#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 *);
int cba_size(struct bitarray *);
int /*<<< orphan*/ printf(char *, ...);
int test_cba_alloc(void) {
  struct bitarray *ba = NULL;
  {
    ba = cba_alloc(100);
    do {
      if (!(ba && cba_size(ba) == 100)) {
        printf("FAILED: !(%s)\n", "ba && cba_size(ba) == 100");
        if (ba)
          cba_free(ba);
        return 0;
      }
    } while (0);
  }
  printf("PASSED\n");
  if (ba)
    cba_free(ba);
  return 1;
}


x86 assembly (clang, -O0):
<test_cba_alloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x10(%rbp)
mov    $0x64,%edi
call   1030 <cba_alloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     117b <test_cba_alloc+0x3b>
mov    -0x10(%rbp),%rdi
call   1050 <cba_size@plt>
cmp    $0x64,%eax
je     11b0 <test_cba_alloc+0x70>
lea    0xe7e(%rip),%rdi
lea    0xe86(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
je     11a4 <test_cba_alloc+0x64>
mov    -0x10(%rbp),%rdi
call   1060 <cba_free@plt>
movl   $0x0,-0x4(%rbp)
jmp    11de <test_cba_alloc+0x9e>
jmp    11b5 <test_cba_alloc+0x75>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
je     11d7 <test_cba_alloc+0x97>
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_cba_alloc>:
push   %rbp
push   %rbx
push   %rax
mov    $0x64,%edi
call   1040 <cba_alloc@plt>
test   %rax,%rax
je     118d <test_cba_alloc+0x3d>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <cba_size@plt>
cmp    $0x64,%eax
jne    11a6 <test_cba_alloc+0x56>
lea    0xeb0(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1070 <cba_free@plt>
mov    $0x1,%ebp
jmp    11c5 <test_cba_alloc+0x75>
lea    0xe6c(%rip),%rdi
lea    0xe74(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11c5 <test_cba_alloc+0x75>
lea    0xe53(%rip),%rdi
lea    0xe5b(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1070 <cba_free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.bitarray = type { i32 }
@.str = [15 x i8] c"FAILED: !(%s)\0A\00"
@.str.1 = [26 x i8] c"ba && cba_size(ba) == 100\00"
@.str.2 = [8 x i8] c"PASSED\0A\00"
define i32 @test_cba_alloc() {
%1 = alloca i32
%2 = alloca %struct.bitarray*
store %struct.bitarray* null, %struct.bitarray** %2
%3 = call %struct.bitarray* @cba_alloc(i32 100)
store %struct.bitarray* %3, %struct.bitarray** %2
br label %4
4: ; preds = %0
%5 = load %struct.bitarray*, %struct.bitarray** %2
%6 = icmp ne %struct.bitarray* %5, null
br i1 %6, label %7, label %11
7: ; preds = %4
%8 = load %struct.bitarray*, %struct.bitarray** %2
%9 = call i32 @cba_size(%struct.bitarray* %8)
%10 = icmp eq i32 %9, 100
br i1 %10, label %19, label %11
11: ; preds = %7, %4
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%13 = load %struct.bitarray*, %struct.bitarray** %2
%14 = icmp ne %struct.bitarray* %13, null
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load %struct.bitarray*, %struct.bitarray** %2
%17 = call i32 @cba_free(%struct.bitarray* %16)
br label %18
18: ; preds = %15, %11
store i32 0, i32* %1
br label %28
19: ; preds = %7
br label %20
20: ; preds = %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%22 = load %struct.bitarray*, %struct.bitarray** %2
%23 = icmp ne %struct.bitarray* %22, null
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load %struct.bitarray*, %struct.bitarray** %2
%26 = call i32 @cba_free(%struct.bitarray* %25)
br label %27
27: ; preds = %24, %20
store i32 1, i32* %1
br label %28
28: ; preds = %27, %18
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
%struct.bitarray = type { i32 }
@.str = [15 x i8] c"FAILED: !(%s)\0A\00"
@.str.1 = [26 x i8] c"ba && cba_size(ba) == 100\00"
@str = [7 x i8] c"PASSED\00"
define i32 @test_cba_alloc() {
%1 = tail call %struct.bitarray* @cba_alloc(i32 100)
%2 = icmp eq %struct.bitarray* %1, null
br i1 %2, label %9, label %3
3: ; preds = %0
%4 = tail call i32 @cba_size(%struct.bitarray* %1)
%5 = icmp eq i32 %4, 100
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @cba_free(%struct.bitarray* %1)
br label %14
9: ; preds = %0
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %14
11: ; preds = %3
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%13 = tail call i32 @cba_free(%struct.bitarray* %1)
br label %14
14: ; preds = %6, %9, %11
%15 = phi i32 [ 1, %11 ], [ 0, %9 ], [ 0, %6 ]
ret i32 %15
}