#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 jump(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int n[] = {2, 3, 1, 1, 4};
  int b[] = {2, 3, 0, 1, 4};
  if (!(jump(n, 1) == 0)) {
    printf("assert fail: %s\n", "boundary 0");
  };
  if (!(jump(n, 5) == 2)) {
    printf("assert fail: %s\n", "2 step");
  };
  if (!(jump(b, 5) == 2)) {
    printf("assert fail: %s\n", "b");
  };
  for (int i = 0; i < 5; ++i) {
    printf("b[%d] = %d\n", i, b[i]);
  }
  printf("everything is fine!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec0(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xebe(%rip),%eax
mov    %eax,-0x20(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xec1(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xebf(%rip),%eax
mov    %eax,-0x40(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x1,%esi
call   1040 <jump@plt>
cmp    $0x0,%eax
je     11a0 <main+0x80>
lea    0xea2(%rip),%rdi
lea    0xeac(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    $0x5,%esi
call   1040 <jump@plt>
cmp    $0x2,%eax
je     11cc <main+0xac>
lea    0xe76(%rip),%rdi
lea    0xe8b(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    $0x5,%esi
call   1040 <jump@plt>
cmp    $0x2,%eax
je     11f8 <main+0xd8>
lea    0xe4a(%rip),%rdi
lea    0xe66(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x54(%rbp)
cmpl   $0x5,-0x54(%rbp)
jge    1230 <main+0x110>
mov    -0x54(%rbp),%esi
movslq -0x54(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%edx
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11ff <main+0xdf>
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
mov    0xed5(%rip),%eax
mov    %eax,0x30(%rsp)
movaps 0xeba(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    0xedf(%rip),%eax
mov    %eax,0x10(%rsp)
movaps 0xec4(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x20(%rsp),%rdi
mov    $0x1,%esi
call   1050 <jump@plt>
test   %eax,%eax
je     1188 <main+0x58>
lea    0xeba(%rip),%rdi
lea    0xec4(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x20(%rsp),%rdi
mov    $0x5,%esi
call   1050 <jump@plt>
cmp    $0x2,%eax
je     11b1 <main+0x81>
lea    0xe91(%rip),%rdi
lea    0xea6(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rdi
mov    $0x5,%esi
call   1050 <jump@plt>
cmp    $0x2,%eax
je     11d8 <main+0xa8>
lea    0xe6a(%rip),%rdi
lea    0xe86(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%edx
lea    0xe77(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%edx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%edx
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe24(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.n = [5 x i32] [i32 2, i32 3, i32 1, i32 1, i32 4]
@__const.main.b = [5 x i32] [i32 2, i32 3, i32 0, i32 1, i32 4]
@.str = [17 x i8] c"assert fail: %s\0A\00"
@.str.1 = [11 x i8] c"boundary 0\00"
@.str.2 = [7 x i8] c"2 step\00"
@.str.3 = [2 x i8] c"b\00"
@.str.4 = [12 x i8] c"b[%d] = %d\0A\00"
@.str.5 = [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 [5 x i32]
%7 = alloca [5 x i32]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [5 x i32]* %6 to i8*
%10 = bitcast [5 x i32]* %7 to i8*
%11 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 0
%12 = call i32 @jump(i32* %11, i32 1)
%13 = icmp eq i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %2
%17 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 0
%18 = call i32 @jump(i32* %17, i32 5)
%19 = icmp eq i32 %18, 2
br i1 %19, label %22, 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 ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %20, %16
%23 = getelementptr inbounds [5 x i32], [5 x i32]* %7, i64 0, i64 0
%24 = call i32 @jump(i32* %23, i32 5)
%25 = icmp eq i32 %24, 2
br i1 %25, label %28, label %26
26: ; preds = %22
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %28
28: ; preds = %26, %22
store i32 0, i32* %8
br label %29
29: ; preds = %39, %28
%30 = load i32, i32* %8
%31 = icmp slt i32 %30, 5
br i1 %31, label %32, label %42
32: ; preds = %29
%33 = load i32, i32* %8
%34 = load i32, i32* %8
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [5 x i32], [5 x i32]* %7, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %33, i32 %37)
br label %39
39: ; preds = %32
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
br label %29
42: ; preds = %29
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.n = [5 x i32] [i32 2, i32 3, i32 1, i32 1, i32 4]
@__const.main.b = [5 x i32] [i32 2, i32 3, i32 0, i32 1, i32 4]
@.str = [17 x i8] c"assert fail: %s\0A\00"
@.str.1 = [11 x i8] c"boundary 0\00"
@.str.2 = [7 x i8] c"2 step\00"
@.str.3 = [2 x i8] c"b\00"
@.str.4 = [12 x i8] c"b[%d] = %d\0A\00"
@str = [20 x i8] c"everything is fine!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [5 x i32]
%4 = alloca [5 x i32]
%5 = bitcast [5 x i32]* %3 to i8*
%6 = bitcast [5 x i32]* %4 to i8*
%7 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%8 = call i32 @jump(i32* %7, i32 1)
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, 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 ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %2
%13 = call i32 @jump(i32* %7, i32 5)
%14 = icmp eq i32 %13, 2
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %17
17: ; preds = %15, %12
%18 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
%19 = call i32 @jump(i32* %18, i32 5)
%20 = icmp eq i32 %19, 2
br i1 %20, label %23, label %21
21: ; preds = %17
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %23
23: ; preds = %21, %17
%24 = load i32, i32* %18
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 0, i32 %24)
%26 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 1
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 %27)
%29 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 2
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 2, i32 %30)
%32 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 3
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 3, i32 %33)
%35 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 4
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 4, i32 %36)
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
ret i32 0
}