#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*/ print_int(int);
int /*<<< orphan*/ print_string(char *);
size_t return1();
void main(void) {
  int myInt;
  int intArr[3];
  intArr[0] = 999;
  intArr[1] = 100;
  intArr[2] = 200;
  myInt = 1;
  print_string("should get 100\ngot: ");
  print_int(intArr[myInt]);
  print_string("\n\n");
  print_string("should get 100\ngot: ");
  print_int(intArr[return1()]);
  print_string("\n\n");
  print_string("should get 100\ngot: ");
  print_int(intArr[return1() + 4 / 8]);
  print_string("\n\n");
  intArr[return1()] = 77;
  print_string("should get 77\ngot: ");
  print_int(intArr[1]);
  print_string("\n\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x3e7,-0x10(%rbp)
movl   $0x64,-0xc(%rbp)
movl   $0xc8,-0x8(%rbp)
movl   $0x1,-0x4(%rbp)
lea    0xea5(%rip),%rdi
call   1030 <print_string@plt>
movslq -0x4(%rbp),%rax
mov    -0x10(%rbp,%rax,4),%edi
call   1040 <print_int@plt>
lea    0xea1(%rip),%rdi
call   1030 <print_string@plt>
lea    0xe80(%rip),%rdi
call   1030 <print_string@plt>
mov    $0x0,%al
call   1050 <return1@plt>
mov    -0x10(%rbp,%rax,4),%edi
call   1040 <print_int@plt>
lea    0xe79(%rip),%rdi
call   1030 <print_string@plt>
lea    0xe58(%rip),%rdi
call   1030 <print_string@plt>
mov    $0x0,%al
call   1050 <return1@plt>
mov    -0x10(%rbp,%rax,4),%edi
call   1040 <print_int@plt>
lea    0xe51(%rip),%rdi
call   1030 <print_string@plt>
mov    $0x0,%al
call   1050 <return1@plt>
movl   $0x4d,-0x10(%rbp,%rax,4)
lea    0xe39(%rip),%rdi
call   1030 <print_string@plt>
mov    -0xc(%rbp),%edi
call   1040 <print_int@plt>
lea    0xe22(%rip),%rdi
call   1030 <print_string@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movabs $0x64000003e7,%rax
mov    %rax,0xc(%rsp)
movl   $0xc8,0x14(%rsp)
lea    0xeab(%rip),%rbx
mov    %rbx,%rdi
call   1030 <print_string@plt>
mov    $0x64,%edi
call   1040 <print_int@plt>
lea    0xea7(%rip),%r14
mov    %r14,%rdi
call   1030 <print_string@plt>
mov    %rbx,%rdi
call   1030 <print_string@plt>
xor    %eax,%eax
call   1050 <return1@plt>
mov    0xc(%rsp,%rax,4),%edi
call   1040 <print_int@plt>
mov    %r14,%rdi
call   1030 <print_string@plt>
mov    %rbx,%rdi
call   1030 <print_string@plt>
xor    %eax,%eax
call   1050 <return1@plt>
mov    0xc(%rsp,%rax,4),%edi
call   1040 <print_int@plt>
mov    %r14,%rdi
call   1030 <print_string@plt>
xor    %eax,%eax
call   1050 <return1@plt>
movl   $0x4d,0xc(%rsp,%rax,4)
lea    0xe4c(%rip),%rdi
call   1030 <print_string@plt>
mov    0x10(%rsp),%edi
call   1040 <print_int@plt>
mov    %r14,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r14
jmp    1030 <print_string@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"should get 100\0Agot: \00"
@.str.1 = [3 x i8] c"\0A\0A\00"
@.str.2 = [20 x i8] c"should get 77\0Agot: \00"
define void @main() {
%1 = alloca i32
%2 = alloca [3 x i32]
%3 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
store i32 999, i32* %3
%4 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 1
store i32 100, i32* %4
%5 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 2
store i32 200, i32* %5
store i32 1, i32* %1
%6 = call i32 @print_string(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* %1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 %8
%10 = load i32, i32* %9
%11 = call i32 @print_int(i32 %10)
%12 = call i32 @print_string(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @print_string(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%14 = call i64 (...) @return1()
%15 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = call i32 @print_int(i32 %16)
%18 = call i32 @print_string(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @print_string(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%20 = call i64 (...) @return1()
%21 = add i64 %20, 0
%22 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = call i32 @print_int(i32 %23)
%25 = call i32 @print_string(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%26 = call i64 (...) @return1()
%27 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 %26
store i32 77, i32* %27
%28 = call i32 @print_string(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%29 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 1
%30 = load i32, i32* %29
%31 = call i32 @print_int(i32 %30)
%32 = call i32 @print_string(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"should get 100\0Agot: \00"
@.str.1 = [3 x i8] c"\0A\0A\00"
@.str.2 = [20 x i8] c"should get 77\0Agot: \00"
define void @main() {
%1 = alloca [3 x i32]
%2 = bitcast [3 x i32]* %1 to i8*
%3 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
store i32 999, i32* %3
%4 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 1
store i32 100, i32* %4
%5 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 2
store i32 200, i32* %5
%6 = tail call i32 @print_string(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @print_int(i32 100)
%8 = tail call i32 @print_string(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @print_string(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%10 = tail call i64 (...) @return1()
%11 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 %10
%12 = load i32, i32* %11
%13 = tail call i32 @print_int(i32 %12)
%14 = tail call i32 @print_string(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 @print_string(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%16 = tail call i64 (...) @return1()
%17 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = tail call i32 @print_int(i32 %18)
%20 = tail call i32 @print_string(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%21 = tail call i64 (...) @return1()
%22 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 %21
store i32 77, i32* %22
%23 = tail call i32 @print_string(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%24 = load i32, i32* %4
%25 = tail call i32 @print_int(i32 %24)
%26 = tail call i32 @print_string(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
ret void
}