#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, long);
long main() {
  long a, i;
  a = 10;
  i = 0;
  while (i < 10 && a > 0) {
    printf("value of i: %ld\n", i);
    i = i + 1;
    a = a - 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0xa,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
xor    %eax,%eax
cmpq   $0xa,-0x10(%rbp)
mov    %al,-0x11(%rbp)
jge    1143 <main+0x33>
cmpq   $0x0,-0x8(%rbp)
setg   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1153 <main+0x43>
jmp    1180 <main+0x70>
mov    -0x10(%rbp),%rsi
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1128 <main+0x18>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xee8(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <printf@plt>
mov    $0x1,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    $0x2,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    $0x3,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    $0x4,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    $0x5,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    $0x6,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    $0x7,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    $0x8,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    $0x9,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"value of i: %ld\0A\00"
define i64 @main() {
%1 = alloca i64
%2 = alloca i64
store i64 10, i64* %1
store i64 0, i64* %2
br label %3
3: ; preds = %11, %0
%4 = load i64, i64* %2
%5 = icmp slt i64 %4, 10
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = load i64, i64* %1
%8 = icmp sgt i64 %7, 0
br label %9
9: ; preds = %6, %3
%10 = phi i1 [ false, %3 ], [ %8, %6 ]
br i1 %10, label %11, label %18
11: ; preds = %9
%12 = load i64, i64* %2
%13 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %12)
%14 = load i64, i64* %2
%15 = add nsw i64 %14, 1
store i64 %15, i64* %2
%16 = load i64, i64* %1
%17 = sub nsw i64 %16, 1
store i64 %17, i64* %1
br label %3
18: ; preds = %9
ret i64 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"value of i: %ld\0A\00"
define i64 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 0)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 1)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 2)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 3)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 4)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 5)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 6)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 7)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 8)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 9)
ret i64 0
}