#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 /*<<< orphan*/);
int /*<<< orphan*/ cba_free(struct bitarray *);
scalar_t__ cba_size(struct bitarray *);
int /*<<< orphan*/ printf(char *, ...);
int test_allocate_zero(void) {
  struct bitarray *ba = NULL;
  {
    ba = cba_alloc(0);
    do {
      if (!(ba && cba_size(ba) == 0)) {
        printf("FAILED: !(%s)\n", "ba && cba_size(ba) == 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_allocate_zero>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x10(%rbp)
xor    %edi,%edi
call   1030 <cba_alloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1179 <test_allocate_zero+0x39>
mov    -0x10(%rbp),%rdi
call   1050 <cba_size@plt>
cmp    $0x0,%rax
je     11ae <test_allocate_zero+0x6e>
lea    0xe80(%rip),%rdi
lea    0xe88(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
je     11a2 <test_allocate_zero+0x62>
mov    -0x10(%rbp),%rdi
call   1060 <cba_free@plt>
movl   $0x0,-0x4(%rbp)
jmp    11dc <test_allocate_zero+0x9c>
jmp    11b3 <test_allocate_zero+0x73>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
je     11d5 <test_allocate_zero+0x95>
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_allocate_zero>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
xor    %edi,%edi
call   1040 <cba_alloc@plt>
test   %rax,%rax
je     1192 <test_allocate_zero+0x42>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <cba_size@plt>
test   %rax,%rax
je     11a9 <test_allocate_zero+0x59>
lea    0xe88(%rip),%rdi
lea    0xe90(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1070 <cba_free@plt>
jmp    11c2 <test_allocate_zero+0x72>
lea    0xe67(%rip),%rdi
lea    0xe6f(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11c2 <test_allocate_zero+0x72>
lea    0xe77(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1070 <cba_free@plt>
mov    $0x1,%ebp
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 = [24 x i8] c"ba && cba_size(ba) == 0\00"
@.str.2 = [8 x i8] c"PASSED\0A\00"
define i32 @test_allocate_zero() {
%1 = alloca i32
%2 = alloca %struct.bitarray*
store %struct.bitarray* null, %struct.bitarray** %2
%3 = call %struct.bitarray* @cba_alloc(i32 0)
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 i64 @cba_size(%struct.bitarray* %8)
%10 = icmp eq i64 %9, 0
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 ([24 x i8], [24 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 = [24 x i8] c"ba && cba_size(ba) == 0\00"
@str = [7 x i8] c"PASSED\00"
define i32 @test_allocate_zero() {
%1 = tail call %struct.bitarray* @cba_alloc(i32 0)
%2 = icmp eq %struct.bitarray* %1, null
br i1 %2, label %9, label %3
3: ; preds = %0
%4 = tail call i64 @cba_size(%struct.bitarray* %1)
%5 = icmp eq i64 %4, 0
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 ([24 x i8], [24 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 ([24 x i8], [24 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
}