#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 *, int);
int main(int argc, char **argv) {
  for (int x = 5; x; x--) {
    printf("x is %d\n", x);
  }
  for (int x = 0; x < 5; x++) {
    printf("x is %d\n", x);
  }
  int ia[] = {1, 2, 3, 4, 5, 0};
  for (int *ip = ia; *ip; ip++) {
    printf("value is %d\n", *ip);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x5,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1154 <main+0x44>
mov    -0x14(%rbp),%esi
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    112d <main+0x1d>
movl   $0x0,-0x18(%rbp)
cmpl   $0x5,-0x18(%rbp)
jge    1182 <main+0x72>
mov    -0x18(%rbp),%esi
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115b <main+0x4b>
mov    0xe97(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe94(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe91(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmpl   $0x0,(%rax)
je     11db <main+0xcb>
mov    -0x38(%rbp),%rax
mov    (%rax),%esi
lea    0xe44(%rip),%rdi
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x38(%rbp)
jmp    11ab <main+0x9b>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0xee1(%rip),%r14
mov    %r14,%rdi
mov    $0x5,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x4,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
mov    $0x1,%ebp
mov    %r14,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x4,%esi
call   1030 <printf@plt>
mov    0xe86(%rip),%rax
mov    %rax,0x10(%rsp)
movaps 0xe6a(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x4(%rsp),%rbx
lea    0xe43(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    (%rbx),%ebp
add    $0x4,%rbx
test   %ebp,%ebp
jne    11d0 <main+0xc0>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"x is %d\0A\00"
@__const.main.ia = [6 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 0]
@.str.1 = [13 x i8] c"value is %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [6 x i32]
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 5, i32* %6
br label %10
10: ; preds = %16, %2
%11 = load i32, i32* %6
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %10
%14 = load i32, i32* %6
%15 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %13
%17 = load i32, i32* %6
%18 = add nsw i32 %17, -1
store i32 %18, i32* %6
br label %10
19: ; preds = %10
store i32 0, i32* %7
br label %20
20: ; preds = %26, %19
%21 = load i32, i32* %7
%22 = icmp slt i32 %21, 5
br i1 %22, label %23, label %29
23: ; preds = %20
%24 = load i32, i32* %7
%25 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %23
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %20
29: ; preds = %20
%30 = bitcast [6 x i32]* %8 to i8*
%31 = getelementptr inbounds [6 x i32], [6 x i32]* %8, i64 0, i64 0
store i32* %31, i32** %9
br label %32
32: ; preds = %40, %29
%33 = load i32*, i32** %9
%34 = load i32, i32* %33
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %43
36: ; preds = %32
%37 = load i32*, i32** %9
%38 = load i32, i32* %37
%39 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %36
%41 = load i32*, i32** %9
%42 = getelementptr inbounds i32, i32* %41, i32 1
store i32* %42, i32** %9
br label %32
43: ; preds = %32
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"x is %d\0A\00"
@__const.main.ia = [6 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 0]
@.str.1 = [13 x i8] c"value is %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [6 x i32]
%4 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 5)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 4)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 3)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 2)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 1)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 0)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 1)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 2)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 3)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 4)
%14 = bitcast [6 x i32]* %3 to i8*
%15 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
br label %17
16: ; preds = %17
ret i32 0
17: ; preds = %2, %17
%18 = phi i32 [ %22, %17 ], [ 1, %2 ]
%19 = phi i32* [ %21, %17 ], [ %15, %2 ]
%20 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%21 = getelementptr inbounds i32, i32* %19, i64 1
%22 = load i32, i32* %21
%23 = icmp eq i32 %22, 0
br i1 %23, label %16, label %17
}