#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 = argc - 1;
  while (i >= 0) {
    printf("arg %d: %s\n", i, *(argv + i));
    i--;
  }
  char *states[] = {"California", "Oregon", "Washington", "Texas"};
  int num_states = 4;
  i = 0;
  while (i < argc - 1 && i < num_states) {
    *(states + i) = *(argv + i + 1);
    i++;
  }
  i = num_states - 1;
  while (i >= 0) {
    printf("state %d: %s\n", i, *(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)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     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    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    112f <main+0x1f>
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)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x45(%rbp)
jge    11be <main+0xae>
mov    -0x14(%rbp),%eax
cmp    -0x44(%rbp),%eax
setl   %al
mov    %al,-0x45(%rbp)
mov    -0x45(%rbp),%al
test   $0x1,%al
jne    11ce <main+0xbe>
jmp    11f2 <main+0xe2>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    0x8(%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    119c <main+0x8c>
mov    -0x44(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     122b <main+0x11b>
mov    -0x14(%rbp),%esi
movslq -0x14(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdx
lea    0xe17(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    11fb <main+0xeb>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %edi,%edi
jle    11ad <main+0x8d>
mov    %rsi,%r15
mov    %edi,%r14d
lea    -0x1(%r14),%ebx
lea    0xec0(%rip),%r12
mov    (%r15,%rbx,8),%rdx
mov    %r12,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
add    $0xffffffffffffffff,%rbx
jb     1140 <main+0x20>
movaps 0x2cb5(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0x2c99(%rip),%xmm0
movaps %xmm0,(%rsp)
cmp    $0x2,%r14d
jl     11c4 <main+0xa4>
add    $0x8,%r15
add    $0xfffffffe,%r14d
cmp    $0x3,%r14d
mov    $0x3,%eax
cmovb  %r14d,%eax
lea    0x8(,%rax,8),%edx
mov    %rsp,%rdi
mov    %r15,%rsi
call   1040 <memcpy@plt>
mov    0x18(%rsp),%rdx
mov    0x10(%rsp),%r12
mov    (%rsp),%r14
mov    0x8(%rsp),%r15
jmp    11e0 <main+0xc0>
movaps 0x2c5c(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0x2c40(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xe5e(%rip),%rdx
lea    0xe4c(%rip),%r12
lea    0xe3e(%rip),%r15
lea    0xe2c(%rip),%r14
lea    0xe48(%rip),%rbx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %r12,%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    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
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
%9 = load i32, i32* %4
%10 = sub nsw i32 %9, 1
store i32 %10, i32* %6
br label %11
11: ; preds = %14, %2
%12 = load i32, i32* %6
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %24
14: ; preds = %11
%15 = load i32, i32* %6
%16 = load i8**, i8*** %5
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %16, i64 %18
%20 = load i8*, i8** %19
%21 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %15, i8* %20)
%22 = load i32, i32* %6
%23 = add nsw i32 %22, -1
store i32 %23, i32* %6
br label %11
24: ; preds = %11
%25 = bitcast [4 x i8*]* %7 to i8*
store i32 4, i32* %8
store i32 0, i32* %6
br label %26
26: ; preds = %37, %24
%27 = load i32, i32* %6
%28 = load i32, i32* %4
%29 = sub nsw i32 %28, 1
%30 = icmp slt i32 %27, %29
br i1 %30, label %31, label %35
31: ; preds = %26
%32 = load i32, i32* %6
%33 = load i32, i32* %8
%34 = icmp slt i32 %32, %33
br label %35
35: ; preds = %31, %26
%36 = phi i1 [ false, %26 ], [ %34, %31 ]
br i1 %36, label %37, label %50
37: ; preds = %35
%38 = load i8**, i8*** %5
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %38, i64 %40
%42 = getelementptr inbounds i8*, i8** %41, i64 1
%43 = load i8*, i8** %42
%44 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 0
%45 = load i32, i32* %6
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %44, i64 %46
store i8* %43, i8** %47
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
br label %26
50: ; preds = %35
%51 = load i32, i32* %8
%52 = sub nsw i32 %51, 1
store i32 %52, i32* %6
br label %53
53: ; preds = %56, %50
%54 = load i32, i32* %6
%55 = icmp sge i32 %54, 0
br i1 %55, label %56, label %66
56: ; preds = %53
%57 = load i32, i32* %6
%58 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 0
%59 = load i32, i32* %6
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8*, i8** %58, i64 %60
%62 = load i8*, i8** %61
%63 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %57, i8* %62)
%64 = load i32, i32* %6
%65 = add nsw i32 %64, -1
store i32 %65, i32* %6
br label %53
66: ; preds = %53
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 %37
7: ; preds = %2
%8 = add nsw i32 %0, -1
%9 = zext i32 %8 to i64
br label %10
10: ; preds = %7, %10
%11 = phi i64 [ %9, %7 ], [ %16, %10 ]
%12 = getelementptr inbounds i8*, i8** %1, i64 %11
%13 = load i8*, i8** %12
%14 = trunc i64 %11 to i32
%15 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %14, i8* %13)
%16 = add nsw i64 %11, -1
%17 = icmp eq i64 %11, 0
br i1 %17, label %18, label %10
18: ; preds = %10
%19 = bitcast [4 x i8*]* %3 to i8*
%20 = icmp sgt i32 %0, 1
br i1 %20, label %21, label %37
21: ; preds = %18
%22 = getelementptr i8*, i8** %1, i64 1
%23 = bitcast i8** %22 to i8*
%24 = add nsw i32 %0, -2
%25 = call i32 @llvm.umin.i32(i32 %24, i32 3)
%26 = shl nuw nsw i32 %25, 3
%27 = add nuw nsw i32 %26, 8
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 3
%30 = load i8*, i8** %29
%31 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 2
%32 = load i8*, i8** %31
%33 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 1
%34 = load i8*, i8** %33
%35 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 0
%36 = load i8*, i8** %35
br label %37
37: ; preds = %5, %21, %18
%38 = phi i8* [ %36, %21 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), %18 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), %5 ]
%39 = phi i8* [ %34, %21 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %18 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %5 ]
%40 = phi i8* [ %32, %21 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), %18 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), %5 ]
%41 = phi i8* [ %30, %21 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), %18 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), %5 ]
%42 = bitcast [4 x i8*]* %3 to i8*
%43 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 3, i8* %41)
%44 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 2, i8* %40)
%45 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 1, i8* %39)
%46 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 0, i8* %38)
ret i32 0
}