On Mon, 2010-01-04 at 01:19 +0530, prashant rawat wrote: > Thanks a lot :) > However, what if I make variable a global? > Now it will be there in the assembly code. > #include<stdio.h> > int b, a=0; > int main () > { > while (a < 100) > { > b = 10; > a = a + 1; > printf ("%d\n", a); > } > printf ("%d, %d\n", b, a); > return 0; > } > Yes, it will be in the assembly language, but its value is ignored if it is => 100. Otherwise, it's just set to 100: .file "loop_invar_2.c" .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "%d\n" .text .p2align 4,,15 .globl main .type main, @function main: .LFB22: .cfi_startproc subq $24, %rsp .cfi_def_cfa_offset 32 cmpl $99, a(%rip) # compare a to 99 jg .L6 # greater, ignore loop stuff movl $10, 12(%rsp) # b = 10; movl $100, a(%rip) # a = 100; movl $10, %edx .L3: leaq 12(%rsp), %rax movl $.LC0, %esi movl $1, %edi movq %rax, c(%rip) xorl %eax, %eax call __printf_chk xorl %eax, %eax addq $24, %rsp ret .p2align 4,,10 .p2align 3 .L6: movl 12(%rsp), %edx # use current b (garbage) jmp .L3 .cfi_endproc .LFE22: .size main, .-main .globl a .bss .align 4 .type a, @object .size a, 4 a: .zero 4 .comm c,8,8 .ident "GCC: (Ubuntu 4.4.1-4ubuntu8) 4.4.1" .section .note.GNU-stack,"",@progbits