#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[]) {
  int i = 0;
  while (i < argc) {
    printf("arg %d: %s\n", i, argv[i]);
    i++;
  }
  char *states[] = {"California", "Oregon", "Washington", "Texas"};
  int num_states = 4;
  i = num_states;
  while (i > 0) {
    printf("state %d: %s\n", num_states - i, states[num_states - i]);
    i--;
  }
  while (argc > 0) {
    if (argc <= num_states) {
      states[argc - 1] = argv[argc - 1];
    }
    argc--;
  }
  i = num_states;
  while (i > 0) {
    printf("state %d: %s\n", num_states - i, states[num_states - i]);
    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)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1162 <main+0x52>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112d <main+0x1d>
mov    0x2c97(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2c94(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0x2c91(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c8e(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x4,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11d2 <main+0xc2>
mov    -0x44(%rbp),%esi
sub    -0x14(%rbp),%esi
mov    -0x44(%rbp),%eax
sub    -0x14(%rbp),%eax
cltq
mov    -0x40(%rbp,%rax,8),%rdx
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    119b <main+0x8b>
jmp    11d7 <main+0xc7>
cmpl   $0x0,-0x8(%rbp)
jle    1219 <main+0x109>
mov    -0x8(%rbp),%eax
cmp    -0x44(%rbp),%eax
jg     120b <main+0xfb>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
mov    %rcx,-0x40(%rbp,%rax,8)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    11d7 <main+0xc7>
mov    -0x44(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    1256 <main+0x146>
mov    -0x44(%rbp),%esi
sub    -0x14(%rbp),%esi
mov    -0x44(%rbp),%eax
sub    -0x14(%rbp),%eax
cltq
mov    -0x40(%rbp,%rax,8),%rdx
lea    0xdec(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    121f <main+0x10f>
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
sub    $0x38,%rsp
mov    %rsi,%r14
mov    %edi,%r15d
mov    %edi,0xc(%rsp)
test   %edi,%edi
jle    1157 <main+0x47>
xor    %ebp,%ebp
lea    0xecb(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r14,%rbp,8),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1140 <main+0x30>
movaps 0x2cb2(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0x2c96(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xeb9(%rip),%rbx
lea    0xe8f(%rip),%rdx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <printf@plt>
lea    0xe89(%rip),%r12
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r12,%rdx
call   1030 <printf@plt>
lea    0xe79(%rip),%r13
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %r13,%rdx
call   1030 <printf@plt>
lea    0xe6d(%rip),%rbp
mov    %rbx,%rdi
mov    $0x3,%esi
mov    %rbp,%rdx
call   1030 <printf@plt>
lea    0xe39(%rip),%rdx
mov    0xc(%rsp),%esi
test   %esi,%esi
jle    1210 <main+0x100>
test   $0x1,%r15b
je     11f7 <main+0xe7>
cmp    $0x4,%esi
ja     11f3 <main+0xe3>
lea    -0x1(%r15),%eax
mov    (%r14,%rax,8),%rcx
mov    %rcx,0x10(%rsp,%rax,8)
add    $0xffffffffffffffff,%r15
cmp    $0x1,%esi
jne    1262 <main+0x152>
mov    0x10(%rsp),%rdx
mov    0x18(%rsp),%r12
mov    0x20(%rsp),%r13
mov    0x28(%rsp),%rbp
lea    0xe18(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r12,%rdx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %r13,%rdx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    %rbp,%rdx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xfffffffe,%eax
add    %r15,%rax
jmp    1286 <main+0x176>
nopl   0x0(%rax)
add    $0xfffffffffffffffe,%rax
lea    0x1(%r15),%rcx
add    $0xffffffffffffffff,%r15
cmp    $0x2,%rcx
jle    11fc <main+0xec>
cmp    $0x4,%r15
ja     1298 <main+0x188>
lea    0x1(%rax),%ecx
mov    (%r14,%rcx,8),%rdx
mov    %rdx,0x10(%rsp,%rcx,8)
add    $0xffffffffffffffff,%r15
cmp    $0x4,%r15
ja     1270 <main+0x160>
mov    %eax,%ecx
shl    $0x3,%rcx
mov    (%r14,%rcx,1),%rdx
mov    %rdx,0x10(%rsp,%rcx,1)
jmp    1270 <main+0x160>

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

LLVM IR (-O2):
@.str = [12 x i8] c"arg %d: %s\0A\00"
@.str.1 = [11 x i8] c"California\00"
@.str.2 = [7 x i8] c"Oregon\00"
@.str.3 = [11 x i8] c"Washington\00"
@.str.4 = [6 x i8] c"Texas\00"
@__const.main.states = [4 x i8*] [i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i32 0, i32 0)]
@.str.5 = [14 x i8] c"state %d: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4 x i8*]
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %15
5: ; preds = %2
%6 = zext i32 %0 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %13, %7 ]
%9 = getelementptr inbounds i8*, i8** %1, i64 %8
%10 = load i8*, i8** %9
%11 = trunc i64 %8 to i32
%12 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %11, i8* %10)
%13 = add nuw nsw i64 %8, 1
%14 = icmp eq i64 %13, %6
br i1 %14, label %15, label %7
15: ; preds = %7, %2
%16 = bitcast [4 x i8*]* %3 to i8*
%17 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 0
%18 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%19 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 1
%20 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%21 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 2
%22 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%23 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 3
%24 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br i1 %4, label %25, label %47
25: ; preds = %15
%26 = zext i32 %0 to i64
%27 = and i64 %26, 1
%28 = icmp eq i64 %27, 0
br i1 %28, label %39, label %29
29: ; preds = %25
%30 = icmp ult i32 %0, 5
br i1 %30, label %31, label %37
31: ; preds = %29
%32 = add nuw nsw i64 %26, 4294967295
%33 = and i64 %32, 4294967295
%34 = getelementptr inbounds i8*, i8** %1, i64 %33
%35 = load i8*, i8** %34
%36 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 %33
store i8* %35, i8** %36
br label %37
37: ; preds = %31, %29
%38 = add nsw i64 %26, -1
br label %39
39: ; preds = %37, %25
%40 = phi i64 [ %26, %25 ], [ %38, %37 ]
%41 = icmp eq i32 %0, 1
br i1 %41, label %42, label %56
42: ; preds = %74, %39
%43 = load i8*, i8** %17
%44 = load i8*, i8** %19
%45 = load i8*, i8** %21
%46 = load i8*, i8** %23
br label %47
47: ; preds = %42, %15
%48 = phi i8* [ %46, %42 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), %15 ]
%49 = phi i8* [ %45, %42 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), %15 ]
%50 = phi i8* [ %44, %42 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %15 ]
%51 = phi i8* [ %43, %42 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), %15 ]
%52 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 0, i8* %51)
%53 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 1, i8* %50)
%54 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 2, i8* %49)
%55 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 3, i8* %48)
ret i32 0
56: ; preds = %39, %74
%57 = phi i64 [ %75, %74 ], [ %40, %39 ]
%58 = icmp ult i64 %57, 5
br i1 %58, label %59, label %65
59: ; preds = %56
%60 = add nuw nsw i64 %57, 4294967295
%61 = and i64 %60, 4294967295
%62 = getelementptr inbounds i8*, i8** %1, i64 %61
%63 = load i8*, i8** %62
%64 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 %61
store i8* %63, i8** %64
br label %65
65: ; preds = %59, %56
%66 = add nsw i64 %57, -1
%67 = icmp ult i64 %66, 5
br i1 %67, label %68, label %74
68: ; preds = %65
%69 = add nsw i64 %57, 4294967294
%70 = and i64 %69, 4294967295
%71 = getelementptr inbounds i8*, i8** %1, i64 %70
%72 = load i8*, i8** %71
%73 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 %70
store i8* %72, i8** %73
br label %74
74: ; preds = %68, %65
%75 = add nsw i64 %57, -2
%76 = icmp sgt i64 %57, 2
br i1 %76, label %56, label %42
}