#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);
int trap(int *, int);
int main(void) {
  int arr[] = {0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1};
  int arr2[] = {2, 0, 2};
  int arr3[] = {4, 2, 3};
  int arr4[] = {0, 2, 0};
  printf("%d\n", trap(arr, 12));
  printf("%d\n", trap(arr2, 3));
  printf("%d\n", trap(arr3, 3));
  printf("%d\n", trap(arr4, 3));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x30,%edx
call   1040 <memcpy@plt>
mov    0xed5(%rip),%rax
mov    %rax,-0x4c(%rbp)
mov    0xed3(%rip),%eax
mov    %eax,-0x44(%rbp)
mov    0xecd(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xecb(%rip),%eax
mov    %eax,-0x50(%rbp)
mov    0xec5(%rip),%rax
mov    %rax,-0x64(%rbp)
mov    0xec3(%rip),%eax
mov    %eax,-0x5c(%rbp)
lea    -0x40(%rbp),%rdi
mov    $0xc,%esi
call   1050 <trap@plt>
mov    %eax,%esi
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
lea    -0x4c(%rbp),%rdi
mov    $0x3,%esi
call   1050 <trap@plt>
mov    %eax,%esi
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
lea    -0x58(%rbp),%rdi
mov    $0x3,%esi
call   1050 <trap@plt>
mov    %eax,%esi
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
lea    -0x64(%rbp),%rdi
mov    $0x3,%esi
call   1050 <trap@plt>
mov    %eax,%esi
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x60,%rsp
movaps 0xef4(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xed8(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xebc(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
mov    0xee9(%rip),%eax
mov    %eax,0x28(%rsp)
mov    0xed6(%rip),%rax
mov    %rax,0x20(%rsp)
mov    0xedf(%rip),%eax
mov    %eax,0x18(%rsp)
mov    0xecc(%rip),%rax
mov    %rax,0x10(%rsp)
mov    0xed5(%rip),%eax
mov    %eax,0x8(%rsp)
mov    0xec2(%rip),%rax
mov    %rax,(%rsp)
lea    0x30(%rsp),%rdi
mov    $0xc,%esi
call   1040 <trap@plt>
lea    0xeb4(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0x20(%rsp),%rdi
mov    $0x3,%esi
call   1040 <trap@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0x10(%rsp),%rdi
mov    $0x3,%esi
call   1040 <trap@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rsp,%rdi
mov    $0x3,%esi
call   1040 <trap@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.arr = [12 x i32] [i32 0, i32 1, i32 0, i32 2, i32 1, i32 0, i32 1, i32 3, i32 2, i32 1, i32 2, i32 1]
@__const.main.arr2 = [3 x i32] [i32 2, i32 0, i32 2]
@__const.main.arr3 = [3 x i32] [i32 4, i32 2, i32 3]
@__const.main.arr4 = [3 x i32] [i32 0, i32 2, i32 0]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [12 x i32]
%3 = alloca [3 x i32]
%4 = alloca [3 x i32]
%5 = alloca [3 x i32]
store i32 0, i32* %1
%6 = bitcast [12 x i32]* %2 to i8*
%7 = bitcast [3 x i32]* %3 to i8*
%8 = bitcast [3 x i32]* %4 to i8*
%9 = bitcast [3 x i32]* %5 to i8*
%10 = getelementptr inbounds [12 x i32], [12 x i32]* %2, i64 0, i64 0
%11 = call i32 @trap(i32* %10, i32 12)
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
%14 = call i32 @trap(i32* %13, i32 3)
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
%17 = call i32 @trap(i32* %16, i32 3)
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%20 = call i32 @trap(i32* %19, i32 3)
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %20)
ret i32 0
}

LLVM IR (-O2):
@__const.main.arr = [12 x i32] [i32 0, i32 1, i32 0, i32 2, i32 1, i32 0, i32 1, i32 3, i32 2, i32 1, i32 2, i32 1]
@__const.main.arr2 = [3 x i32] [i32 2, i32 0, i32 2]
@__const.main.arr3 = [3 x i32] [i32 4, i32 2, i32 3]
@__const.main.arr4 = [3 x i32] [i32 0, i32 2, i32 0]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [12 x i32]
%2 = alloca [3 x i32]
%3 = alloca [3 x i32]
%4 = alloca [3 x i32]
%5 = bitcast [12 x i32]* %1 to i8*
%6 = bitcast [3 x i32]* %2 to i8*
%7 = bitcast [3 x i32]* %3 to i8*
%8 = bitcast [3 x i32]* %4 to i8*
%9 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 0
%10 = call i32 @trap(i32* %9, i32 12)
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%13 = call i32 @trap(i32* %12, i32 3)
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
%16 = call i32 @trap(i32* %15, i32 3)
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
%19 = call i32 @trap(i32* %18, i32 3)
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
ret i32 0
}