#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 contestants[] = {1, 2, 3};
  int *choice = contestants;
  contestants[0] = 2;
  contestants[1] = contestants[2];
  contestants[2] = *choice;
  printf("I'm going to pick contestant number %i\n", contestants[2]);
  printf("I'm going to pick contestant number %i\n", contestants[1]);
  printf("I'm going to pick contestant number %p\n", &choice);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xed8(%rip),%eax
mov    %eax,-0x8(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x2,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeba(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xc(%rsp),%rax
mov    %rax,0x18(%rsp)
movabs $0x300000002,%rax
mov    %rax,0xc(%rsp)
movl   $0x2,0x14(%rsp)
lea    0xec3(%rip),%rbx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec7(%rip),%rdi
lea    0x18(%rsp),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.contestants = [3 x i32] [i32 1, i32 2, i32 3]
@.str = [40 x i8] c"I'm going to pick contestant number %i\0A\00"
@.str.1 = [40 x i8] c"I'm going to pick contestant number %p\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i32]
%3 = alloca i32*
store i32 0, i32* %1
%4 = bitcast [3 x i32]* %2 to i8*
%5 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
store i32* %5, i32** %3
%6 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
store i32 2, i32* %6
%7 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 2
%8 = load i32, i32* %7
%9 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 1
store i32 %8, i32* %9
%10 = load i32*, i32** %3
%11 = load i32, i32* %10
%12 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 2
store i32 %11, i32* %12
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 2
%14 = load i32, i32* %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 1
%17 = load i32, i32* %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32** %3)
ret i32 0
}

LLVM IR (-O2):
@.str = [40 x i8] c"I'm going to pick contestant number %i\0A\00"
@.str.1 = [40 x i8] c"I'm going to pick contestant number %p\0A\00"
define i32 @main() {
%1 = alloca [3 x i32]
%2 = alloca i32*
%3 = bitcast [3 x i32]* %1 to i8*
%4 = bitcast i32** %2 to i8*
%5 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
store i32* %5, i32** %2
store i32 2, i32* %5
%6 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 2
%7 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 1
store i32 3, i32* %7
store i32 2, i32* %6
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 2)
%9 = load i32, i32* %7
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32** %2)
ret i32 0
}