#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 = num_states - 1;
  while (i > -1) {
    printf("state %d: %s\n", i, states[i]);
    --i;
  }
  char *copy[argc - 1];
  i = 1;
  while (i < argc) {
    copy[i - 1] = argv[i];
    ++i;
  }
  i = i - 2;
  while (i > -1) {
    printf("copy[%d]: %s\n", i, copy[i]);
    --i;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%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)
jle    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)
mov    -0x44(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jle    11ce <main+0xbe>
mov    -0x14(%rbp),%esi
movslq -0x14(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdx
lea    0xe74(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    119e <main+0x8e>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %rsp,%rcx
mov    %rcx,-0x50(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x58(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1236 <main+0x126>
mov    -0x60(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq -0x14(%rbp),%rdx
mov    (%rcx,%rdx,8),%rdx
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ff <main+0xef>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jle    1272 <main+0x162>
mov    -0x60(%rbp),%rax
mov    -0x14(%rbp),%esi
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xdde(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    123f <main+0x12f>
movl   $0x0,-0x4(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%r13d
lea    -0x1(%r13),%r15d
cmp    $0x2,%edi
jl     116b <main+0x4b>
lea    0xebc(%rip),%r12
mov    %r15,%rbx
nopw   0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rdx
mov    %r12,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
lea    -0x1(%rbx),%rax
cmp    $0x1,%rbx
mov    %rax,%rbx
ja     1150 <main+0x30>
lea    0xebd(%rip),%rbx
lea    0xeb0(%rip),%rdx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
lea    0xe91(%rip),%rdx
mov    %rbx,%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
lea    0xe76(%rip),%rdx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
lea    0xe57(%rip),%rdx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <printf@plt>
mov    %rsp,%r12
lea    0xf(,%r15,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
cmp    $0x1,%r13d
jle    1215 <main+0xf5>
add    $0x8,%r14
shl    $0x3,%r15
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <memcpy@plt>
add    $0xfffffffe,%r13d
lea    0xe42(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    (%r12,%r13,8),%rdx
mov    %r14,%rdi
mov    %r13d,%esi
call   1030 <printf@plt>
add    $0xffffffffffffffff,%r13
jb     1200 <main+0xe0>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
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"
@.str.6 = [14 x i8] c"copy[%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
%9 = alloca i8*
%10 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = sub nsw i32 %11, 1
store i32 %12, i32* %6
br label %13
13: ; preds = %16, %2
%14 = load i32, i32* %6
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %26
16: ; preds = %13
%17 = load i32, i32* %6
%18 = load i8**, i8*** %5
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %17, i8* %22)
%24 = load i32, i32* %6
%25 = add nsw i32 %24, -1
store i32 %25, i32* %6
br label %13
26: ; preds = %13
%27 = bitcast [4 x i8*]* %7 to i8*
store i32 4, i32* %8
%28 = load i32, i32* %8
%29 = sub nsw i32 %28, 1
store i32 %29, i32* %6
br label %30
30: ; preds = %33, %26
%31 = load i32, i32* %6
%32 = icmp sgt i32 %31, -1
br i1 %32, label %33, label %42
33: ; preds = %30
%34 = load i32, i32* %6
%35 = load i32, i32* %6
%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 %34, i8* %38)
%40 = load i32, i32* %6
%41 = add nsw i32 %40, -1
store i32 %41, i32* %6
br label %30
42: ; preds = %30
%43 = load i32, i32* %4
%44 = sub nsw i32 %43, 1
%45 = zext i32 %44 to i64
%46 = call i8* @llvm.stacksave()
store i8* %46, i8** %9
%47 = alloca i8*, i64 %45
store i64 %45, i64* %10
store i32 1, i32* %6
br label %48
48: ; preds = %52, %42
%49 = load i32, i32* %6
%50 = load i32, i32* %4
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %64
52: ; preds = %48
%53 = load i8**, i8*** %5
%54 = load i32, i32* %6
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8*, i8** %53, i64 %55
%57 = load i8*, i8** %56
%58 = load i32, i32* %6
%59 = sub nsw i32 %58, 1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8*, i8** %47, i64 %60
store i8* %57, i8** %61
%62 = load i32, i32* %6
%63 = add nsw i32 %62, 1
store i32 %63, i32* %6
br label %48
64: ; preds = %48
%65 = load i32, i32* %6
%66 = sub nsw i32 %65, 2
store i32 %66, i32* %6
br label %67
67: ; preds = %70, %64
%68 = load i32, i32* %6
%69 = icmp sgt i32 %68, -1
br i1 %69, label %70, label %79
70: ; preds = %67
%71 = load i32, i32* %6
%72 = load i32, i32* %6
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8*, i8** %47, i64 %73
%75 = load i8*, i8** %74
%76 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %71, i8* %75)
%77 = load i32, i32* %6
%78 = add nsw i32 %77, -1
store i32 %78, i32* %6
br label %67
79: ; preds = %67
store i32 0, i32* %3
%80 = load i8*, i8** %9
%81 = load i32, i32* %3
ret i32 %81
}

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"
@.str.5 = [14 x i8] c"state %d: %s\0A\00"
@.str.6 = [14 x i8] c"copy[%d]: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = add i32 %0, -1
%4 = icmp sgt i32 %0, 1
%5 = zext i32 %3 to i64
br i1 %4, label %12, label %6
6: ; preds = %12, %2
%7 = 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))
%8 = 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))
%9 = 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))
%10 = 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))
%11 = alloca i8*, i64 %5
br i1 %4, label %20, label %35
12: ; preds = %2, %12
%13 = phi i64 [ %18, %12 ], [ %5, %2 ]
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = trunc i64 %13 to i32
%17 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %16, i8* %15)
%18 = add nsw i64 %13, -1
%19 = icmp ugt i64 %13, 1
br i1 %19, label %12, label %6
20: ; preds = %6
%21 = bitcast i8** %11 to i8*
%22 = getelementptr i8*, i8** %1, i64 1
%23 = bitcast i8** %22 to i8*
%24 = shl nuw nsw i64 %5, 3
%25 = add nsw i32 %0, -2
%26 = zext i32 %25 to i64
br label %27
27: ; preds = %20, %27
%28 = phi i64 [ %26, %20 ], [ %33, %27 ]
%29 = getelementptr inbounds i8*, i8** %11, i64 %28
%30 = load i8*, i8** %29
%31 = trunc i64 %28 to i32
%32 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %31, i8* %30)
%33 = add nsw i64 %28, -1
%34 = icmp eq i64 %28, 0
br i1 %34, label %35, label %27
35: ; preds = %27, %6
ret i32 0
}