#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"};
  i = 0;
  if (argc > 4) {
    argc = 4;
  }
  while (i < argc) {
    printf("arg %d: %s\n", i, argv[i]);
    states[i] = argv[i];
    i++;
  }
  int num_states = 4 - 1;
  i = 0;
  while (num_states > -1) {
    printf("state %d: %s\n", num_states, states[num_states]);
    num_states--;
  }
  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   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x8(%rbp)
jle    11a6 <main+0x96>
movl   $0x4,-0x8(%rbp)
jmp    11ab <main+0x9b>
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f5 <main+0xe5>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe33(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
movslq -0x14(%rbp),%rax
mov    %rcx,-0x40(%rbp,%rax,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ab <main+0x9b>
movl   $0x3,-0x44(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xffffffff,-0x44(%rbp)
jle    1233 <main+0x123>
mov    -0x44(%rbp),%esi
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdx
lea    0xe0f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x44(%rbp)
jmp    1203 <main+0xf3>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
test   %edi,%edi
jle    11c4 <main+0xb4>
mov    %rsi,%rbx
mov    %edi,%r14d
mov    %edi,%r12d
xor    %ebp,%ebp
lea    0xeca(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx,%rbp,8),%rdx
mov    %r15,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1140 <main+0x30>
movaps 0x2cb2(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0x2c96(%rip),%xmm0
movaps %xmm0,(%rsp)
test   %r14d,%r14d
jle    11db <main+0xcb>
cmp    $0x4,%r12d
mov    $0x4,%r15d
cmovb  %r14d,%r15d
xor    %ebp,%ebp
lea    0xe76(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    (%rbx,%rbp,8),%rdx
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    (%rbx,%rbp,8),%rax
mov    %rax,(%rsp,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1190 <main+0x80>
mov    0x18(%rsp),%rdx
mov    0x10(%rsp),%rbp
mov    (%rsp),%r14
mov    0x8(%rsp),%r15
jmp    11f7 <main+0xe7>
movaps 0x2c45(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0x2c29(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xe47(%rip),%rdx
lea    0xe35(%rip),%rbp
lea    0xe27(%rip),%r15
lea    0xe15(%rip),%r14
lea    0xe31(%rip),%rbx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %rbp,%rdx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r15,%rdx
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r14,%rdx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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 0, i32* %6
%25 = load i32, i32* %4
%26 = icmp sgt i32 %25, 4
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 4, i32* %4
br label %28
28: ; preds = %27, %23
br label %29
29: ; preds = %33, %28
%30 = load i32, i32* %6
%31 = load i32, i32* %4
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %51
33: ; preds = %29
%34 = load i32, i32* %6
%35 = load i8**, i8*** %5
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
%39 = load i8*, i8** %38
%40 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %34, i8* %39)
%41 = load i8**, i8*** %5
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %41, i64 %43
%45 = load i8*, i8** %44
%46 = load i32, i32* %6
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 %47
store i8* %45, i8** %48
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
br label %29
51: ; preds = %29
store i32 3, i32* %8
store i32 0, i32* %6
br label %52
52: ; preds = %55, %51
%53 = load i32, i32* %8
%54 = icmp sgt i32 %53, -1
br i1 %54, label %55, label %64
55: ; preds = %52
%56 = load i32, i32* %8
%57 = load i32, i32* %8
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 %58
%60 = load i8*, i8** %59
%61 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %56, i8* %60)
%62 = load i32, i32* %8
%63 = add nsw i32 %62, -1
store i32 %63, i32* %8
br label %52
64: ; preds = %52
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 %7, label %5
5: ; preds = %2
%6 = bitcast [4 x i8*]* %3 to i8*
br label %32
7: ; preds = %2
%8 = zext i32 %0 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %15, %9 ]
%11 = getelementptr inbounds i8*, i8** %1, i64 %10
%12 = load i8*, i8** %11
%13 = trunc i64 %10 to i32
%14 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %13, i8* %12)
%15 = add nuw nsw i64 %10, 1
%16 = icmp eq i64 %15, %8
br i1 %16, label %17, label %9
17: ; preds = %9
%18 = bitcast [4 x i8*]* %3 to i8*
br i1 %4, label %19, label %32
19: ; preds = %17
%20 = icmp ult i32 %0, 4
%21 = select i1 %20, i32 %0, i32 4
%22 = zext i32 %21 to i64
br label %42
23: ; preds = %42
%24 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 3
%25 = load i8*, i8** %24
%26 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 2
%27 = load i8*, i8** %26
%28 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 1
%29 = load i8*, i8** %28
%30 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 0
%31 = load i8*, i8** %30
br label %32
32: ; preds = %5, %23, %17
%33 = phi i8* [ %31, %23 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), %17 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), %5 ]
%34 = phi i8* [ %29, %23 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %17 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %5 ]
%35 = phi i8* [ %27, %23 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), %17 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), %5 ]
%36 = phi i8* [ %25, %23 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), %17 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), %5 ]
%37 = bitcast [4 x i8*]* %3 to i8*
%38 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 3, i8* %36)
%39 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 2, i8* %35)
%40 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 1, i8* %34)
%41 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 0, i8* %33)
ret i32 0
42: ; preds = %19, %42
%43 = phi i64 [ 0, %19 ], [ %50, %42 ]
%44 = getelementptr inbounds i8*, i8** %1, i64 %43
%45 = load i8*, i8** %44
%46 = trunc i64 %43 to i32
%47 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %46, i8* %45)
%48 = load i8*, i8** %44
%49 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 %43
store i8* %48, i8** %49
%50 = add nuw nsw i64 %43, 1
%51 = icmp eq i64 %50, %22
br i1 %51, label %23, label %42
}