#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, char *);
int main(int argc, char *argv[]) {
  char *states[] = {"California", "Oregon", NULL, "Washington", "Texas"};
  int num_states = 5;
  for (int i = 0; i < num_states; i++) {
    printf("state %d: %s\n", i, states[i]);
  }
  states[2] = "New York";
  for (int i = 0; i < num_states; i++) {
    printf("state %d: %s\n", i, states[i]);
  }
  argv[0] = "Hello World!";
  for (int i = 0; i < argc; i++) {
    printf("arg %d: %s.\n", i, argv[i]);
  }
  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)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
lea    0xeb3(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xeb3(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xeaf(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xeaf(%rip),%rax
mov    %rax,-0x20(%rbp)
movl   $0x5,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    11b2 <main+0x92>
mov    -0x48(%rbp),%esi
movslq -0x48(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdx
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1180 <main+0x60>
lea    0xe78(%rip),%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    11f6 <main+0xd6>
mov    -0x4c(%rbp),%esi
movslq -0x4c(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdx
lea    0xe40(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11c4 <main+0xa4>
mov    -0x10(%rbp),%rax
lea    0xe39(%rip),%rcx
mov    %rcx,(%rax)
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1240 <main+0x120>
mov    -0x50(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x50(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe1a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    120b <main+0xeb>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %edi,%r14d
lea    0xefb(%rip),%rbp
lea    0xed1(%rip),%rdx
mov    %rbp,%rdi
xor    %esi,%esi
call   1030 <printf@plt>
lea    0xecb(%rip),%rbx
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
call   1030 <printf@plt>
mov    %rbp,%rdi
mov    $0x2,%esi
xor    %edx,%edx
call   1030 <printf@plt>
lea    0xeac(%rip),%r13
mov    %rbp,%rdi
mov    $0x3,%esi
mov    %r13,%rdx
call   1030 <printf@plt>
lea    0xea0(%rip),%r15
mov    %rbp,%rdi
mov    $0x4,%esi
mov    %r15,%rdx
call   1030 <printf@plt>
mov    %rbp,%rdi
xor    %esi,%esi
lea    0xe67(%rip),%rdx
call   1030 <printf@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
call   1030 <printf@plt>
lea    0xe7c(%rip),%rdx
mov    %rbp,%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
mov    %rbp,%rdi
mov    $0x3,%esi
mov    %r13,%rdx
call   1030 <printf@plt>
mov    %rbp,%rdi
mov    $0x4,%esi
mov    %r15,%rdx
call   1030 <printf@plt>
lea    0xe51(%rip),%rax
mov    %rax,(%r12)
test   %r14d,%r14d
jle    1237 <main+0x127>
lea    0xe4e(%rip),%rdi
lea    0xe3a(%rip),%rdx
xor    %esi,%esi
call   1030 <printf@plt>
cmp    $0x1,%r14d
je     1237 <main+0x127>
mov    %r14d,%ebx
mov    $0x1,%ebp
lea    0xe2b(%rip),%r14
nopl   0x0(%rax)
mov    (%r12,%rbp,8),%rdx
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1220 <main+0x110>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"California\00"
@.str.1 = [7 x i8] c"Oregon\00"
@.str.2 = [11 x i8] c"Washington\00"
@.str.3 = [6 x i8] c"Texas\00"
@.str.4 = [14 x i8] c"state %d: %s\0A\00"
@.str.5 = [9 x i8] c"New York\00"
@.str.6 = [13 x i8] c"Hello World!\00"
@.str.7 = [13 x i8] c"arg %d: %s.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [5 x i8*]
%7 = alloca i32
%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 = bitcast [5 x i8*]* %6 to i8*
%12 = bitcast i8* %11 to [5 x i8*]*
%13 = getelementptr inbounds [5 x i8*], [5 x i8*]* %12, i32 0, i32 0
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0), i8** %13
%14 = getelementptr inbounds [5 x i8*], [5 x i8*]* %12, i32 0, i32 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i8** %14
%15 = getelementptr inbounds [5 x i8*], [5 x i8*]* %12, i32 0, i32 3
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i32 0, i32 0), i8** %15
%16 = getelementptr inbounds [5 x i8*], [5 x i8*]* %12, i32 0, i32 4
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8** %16
store i32 5, i32* %7
store i32 0, i32* %8
br label %17
17: ; preds = %28, %2
%18 = load i32, i32* %8
%19 = load i32, i32* %7
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %31
21: ; preds = %17
%22 = load i32, i32* %8
%23 = load i32, i32* %8
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [5 x i8*], [5 x i8*]* %6, i64 0, i64 %24
%26 = load i8*, i8** %25
%27 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %22, i8* %26)
br label %28
28: ; preds = %21
%29 = load i32, i32* %8
%30 = add nsw i32 %29, 1
store i32 %30, i32* %8
br label %17
31: ; preds = %17
%32 = getelementptr inbounds [5 x i8*], [5 x i8*]* %6, i64 0, i64 2
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8** %32
store i32 0, i32* %9
br label %33
33: ; preds = %44, %31
%34 = load i32, i32* %9
%35 = load i32, i32* %7
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %47
37: ; preds = %33
%38 = load i32, i32* %9
%39 = load i32, i32* %9
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [5 x i8*], [5 x i8*]* %6, i64 0, i64 %40
%42 = load i8*, i8** %41
%43 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %38, i8* %42)
br label %44
44: ; preds = %37
%45 = load i32, i32* %9
%46 = add nsw i32 %45, 1
store i32 %46, i32* %9
br label %33
47: ; preds = %33
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 0
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8** %49
store i32 0, i32* %10
br label %50
50: ; preds = %62, %47
%51 = load i32, i32* %10
%52 = load i32, i32* %4
%53 = icmp slt i32 %51, %52
br i1 %53, label %54, label %65
54: ; preds = %50
%55 = load i32, i32* %10
%56 = load i8**, i8*** %5
%57 = load i32, i32* %10
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %56, i64 %58
%60 = load i8*, i8** %59
%61 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i32 %55, i8* %60)
br label %62
62: ; preds = %54
%63 = load i32, i32* %10
%64 = add nsw i32 %63, 1
store i32 %64, i32* %10
br label %50
65: ; preds = %50
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"California\00"
@.str.1 = [7 x i8] c"Oregon\00"
@.str.2 = [11 x i8] c"Washington\00"
@.str.3 = [6 x i8] c"Texas\00"
@.str.4 = [14 x i8] c"state %d: %s\0A\00"
@.str.5 = [9 x i8] c"New York\00"
@.str.6 = [13 x i8] c"Hello World!\00"
@.str.7 = [13 x i8] c"arg %d: %s.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 2, i8* null)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%8 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%11 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8** %1
%13 = icmp sgt i32 %0, 0
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = zext i32 %0 to i64
%16 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%17 = icmp eq i32 %0, 1
br i1 %17, label %18, label %19
18: ; preds = %19, %14, %2
ret i32 0
19: ; preds = %14, %19
%20 = phi i64 [ %25, %19 ], [ 1, %14 ]
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i8*, i8** %21
%23 = trunc i64 %20 to i32
%24 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i32 %23, i8* %22)
%25 = add nuw nsw i64 %20, 1
%26 = icmp eq i64 %25, %15
br i1 %26, label %18, label %19
}