#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*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int trap(int *, int);
int main(int argc, char *argv[]) {
  int h1[] = {2, 0, 2};
  int h2[] = {0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1};
  if (!(trap(h1, 3) == 2)) {
    printf("assert fail: %s\n", "h1 == 2");
    exit(-1);
  };
  if (!(trap(h2, 12) == 6)) {
    printf("assert fail: %s\n", "h2 == 6");
    exit(-1);
  };
  printf("everything is fine!\n");
  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)
mov    0xea3(%rip),%rax
mov    %rax,-0x1c(%rbp)
mov    0xea1(%rip),%eax
mov    %eax,-0x14(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe9b(%rip),%rsi
mov    $0x30,%edx
call   1040 <memcpy@plt>
lea    -0x1c(%rbp),%rdi
mov    $0x3,%esi
call   1050 <trap@plt>
cmp    $0x2,%eax
je     11b5 <main+0x75>
lea    0xea3(%rip),%rdi
lea    0xead(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
lea    -0x50(%rbp),%rdi
mov    $0xc,%esi
call   1050 <trap@plt>
cmp    $0x6,%eax
je     11eb <main+0xab>
lea    0xe6d(%rip),%rdi
lea    0xe7f(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x48,%rsp
mov    0xebe(%rip),%eax
mov    %eax,0x8(%rsp)
mov    0xeab(%rip),%rax
mov    %rax,(%rsp)
movaps 0xed0(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeb4(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe98(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    %rsp,%rdi
mov    $0x3,%esi
call   1050 <trap@plt>
cmp    $0x2,%eax
jne    11b6 <main+0x76>
lea    0x10(%rsp),%rdi
mov    $0xc,%esi
call   1050 <trap@plt>
cmp    $0x6,%eax
jne    11c6 <main+0x86>
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x48,%rsp
ret
lea    0xe83(%rip),%rdi
lea    0xe8d(%rip),%rsi
jmp    11d4 <main+0x94>
lea    0xe73(%rip),%rdi
lea    0xe85(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@__const.main.h1 = [3 x i32] [i32 2, i32 0, i32 2]
@__const.main.h2 = [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]
@.str = [17 x i8] c"assert fail: %s\0A\00"
@.str.1 = [8 x i8] c"h1 == 2\00"
@.str.2 = [8 x i8] c"h2 == 6\00"
@.str.3 = [21 x i8] c"everything is fine!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [3 x i32]
%7 = alloca [12 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [3 x i32]* %6 to i8*
%9 = bitcast [12 x i32]* %7 to i8*
%10 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%11 = call i32 @trap(i32* %10, i32 3)
%12 = icmp eq i32 %11, 2
br i1 %12, label %16, label %13
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @exit(i32 -1)
unreachable
16: ; preds = %2
%17 = getelementptr inbounds [12 x i32], [12 x i32]* %7, i64 0, i64 0
%18 = call i32 @trap(i32* %17, i32 12)
%19 = icmp eq i32 %18, 6
br i1 %19, label %23, label %20
20: ; preds = %16
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 @exit(i32 -1)
unreachable
23: ; preds = %16
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.h1 = [3 x i32] [i32 2, i32 0, i32 2]
@__const.main.h2 = [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]
@.str = [17 x i8] c"assert fail: %s\0A\00"
@.str.1 = [8 x i8] c"h1 == 2\00"
@.str.2 = [8 x i8] c"h2 == 6\00"
@str = [20 x i8] c"everything is fine!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [3 x i32]
%4 = alloca [12 x i32]
%5 = bitcast [3 x i32]* %3 to i8*
%6 = bitcast [12 x i32]* %4 to i8*
%7 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
%8 = call i32 @trap(i32* %7, i32 3)
%9 = icmp eq i32 %8, 2
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @exit(i32 -1)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds [12 x i32], [12 x i32]* %4, i64 0, i64 0
%15 = call i32 @trap(i32* %14, i32 12)
%16 = icmp eq i32 %15, 6
br i1 %16, label %20, label %17
17: ; preds = %13
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 @exit(i32 -1)
unreachable
20: ; preds = %13
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
ret i32 0
}