#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 rand();
int main() {
  int i = 0, j;
  for (i = 0; i < 1000; i++) {
    printf("1\n");
    j = rand();
    if (j == 1) {
      if (i < 500) {
        printf("2\n");
        if (i < 200) {
          printf("3\n");
          if (i == 1 || i == 2 || i == 3) {
            printf("4\n");
          }
        } else if (i == 42) {
          while (1) {
            printf("loooop!\n");
          }
        }
      }
      printf("break!\n");
      break;
    }
    printf("5\n");
  }
  printf("6\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x3e8,-0x8(%rbp)
jge    1220 <main+0x100>
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <rand@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1206 <main+0xe6>
cmpl   $0x1f4,-0x8(%rbp)
jge    11f5 <main+0xd5>
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0xc8,-0x8(%rbp)
jge    11cb <main+0xab>
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
je     11ba <main+0x9a>
cmpl   $0x2,-0x8(%rbp)
je     11ba <main+0x9a>
cmpl   $0x3,-0x8(%rbp)
jne    11c6 <main+0xa6>
lea    0xe48(%rip),%rdi
call   1030 <printf@plt>
jmp    11f0 <main+0xd0>
cmpl   $0x2a,-0x8(%rbp)
jne    11eb <main+0xcb>
jmp    11da <main+0xba>
lea    0xe2b(%rip),%rdi
call   1030 <printf@plt>
jmp    11da <main+0xba>
jmp    11f0 <main+0xd0>
jmp    11f5 <main+0xd5>
lea    0xe19(%rip),%rdi
call   1030 <printf@plt>
jmp    1220 <main+0x100>
lea    0xe10(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113d <main+0x1d>
lea    0xdf9(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xed7(%rip),%rbx
lea    0xed2(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <rand@plt>
cmp    $0x1,%eax
je     1169 <main+0x49>
mov    %r14,%rdi
call   1030 <puts@plt>
add    $0xffffffff,%ebp
cmp    $0xfffffc18,%ebp
jne    1140 <main+0x20>
jmp    11b4 <main+0x94>
mov    %ebp,%ebx
neg    %ebx
cmp    $0x1f3,%ebx
ja     11a8 <main+0x88>
lea    0xe91(%rip),%rdi
call   1030 <puts@plt>
cmp    $0xc7,%ebx
ja     11a8 <main+0x88>
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
not    %ebp
cmp    $0x2,%ebp
ja     11a8 <main+0x88>
lea    0xe6e(%rip),%rdi
call   1030 <puts@plt>
lea    0xe57(%rip),%rdi
call   1030 <puts@plt>
lea    0xe45(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@str = [2 x i8] c"6\00"
@str.8 = [2 x i8] c"1\00"
@str.9 = [2 x i8] c"5\00"
@str.10 = [7 x i8] c"break!\00"
@str.11 = [2 x i8] c"2\00"
@str.12 = [2 x i8] c"3\00"
@str.13 = [2 x i8] c"4\00"
define i32 @main() {
br label %1
1: ; preds = %0, %19
%2 = phi i32 [ 0, %0 ], [ %21, %19 ]
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.8, i64 0, i64 0))
%4 = tail call i32 (...) @rand()
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %19
6: ; preds = %1
%7 = icmp ult i32 %2, 500
br i1 %7, label %8, label %17
8: ; preds = %6
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.11, i64 0, i64 0))
%10 = icmp ult i32 %2, 200
br i1 %10, label %11, label %17
11: ; preds = %8
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.12, i64 0, i64 0))
%13 = add nsw i32 %2, -1
%14 = icmp ult i32 %13, 3
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.13, i64 0, i64 0))
br label %17
17: ; preds = %8, %11, %15, %6
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.10, i64 0, i64 0))
br label %23
19: ; preds = %1
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.9, i64 0, i64 0))
%21 = add nuw nsw i32 %2, 1
%22 = icmp eq i32 %21, 1000
br i1 %22, label %23, label %1
23: ; preds = %19, %17
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret i32 0
}