#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 */
struct bitarray {
  int dummy;
};

/* Variables and functions */
struct bitarray *cba_alloc(int);
int /*<<< orphan*/ cba_free(struct bitarray *);
scalar_t__ cba_get(struct bitarray *, int);
int /*<<< orphan*/ printf(char *, ...);
int test_out_of_bounds(void) {
  struct bitarray *ba = NULL;
  {
    ba = cba_alloc(10);
    do {
      if (!(cba_get(ba, 10) < 0)) {
        printf("FAILED: !(%s)\n", "cba_get(ba, 10) < 0");
        if (ba)
          cba_free(ba);
        return 0;
      }
    } while (0);
    do {
      if (!(cba_get(ba, 50) < 0)) {
        printf("FAILED: !(%s)\n", "cba_get(ba, 50) < 0");
        if (ba)
          cba_free(ba);
        return 0;
      }
    } while (0);
    do {
      if (!(cba_get(ba, -11) < 0)) {
        printf("FAILED: !(%s)\n", "cba_get(ba, -11) < 0");
        if (ba)
          cba_free(ba);
        return 0;
      }
    } while (0);
  }
  printf("PASSED\n");
  if (ba)
    cba_free(ba);
  return 1;
}


x86 assembly (clang, -O0):
<test_out_of_bounds>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x10(%rbp)
mov    $0xa,%edi
call   1030 <cba_alloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1040 <cba_get@plt>
cmp    $0x0,%rax
jl     11ab <test_out_of_bounds+0x6b>
lea    0xe83(%rip),%rdi
lea    0xe8b(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
je     119f <test_out_of_bounds+0x5f>
mov    -0x10(%rbp),%rdi
call   1060 <cba_free@plt>
movl   $0x0,-0x4(%rbp)
jmp    1287 <test_out_of_bounds+0x147>
jmp    11b0 <test_out_of_bounds+0x70>
jmp    11b5 <test_out_of_bounds+0x75>
mov    -0x10(%rbp),%rdi
mov    $0x32,%esi
call   1040 <cba_get@plt>
cmp    $0x0,%rax
jl     1202 <test_out_of_bounds+0xc2>
lea    0xe2c(%rip),%rdi
lea    0xe48(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
je     11f6 <test_out_of_bounds+0xb6>
mov    -0x10(%rbp),%rdi
call   1060 <cba_free@plt>
movl   $0x0,-0x4(%rbp)
jmp    1287 <test_out_of_bounds+0x147>
jmp    1207 <test_out_of_bounds+0xc7>
jmp    120c <test_out_of_bounds+0xcc>
mov    -0x10(%rbp),%rdi
mov    $0xfffffff5,%esi
call   1040 <cba_get@plt>
cmp    $0x0,%rax
jl     1259 <test_out_of_bounds+0x119>
lea    0xdd5(%rip),%rdi
lea    0xe05(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
je     124d <test_out_of_bounds+0x10d>
mov    -0x10(%rbp),%rdi
call   1060 <cba_free@plt>
movl   $0x0,-0x4(%rbp)
jmp    1287 <test_out_of_bounds+0x147>
jmp    125e <test_out_of_bounds+0x11e>
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
je     1280 <test_out_of_bounds+0x140>
mov    -0x10(%rbp),%rdi
call   1060 <cba_free@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_out_of_bounds>:
push   %rbp
push   %rbx
push   %rax
mov    $0xa,%edi
call   1040 <cba_alloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0xa,%esi
call   1050 <cba_get@plt>
test   %rax,%rax
js     1182 <test_out_of_bounds+0x32>
lea    0xe87(%rip),%rdi
lea    0xe8f(%rip),%rsi
jmp    11c4 <test_out_of_bounds+0x74>
mov    %rbx,%rdi
mov    $0x32,%esi
call   1050 <cba_get@plt>
test   %rax,%rax
js     11a4 <test_out_of_bounds+0x54>
lea    0xe65(%rip),%rdi
lea    0xe81(%rip),%rsi
jmp    11c4 <test_out_of_bounds+0x74>
mov    %rbx,%rdi
mov    $0xfffffff5,%esi
call   1050 <cba_get@plt>
test   %rax,%rax
js     11e3 <test_out_of_bounds+0x93>
lea    0xe43(%rip),%rdi
lea    0xe73(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <printf@plt>
test   %rbx,%rbx
je     11da <test_out_of_bounds+0x8a>
mov    %rbx,%rdi
call   1070 <cba_free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe62(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
test   %rbx,%rbx
jne    11d2 <test_out_of_bounds+0x82>
jmp    11da <test_out_of_bounds+0x8a>

LLVM IR (-O0):
%struct.bitarray = type { i32 }
@.str = [15 x i8] c"FAILED: !(%s)\0A\00"
@.str.1 = [20 x i8] c"cba_get(ba, 10) < 0\00"
@.str.2 = [20 x i8] c"cba_get(ba, 50) < 0\00"
@.str.3 = [21 x i8] c"cba_get(ba, -11) < 0\00"
@.str.4 = [8 x i8] c"PASSED\0A\00"
define i32 @test_out_of_bounds() {
%1 = alloca i32
%2 = alloca %struct.bitarray*
store %struct.bitarray* null, %struct.bitarray** %2
%3 = call %struct.bitarray* @cba_alloc(i32 10)
store %struct.bitarray* %3, %struct.bitarray** %2
br label %4
4: ; preds = %0
%5 = load %struct.bitarray*, %struct.bitarray** %2
%6 = call i64 @cba_get(%struct.bitarray* %5, i32 10)
%7 = icmp slt i64 %6, 0
br i1 %7, label %16, label %8
8: ; preds = %4
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%10 = load %struct.bitarray*, %struct.bitarray** %2
%11 = icmp ne %struct.bitarray* %10, null
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load %struct.bitarray*, %struct.bitarray** %2
%14 = call i32 @cba_free(%struct.bitarray* %13)
br label %15
15: ; preds = %12, %8
store i32 0, i32* %1
br label %53
16: ; preds = %4
br label %17
17: ; preds = %16
br label %18
18: ; preds = %17
%19 = load %struct.bitarray*, %struct.bitarray** %2
%20 = call i64 @cba_get(%struct.bitarray* %19, i32 50)
%21 = icmp slt i64 %20, 0
br i1 %21, label %30, label %22
22: ; preds = %18
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%24 = load %struct.bitarray*, %struct.bitarray** %2
%25 = icmp ne %struct.bitarray* %24, null
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load %struct.bitarray*, %struct.bitarray** %2
%28 = call i32 @cba_free(%struct.bitarray* %27)
br label %29
29: ; preds = %26, %22
store i32 0, i32* %1
br label %53
30: ; preds = %18
br label %31
31: ; preds = %30
br label %32
32: ; preds = %31
%33 = load %struct.bitarray*, %struct.bitarray** %2
%34 = call i64 @cba_get(%struct.bitarray* %33, i32 -11)
%35 = icmp slt i64 %34, 0
br i1 %35, label %44, label %36
36: ; preds = %32
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%38 = load %struct.bitarray*, %struct.bitarray** %2
%39 = icmp ne %struct.bitarray* %38, null
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = load %struct.bitarray*, %struct.bitarray** %2
%42 = call i32 @cba_free(%struct.bitarray* %41)
br label %43
43: ; preds = %40, %36
store i32 0, i32* %1
br label %53
44: ; preds = %32
br label %45
45: ; preds = %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%47 = load %struct.bitarray*, %struct.bitarray** %2
%48 = icmp ne %struct.bitarray* %47, null
br i1 %48, label %49, label %52
49: ; preds = %45
%50 = load %struct.bitarray*, %struct.bitarray** %2
%51 = call i32 @cba_free(%struct.bitarray* %50)
br label %52
52: ; preds = %49, %45
store i32 1, i32* %1
br label %53
53: ; preds = %52, %43, %29, %15
%54 = load i32, i32* %1
ret i32 %54
}

LLVM IR (-O2):
%struct.bitarray = type { i32 }
@.str = [15 x i8] c"FAILED: !(%s)\0A\00"
@.str.1 = [20 x i8] c"cba_get(ba, 10) < 0\00"
@.str.2 = [20 x i8] c"cba_get(ba, 50) < 0\00"
@.str.3 = [21 x i8] c"cba_get(ba, -11) < 0\00"
@str = [7 x i8] c"PASSED\00"
define i32 @test_out_of_bounds() {
%1 = tail call %struct.bitarray* @cba_alloc(i32 10)
%2 = tail call i64 @cba_get(%struct.bitarray* %1, i32 10)
%3 = icmp slt i64 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq %struct.bitarray* %1, null
br i1 %6, label %25, label %22
7: ; preds = %0
%8 = tail call i64 @cba_get(%struct.bitarray* %1, i32 50)
%9 = icmp slt i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq %struct.bitarray* %1, null
br i1 %12, label %25, label %22
13: ; preds = %7
%14 = tail call i64 @cba_get(%struct.bitarray* %1, i32 -11)
%15 = icmp slt i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq %struct.bitarray* %1, null
br i1 %18, label %25, label %22
19: ; preds = %13
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%21 = icmp eq %struct.bitarray* %1, null
br i1 %21, label %25, label %22
22: ; preds = %19, %16, %10, %4
%23 = phi i32 [ 0, %4 ], [ 0, %10 ], [ 0, %16 ], [ 1, %19 ]
%24 = tail call i32 @cba_free(%struct.bitarray* %1)
br label %25
25: ; preds = %22, %19, %16, %10, %4
%26 = phi i32 [ 0, %4 ], [ 0, %10 ], [ 0, %16 ], [ 1, %19 ], [ %23, %22 ]
ret i32 %26
}