#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 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 = 0;
  while (i < num_states) {
    printf("state %d: %s\n", i, states[i]);
    i++;
  }
  char *cakes[] = {"chocolate cake", "raspberry cake", "layered cake"};
  i = 3;
  while (0 < i) {
    printf("Cake on index %d is: %s\n", i, cakes[i]);
    i--;
  }
  i = 0;
  char *copied_args[argc];
  while (i < argc) {
    if (argv[i]) {
      copied_args[i] = argv[i];
      printf("Copied value: %s\n", copied_args[i]);
    }
    i++;
  }
  for (int j = 0; j < argc; j++) {
    printf("The value i copied earlier %s\n", copied_args[j]);
  }
  copied_args[1] = "something new";
  printf("Has the value changed? if it has, it should be equal \"Something "
         "new\" : %s \n",
         argv[1]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%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    1167 <main+0x57>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1130 <main+0x20>
mov    0x2c72(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2c6f(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0x2c6c(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c69(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x4,-0x44(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    11d5 <main+0xc5>
mov    -0x14(%rbp),%esi
movslq -0x14(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdx
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a1 <main+0x91>
mov    0x2c24(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0x2c21(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0x2c1e(%rip),%rax
mov    %rax,-0x50(%rbp)
movl   $0x3,-0x14(%rbp)
xor    %eax,%eax
cmp    -0x14(%rbp),%eax
jge    1230 <main+0x120>
mov    -0x14(%rbp),%esi
movslq -0x14(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rdx
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    11fd <main+0xed>
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x68(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x80(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x70(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12b9 <main+0x1a9>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     12ab <main+0x19b>
mov    -0x80(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq -0x14(%rbp),%rdx
mov    (%rcx,%rdx,8),%rdx
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    125e <main+0x14e>
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12f4 <main+0x1e4>
mov    -0x80(%rbp),%rax
movslq -0x74(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    12c0 <main+0x1b0>
mov    -0x80(%rbp),%rax
lea    0xdb3(%rip),%rcx
mov    %rcx,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x68(%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,%r12
mov    %edi,%r13d
mov    %edi,-0x2c(%rbp)
test   %edi,%edi
jle    1159 <main+0x49>
lea    0xece(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r12,%rbx,8),%rdx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1140 <main+0x30>
lea    0xecf(%rip),%r15
lea    0xea5(%rip),%rdx
mov    %r15,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe9d(%rip),%rdx
mov    %r15,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe8e(%rip),%rdx
mov    %r15,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe83(%rip),%rdx
mov    %r15,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe9d(%rip),%rbx
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe7a(%rip),%rdx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe55(%rip),%rdx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rsp,%r14
lea    0xf(,%r13,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
cmpl   $0x0,-0x2c(%rbp)
jle    1277 <main+0x167>
lea    0xe59(%rip),%r15
xor    %ebx,%ebx
jmp    1229 <main+0x119>
nopl   (%rax)
add    $0x1,%rbx
cmp    %rbx,%r13
je     1242 <main+0x132>
mov    (%r12,%rbx,8),%rsi
test   %rsi,%rsi
je     1220 <main+0x110>
mov    %rsi,(%r14,%rbx,8)
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1220 <main+0x110>
cmpl   $0x0,-0x2c(%rbp)
jle    1277 <main+0x167>
lea    0xe35(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1260 <main+0x150>
mov    0x8(%r12),%rsi
lea    0xe20(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
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 = [15 x i8] c"chocolate cake\00"
@.str.7 = [15 x i8] c"raspberry cake\00"
@.str.8 = [13 x i8] c"layered cake\00"
@__const.main.cakes = [3 x i8*] [i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i32 0, i32 0)]
@.str.9 = [25 x i8] c"Cake on index %d is: %s\0A\00"
@.str.10 = [18 x i8] c"Copied value: %s\0A\00"
@.str.11 = [31 x i8] c"The value i copied earlier %s\0A\00"
@.str.12 = [14 x i8] c"something new\00"
@.str.13 = [76 x i8] c"Has the value changed? if it has, it should be equal \22Something new\22 : %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 [3 x i8*]
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %13
13: ; preds = %17, %2
%14 = load i32, i32* %6
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %27
17: ; preds = %13
%18 = load i32, i32* %6
%19 = load i8**, i8*** %5
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %18, i8* %23)
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %13
27: ; preds = %13
%28 = bitcast [4 x i8*]* %7 to i8*
store i32 4, i32* %8
store i32 0, i32* %6
br label %29
29: ; preds = %33, %27
%30 = load i32, i32* %6
%31 = load i32, i32* %8
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %42
33: ; preds = %29
%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 (i8*, ...) @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 %29
42: ; preds = %29
%43 = bitcast [3 x i8*]* %9 to i8*
store i32 3, i32* %6
br label %44
44: ; preds = %47, %42
%45 = load i32, i32* %6
%46 = icmp slt i32 0, %45
br i1 %46, label %47, label %56
47: ; preds = %44
%48 = load i32, i32* %6
%49 = load i32, i32* %6
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [3 x i8*], [3 x i8*]* %9, i64 0, i64 %50
%52 = load i8*, i8** %51
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), i32 %48, i8* %52)
%54 = load i32, i32* %6
%55 = add nsw i32 %54, -1
store i32 %55, i32* %6
br label %44
56: ; preds = %44
store i32 0, i32* %6
%57 = load i32, i32* %4
%58 = zext i32 %57 to i64
%59 = call i8* @llvm.stacksave()
store i8* %59, i8** %10
%60 = alloca i8*, i64 %58
store i64 %58, i64* %11
br label %61
61: ; preds = %86, %56
%62 = load i32, i32* %6
%63 = load i32, i32* %4
%64 = icmp slt i32 %62, %63
br i1 %64, label %65, label %89
65: ; preds = %61
%66 = load i8**, i8*** %5
%67 = load i32, i32* %6
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8*, i8** %66, i64 %68
%70 = load i8*, i8** %69
%71 = icmp ne i8* %70, null
br i1 %71, label %72, label %86
72: ; preds = %65
%73 = load i8**, i8*** %5
%74 = load i32, i32* %6
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i8*, i8** %73, i64 %75
%77 = load i8*, i8** %76
%78 = load i32, i32* %6
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8*, i8** %60, i64 %79
store i8* %77, i8** %80
%81 = load i32, i32* %6
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i8*, i8** %60, i64 %82
%84 = load i8*, i8** %83
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i8* %84)
br label %86
86: ; preds = %72, %65
%87 = load i32, i32* %6
%88 = add nsw i32 %87, 1
store i32 %88, i32* %6
br label %61
89: ; preds = %61
store i32 0, i32* %12
br label %90
90: ; preds = %100, %89
%91 = load i32, i32* %12
%92 = load i32, i32* %4
%93 = icmp slt i32 %91, %92
br i1 %93, label %94, label %103
94: ; preds = %90
%95 = load i32, i32* %12
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i8*, i8** %60, i64 %96
%98 = load i8*, i8** %97
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.11, i64 0, i64 0), i8* %98)
br label %100
100: ; preds = %94
%101 = load i32, i32* %12
%102 = add nsw i32 %101, 1
store i32 %102, i32* %12
br label %90
103: ; preds = %90
%104 = getelementptr inbounds i8*, i8** %60, i64 1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), i8** %104
%105 = load i8**, i8*** %5
%106 = getelementptr inbounds i8*, i8** %105, i64 1
%107 = load i8*, i8** %106
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.13, i64 0, i64 0), i8* %107)
store i32 0, i32* %3
%109 = load i8*, i8** %10
%110 = load i32, i32* %3
ret i32 %110
}

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.7 = [15 x i8] c"raspberry cake\00"
@.str.8 = [13 x i8] c"layered cake\00"
@.str.9 = [25 x i8] c"Cake on index %d is: %s\0A\00"
@.str.10 = [18 x i8] c"Copied value: %s\0A\00"
@.str.11 = [31 x i8] c"The value i copied earlier %s\0A\00"
@.str.13 = [76 x i8] c"Has the value changed? if it has, it should be equal \22Something new\22 : %s \0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 0
%4 = zext i32 %0 to i64
br i1 %3, label %14, label %5
5: ; preds = %14, %2
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) 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))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) 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))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) 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 (i8*, ...) @printf(i8* dereferenceable(1) 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))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), i32 3, i8* undef)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
%13 = alloca i8*, i64 %4
br i1 %3, label %23, label %34
14: ; preds = %2, %14
%15 = phi i64 [ %20, %14 ], [ 0, %2 ]
%16 = getelementptr inbounds i8*, i8** %1, i64 %15
%17 = load i8*, i8** %16
%18 = trunc i64 %15 to i32
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %18, i8* %17)
%20 = add nuw nsw i64 %15, 1
%21 = icmp eq i64 %20, %4
br i1 %21, label %5, label %14
22: ; preds = %31
br i1 %3, label %38, label %34
23: ; preds = %5, %31
%24 = phi i64 [ %32, %31 ], [ 0, %5 ]
%25 = getelementptr inbounds i8*, i8** %1, i64 %24
%26 = load i8*, i8** %25
%27 = icmp eq i8* %26, null
br i1 %27, label %31, label %28
28: ; preds = %23
%29 = getelementptr inbounds i8*, i8** %13, i64 %24
store i8* %26, i8** %29
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i8* %26)
br label %31
31: ; preds = %28, %23
%32 = add nuw nsw i64 %24, 1
%33 = icmp eq i64 %32, %4
br i1 %33, label %22, label %23
34: ; preds = %38, %5, %22
%35 = getelementptr inbounds i8*, i8** %1, i64 1
%36 = load i8*, i8** %35
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([76 x i8], [76 x i8]* @.str.13, i64 0, i64 0), i8* %36)
ret i32 0
38: ; preds = %22, %38
%39 = phi i64 [ %43, %38 ], [ 0, %22 ]
%40 = getelementptr inbounds i8*, i8** %13, i64 %39
%41 = load i8*, i8** %40
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.11, i64 0, i64 0), i8* %41)
%43 = add nuw nsw i64 %39, 1
%44 = icmp eq i64 %43, %4
br i1 %44, label %34, label %38
}