#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;
  char *states[] = {"California", "Oregon", "Washington", "Texas"};
  int num_states = 4;
  char *tmp = states[0];
  states[0] = argv[0];
  argv[0] = tmp;
  for (i = 0; i < argc; i++) {
    printf("arg %d: %s\n", i, argv[i]);
  }
  for (i = 0; i < num_states; i++) {
    printf("state %d: %s.\n", i, states[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    0x2ccc(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2cc9(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0x2cc6(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cc3(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x4,-0x44(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x50(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ba <main+0xaa>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1185 <main+0x75>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    11f3 <main+0xe3>
mov    -0x14(%rbp),%esi
movslq -0x14(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdx
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c1 <main+0xb1>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    (%rsi),%r14
lea    0xede(%rip),%rax
mov    %rax,(%rsi)
test   %edi,%edi
jle    1177 <main+0x67>
mov    %rsi,%r12
mov    %edi,%ebp
lea    0xeee(%rip),%rdi
lea    0xec4(%rip),%rdx
xor    %esi,%esi
call   1030 <printf@plt>
cmp    $0x1,%ebp
je     1177 <main+0x67>
mov    %ebp,%ebx
mov    $0x1,%ebp
lea    0xecd(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
mov    (%r12,%rbp,8),%rdx
mov    %r15,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1160 <main+0x50>
lea    0xeb1(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r14,%rdx
call   1030 <printf@plt>
lea    0xe79(%rip),%rdx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
lea    0xe6c(%rip),%rdx
mov    %rbx,%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
lea    0xe63(%rip),%rdx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
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"
@__const.main.states = [4 x i8*] [i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [12 x i8] c"arg %d: %s\0A\00"
@.str.5 = [15 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
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%10 = bitcast [4 x i8*]* %7 to i8*
store i32 4, i32* %8
%11 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 0
%12 = load i8*, i8** %11
store i8* %12, i8** %9
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 0
store i8* %15, i8** %16
%17 = load i8*, i8** %9
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
store i8* %17, i8** %19
store i32 0, i32* %6
br label %20
20: ; preds = %32, %2
%21 = load i32, i32* %6
%22 = load i32, i32* %4
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %35
24: ; preds = %20
%25 = load i32, i32* %6
%26 = load i8**, i8*** %5
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %25, i8* %30)
br label %32
32: ; preds = %24
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %20
35: ; preds = %20
store i32 0, i32* %6
br label %36
36: ; preds = %47, %35
%37 = load i32, i32* %6
%38 = load i32, i32* %8
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %50
40: ; preds = %36
%41 = load i32, i32* %6
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 %43
%45 = load i8*, i8** %44
%46 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %41, i8* %45)
br label %47
47: ; preds = %40
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
br label %36
50: ; preds = %36
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 = [12 x i8] c"arg %d: %s\0A\00"
@.str.5 = [15 x i8] c"state %d: %s.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %1
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = zext i32 %0 to i64
%7 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %0, 1
br i1 %8, label %9, label %14
9: ; preds = %14, %5, %2
%10 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 0, i8* %3)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
14: ; preds = %5, %14
%15 = phi i64 [ %20, %14 ], [ 1, %5 ]
%16 = getelementptr inbounds i8*, i8** %1, i64 %15
%17 = load i8*, i8** %16
%18 = trunc i64 %15 to i32
%19 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %18, i8* %17)
%20 = add nuw nsw i64 %15, 1
%21 = icmp eq i64 %20, %6
br i1 %21, label %9, label %14
}