#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 main(int argc, char *argv[]) {
  printf("The path to the executeable file, and thereby allso the name of the "
         "program: %s\n",
         argv[0]);
  int i = 0;
  printf("The amount of cmd arguments: %d\n", argc);
  for (i = 1; i < argc; i++) {
    printf("arg %d: %s\n", i, argv[i]);
  }
  char *states[] = {"California", "Oregon", "Washington", "Texas"};
  int num_states = 4;
  for (int i = 0; i < num_states; i++) {
    printf("state %d: %s\n", i, states[i]);
  }
  int index = 0;
  while (index < 5) {
    printf("Emulateing a for-loop with a while, this is the index: %d\n",
           index);
    index = index + 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%esi
lea    0xf05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1191 <main+0x81>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xef6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115a <main+0x4a>
mov    0x2c68(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2c65(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0x2c62(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c5f(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x4,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    11ff <main+0xef>
mov    -0x48(%rbp),%esi
movslq -0x48(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdx
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    11cb <main+0xbb>
movl   $0x0,-0x4c(%rbp)
cmpl   $0x5,-0x4c(%rbp)
jge    122f <main+0x11f>
mov    -0x4c(%rbp),%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1206 <main+0xf6>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebx
mov    (%rsi),%rsi
lea    0xed9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf1c(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x2,%ebx
jl     1179 <main+0x69>
mov    %ebx,%r12d
mov    $0x1,%ebx
lea    0xf20(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r14,%rbx,8),%rdx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1160 <main+0x50>
lea    0xf21(%rip),%rbx
lea    0xef7(%rip),%rdx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeef(%rip),%rdx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee0(%rip),%rdx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed5(%rip),%rdx
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed3(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [81 x i8] c"The path to the executeable file, and thereby allso the name of the program: %s\0A\00"
@.str.1 = [33 x i8] c"The amount of cmd arguments: %d\0A\00"
@.str.2 = [12 x i8] c"arg %d: %s\0A\00"
@.str.3 = [11 x i8] c"California\00"
@.str.4 = [7 x i8] c"Oregon\00"
@.str.5 = [11 x i8] c"Washington\00"
@.str.6 = [6 x i8] c"Texas\00"
@__const.main.states = [4 x i8*] [i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0)]
@.str.7 = [14 x i8] c"state %d: %s\0A\00"
@.str.8 = [59 x i8] c"Emulateing a for-loop with a while, this is the index: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [4 x i8*]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 0, i32* %6
%15 = load i32, i32* %4
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %15)
store i32 1, i32* %6
br label %17
17: ; preds = %29, %2
%18 = load i32, i32* %6
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %32
21: ; preds = %17
%22 = load i32, i32* %6
%23 = load i8**, i8*** %5
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %22, i8* %27)
br label %29
29: ; preds = %21
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %17
32: ; preds = %17
%33 = bitcast [4 x i8*]* %7 to i8*
store i32 4, i32* %8
store i32 0, i32* %9
br label %34
34: ; preds = %45, %32
%35 = load i32, i32* %9
%36 = load i32, i32* %8
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %48
38: ; preds = %34
%39 = load i32, i32* %9
%40 = load i32, i32* %9
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 %41
%43 = load i8*, i8** %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 %39, i8* %43)
br label %45
45: ; preds = %38
%46 = load i32, i32* %9
%47 = add nsw i32 %46, 1
store i32 %47, i32* %9
br label %34
48: ; preds = %34
store i32 0, i32* %10
br label %49
49: ; preds = %52, %48
%50 = load i32, i32* %10
%51 = icmp slt i32 %50, 5
br i1 %51, label %52, label %57
52: ; preds = %49
%53 = load i32, i32* %10
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.8, i64 0, i64 0), i32 %53)
%55 = load i32, i32* %10
%56 = add nsw i32 %55, 1
store i32 %56, i32* %10
br label %49
57: ; preds = %49
ret i32 0
}

LLVM IR (-O2):
@.str = [81 x i8] c"The path to the executeable file, and thereby allso the name of the program: %s\0A\00"
@.str.1 = [33 x i8] c"The amount of cmd arguments: %d\0A\00"
@.str.2 = [12 x i8] c"arg %d: %s\0A\00"
@.str.3 = [11 x i8] c"California\00"
@.str.4 = [7 x i8] c"Oregon\00"
@.str.5 = [11 x i8] c"Washington\00"
@.str.6 = [6 x i8] c"Texas\00"
@.str.7 = [14 x i8] c"state %d: %s\0A\00"
@.str.8 = [59 x i8] c"Emulateing a for-loop with a while, this is the index: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %0)
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = zext i32 %0 to i64
br label %19
9: ; preds = %19, %2
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.8, i64 0, i64 0), i32 0)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.8, i64 0, i64 0), i32 1)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.8, i64 0, i64 0), i32 2)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.8, i64 0, i64 0), i32 3)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.8, i64 0, i64 0), i32 4)
ret i32 0
19: ; preds = %7, %19
%20 = phi i64 [ 1, %7 ], [ %25, %19 ]
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i8*, i8** %21
%23 = trunc i64 %20 to i32
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %23, i8* %22)
%25 = add nuw nsw i64 %20, 1
%26 = icmp eq i64 %25, %8
br i1 %26, label %9, label %19
}