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

/* Variables and functions */
int mbm_clear_bit(struct m_bitmap *, int);
struct m_bitmap *mbm_create_bitmap(int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ mbm_flush_to_disk(struct m_bitmap *);
int /*<<< orphan*/ mbm_free_bitmap(struct m_bitmap *);
scalar_t__ mbm_is_bit_set(struct m_bitmap *, int);
struct m_bitmap *mbm_load_bitmap(char *, int /*<<< orphan*/);
int mbm_set_first_clear(struct m_bitmap *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ unlink(char *);
int main() {
  struct m_bitmap *bitmap;
  uint64_t free_blk;
  uint64_t i;
  bitmap = mbm_create_bitmap((64 * 1024 * 1024), "./metadata.dat", 0);
  if (bitmap == NULL) {
    printf("Create test failed...\n");
    return -1;
  }
  printf("Create test passed...\n");
  for (i = 0; i < 1024; i++) {
    free_blk = mbm_set_first_clear(bitmap);
    if (free_blk != i) {
      printf("freeblk %lu expected, recieved %lu\n", i, free_blk);
      return -1;
    }
  }
  printf("set_bit test-1 passed...\n");
  free_blk = mbm_set_first_clear(bitmap);
  if (free_blk != 1024) {
    printf("freeblk 1024 expected, recieved %lu\n", free_blk);
    return -1;
  }
  printf("set_bit test-2 passed...\n");
  int ret = mbm_clear_bit(bitmap, 100);
  if (ret != 0) {
    printf("clear_blk failed\n");
    return -1;
  }
  ret = mbm_clear_bit(bitmap, 512);
  if (ret != 0) {
    printf("clear_blk failed\n");
    return -1;
  }
  ret = mbm_clear_bit(bitmap, 1);
  if (ret != 0) {
    printf("clear_blk failed\n");
    return -1;
  }
  printf("clear_bit test-1 passed...\n");
  free_blk = mbm_set_first_clear(bitmap);
  if (free_blk != 1) {
    printf("freeblk 1 expected, recieved %lu\n", free_blk);
    return -1;
  }
  printf("set_bit test-3 passed...\n");
  ret = mbm_clear_bit(bitmap, 1002);
  if (ret != 0) {
    printf("clear_blk failed\n");
    return -1;
  }
  ret = mbm_clear_bit(bitmap, 800);
  if (ret != 0) {
    printf("clear_blk failed\n");
    return -1;
  }
  ret = mbm_clear_bit(bitmap, 511);
  if (ret != 0) {
    printf("clear_blk failed\n");
    return -1;
  }
  printf("clear_bit test-2 passed...\n");
  free_blk = mbm_set_first_clear(bitmap);
  if (free_blk != 100) {
    printf("freeblk 100 expected, recieved %lu\n", free_blk);
    return -1;
  }
  free_blk = mbm_set_first_clear(bitmap);
  if (free_blk != 511) {
    printf("freeblk 511 expected, recieved %lu\n", free_blk);
    return -1;
  }
  printf("set_bit test-4 passed...\n");
  mbm_flush_to_disk(bitmap);
  mbm_free_bitmap(bitmap);
  bitmap = mbm_load_bitmap("./metadata.dat", 0);
  if (bitmap == NULL) {
    printf("load test failed...\n");
    return -1;
  }
  printf("load test passed...\n");
  if (!mbm_is_bit_set(bitmap, 511)) {
    printf("Wrong status in metadata file for bit 511\n");
    return -1;
  }
  if (!mbm_is_bit_set(bitmap, 100)) {
    printf("Wrong status in metadata file for bit 100\n");
    return -1;
  }
  if (mbm_is_bit_set(bitmap, 800)) {
    printf("Wrong status in metadata file for bit 800\n");
    return -1;
  }
  if (mbm_is_bit_set(bitmap, 1002)) {
    printf("Wrong status in metadata file for bit 1002\n");
    return -1;
  }
  printf("Load metadata test passed...\n");
  mbm_free_bitmap(bitmap);
  unlink("./metadata.dat");
  printf("All tests Passed\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x4000000,%edi
lea    0xe55(%rip),%rsi
xor    %edx,%edx
call   10a0 <mbm_create_bitmap@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11db <main+0x4b>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1603 <main+0x473>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x400,-0x18(%rbp)
jge    1248 <main+0xb8>
mov    -0x10(%rbp),%rdi
call   1030 <mbm_set_first_clear@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     1235 <main+0xa5>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1603 <main+0x473>
jmp    123a <main+0xaa>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11f0 <main+0x60>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <mbm_set_first_clear@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x400,-0x14(%rbp)
je     128c <main+0xfc>
mov    -0x14(%rbp),%esi
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1603 <main+0x473>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x64,%esi
call   1070 <mbm_clear_bit@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     12cf <main+0x13f>
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1603 <main+0x473>
mov    -0x10(%rbp),%rdi
mov    $0x200,%esi
call   1070 <mbm_clear_bit@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1304 <main+0x174>
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1603 <main+0x473>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1070 <mbm_clear_bit@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1339 <main+0x1a9>
lea    0xd94(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1603 <main+0x473>
lea    0xd8c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <mbm_set_first_clear@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
je     137a <main+0x1ea>
mov    -0x14(%rbp),%esi
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1603 <main+0x473>
lea    0xd89(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x3ea,%esi
call   1070 <mbm_clear_bit@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     13bd <main+0x22d>
lea    0xd10(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1603 <main+0x473>
mov    -0x10(%rbp),%rdi
mov    $0x320,%esi
call   1070 <mbm_clear_bit@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     13f2 <main+0x262>
lea    0xcdb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1603 <main+0x473>
mov    -0x10(%rbp),%rdi
mov    $0x1ff,%esi
call   1070 <mbm_clear_bit@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1427 <main+0x297>
lea    0xca6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1603 <main+0x473>
lea    0xcf6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <mbm_set_first_clear@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
je     1468 <main+0x2d8>
mov    -0x14(%rbp),%esi
lea    0xceb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1603 <main+0x473>
mov    -0x10(%rbp),%rdi
call   1030 <mbm_set_first_clear@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1ff,-0x14(%rbp)
je     149e <main+0x30e>
mov    -0x14(%rbp),%esi
lea    0xcd9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1603 <main+0x473>
lea    0xce3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1090 <mbm_flush_to_disk@plt>
mov    -0x10(%rbp),%rdi
call   1080 <mbm_free_bitmap@plt>
lea    0xb3b(%rip),%rdi
xor    %esi,%esi
call   10b0 <mbm_load_bitmap@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    14f5 <main+0x365>
lea    0xcc0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1603 <main+0x473>
lea    0xcbb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1ff,%esi
call   1050 <mbm_is_bit_set@plt>
cmp    $0x0,%rax
jne    1535 <main+0x3a5>
lea    0xcaa(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1603 <main+0x473>
mov    -0x10(%rbp),%rdi
mov    $0x64,%esi
call   1050 <mbm_is_bit_set@plt>
cmp    $0x0,%rax
jne    1567 <main+0x3d7>
lea    0xca3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1603 <main+0x473>
mov    -0x10(%rbp),%rdi
mov    $0x320,%esi
call   1050 <mbm_is_bit_set@plt>
cmp    $0x0,%rax
je     1599 <main+0x409>
lea    0xc9c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1603 <main+0x473>
mov    -0x10(%rbp),%rdi
mov    $0x3ea,%esi
call   1050 <mbm_is_bit_set@plt>
cmp    $0x0,%rax
je     15cb <main+0x43b>
lea    0xc95(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1603 <main+0x473>
lea    0xca7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1080 <mbm_free_bitmap@plt>
lea    0xa17(%rip),%rdi
call   1040 <unlink@plt>
lea    0xca2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xe56(%rip),%rsi
xor    %ebp,%ebp
mov    $0x4000000,%edi
xor    %edx,%edx
call   10b0 <mbm_create_bitmap@plt>
test   %rax,%rax
je     124a <main+0xaa>
mov    %rax,%rbx
lea    0xef7(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1030 <mbm_set_first_clear@plt>
cmp    %eax,%ebp
jne    1258 <main+0xb8>
add    $0x1,%ebp
cmp    $0x400,%ebp
jne    11d0 <main+0x30>
lea    0xeea(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1030 <mbm_set_first_clear@plt>
cmp    $0x400,%eax
jne    126c <main+0xcc>
lea    0xee8(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1080 <mbm_clear_bit@plt>
test   %eax,%eax
jne    1241 <main+0xa1>
mov    %rbx,%rdi
mov    $0x200,%esi
call   1080 <mbm_clear_bit@plt>
test   %eax,%eax
jne    1241 <main+0xa1>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1080 <mbm_clear_bit@plt>
test   %eax,%eax
je     1288 <main+0xe8>
lea    0x1029(%rip),%rdi
jmp    1251 <main+0xb1>
lea    0x1031(%rip),%rdi
call   1050 <puts@plt>
jmp    127c <main+0xdc>
lea    0xdb0(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <printf@plt>
jmp    127c <main+0xdc>
lea    0xdc0(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe7b(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1030 <mbm_set_first_clear@plt>
cmp    $0x1,%eax
jne    13a0 <main+0x200>
lea    0xe79(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    $0x3ea,%esi
call   1080 <mbm_clear_bit@plt>
test   %eax,%eax
jne    1241 <main+0xa1>
mov    %rbx,%rdi
mov    $0x320,%esi
call   1080 <mbm_clear_bit@plt>
test   %eax,%eax
jne    1241 <main+0xa1>
mov    %rbx,%rdi
mov    $0x1ff,%esi
call   1080 <mbm_clear_bit@plt>
test   %eax,%eax
jne    1241 <main+0xa1>
lea    0xe47(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1030 <mbm_set_first_clear@plt>
cmp    $0x64,%eax
jne    13ac <main+0x20c>
mov    %rbx,%rdi
call   1030 <mbm_set_first_clear@plt>
cmp    $0x1ff,%eax
jne    13b8 <main+0x218>
lea    0xe32(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   10a0 <mbm_flush_to_disk@plt>
mov    %rbx,%rdi
call   1090 <mbm_free_bitmap@plt>
lea    0xcbd(%rip),%rdi
xor    %esi,%esi
call   10c0 <mbm_load_bitmap@plt>
test   %rax,%rax
je     13c4 <main+0x224>
mov    %rax,%rbx
lea    0xe19(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    $0x1ff,%esi
call   1060 <mbm_is_bit_set@plt>
test   %rax,%rax
je     13d0 <main+0x230>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1060 <mbm_is_bit_set@plt>
test   %rax,%rax
je     13dc <main+0x23c>
mov    %rbx,%rdi
mov    $0x320,%esi
call   1060 <mbm_is_bit_set@plt>
test   %rax,%rax
je     13e8 <main+0x248>
lea    0xe98(%rip),%rdi
jmp    1251 <main+0xb1>
lea    0xcb1(%rip),%rdi
jmp    1273 <main+0xd3>
lea    0xcc7(%rip),%rdi
jmp    1273 <main+0xd3>
lea    0xcdf(%rip),%rdi
jmp    1273 <main+0xd3>
lea    0xe92(%rip),%rdi
jmp    1251 <main+0xb1>
lea    0xdaf(%rip),%rdi
jmp    1251 <main+0xb1>
lea    0xdcd(%rip),%rdi
jmp    1251 <main+0xb1>
mov    %rbx,%rdi
mov    $0x3ea,%esi
call   1060 <mbm_is_bit_set@plt>
test   %rax,%rax
je     1406 <main+0x266>
lea    0xe07(%rip),%rdi
jmp    1251 <main+0xb1>
lea    0xdcd(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1090 <mbm_free_bitmap@plt>
lea    0xbdf(%rip),%rdi
call   1040 <unlink@plt>
lea    0xdca(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
jmp    1281 <main+0xe1>

LLVM IR (-O0):
%struct.m_bitmap = type { i32 }
@.str = [15 x i8] c"./metadata.dat\00"
@.str.1 = [23 x i8] c"Create test failed...\0A\00"
@.str.2 = [23 x i8] c"Create test passed...\0A\00"
@.str.3 = [36 x i8] c"freeblk %lu expected, recieved %lu\0A\00"
@.str.4 = [26 x i8] c"set_bit test-1 passed...\0A\00"
@.str.5 = [37 x i8] c"freeblk 1024 expected, recieved %lu\0A\00"
@.str.6 = [26 x i8] c"set_bit test-2 passed...\0A\00"
@.str.7 = [18 x i8] c"clear_blk failed\0A\00"
@.str.8 = [28 x i8] c"clear_bit test-1 passed...\0A\00"
@.str.9 = [34 x i8] c"freeblk 1 expected, recieved %lu\0A\00"
@.str.10 = [26 x i8] c"set_bit test-3 passed...\0A\00"
@.str.11 = [28 x i8] c"clear_bit test-2 passed...\0A\00"
@.str.12 = [36 x i8] c"freeblk 100 expected, recieved %lu\0A\00"
@.str.13 = [36 x i8] c"freeblk 511 expected, recieved %lu\0A\00"
@.str.14 = [26 x i8] c"set_bit test-4 passed...\0A\00"
@.str.15 = [21 x i8] c"load test failed...\0A\00"
@.str.16 = [21 x i8] c"load test passed...\0A\00"
@.str.17 = [43 x i8] c"Wrong status in metadata file for bit 511\0A\00"
@.str.18 = [43 x i8] c"Wrong status in metadata file for bit 100\0A\00"
@.str.19 = [43 x i8] c"Wrong status in metadata file for bit 800\0A\00"
@.str.20 = [44 x i8] c"Wrong status in metadata file for bit 1002\0A\00"
@.str.21 = [30 x i8] c"Load metadata test passed...\0A\00"
@.str.22 = [18 x i8] c"All tests Passed\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.m_bitmap*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call %struct.m_bitmap* @mbm_create_bitmap(i32 67108864, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 0)
store %struct.m_bitmap* %6, %struct.m_bitmap** %2
%7 = load %struct.m_bitmap*, %struct.m_bitmap** %2
%8 = icmp eq %struct.m_bitmap* %7, null
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %151
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %4
br label %13
13: ; preds = %27, %11
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 1024
br i1 %15, label %16, label %30
16: ; preds = %13
%17 = load %struct.m_bitmap*, %struct.m_bitmap** %2
%18 = call i32 @mbm_set_first_clear(%struct.m_bitmap* %17)
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = load i32, i32* %4
%21 = icmp ne i32 %19, %20
br i1 %21, label %22, label %26
22: ; preds = %16
%23 = load i32, i32* %4
%24 = load i32, i32* %3
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %23, i32 %24)
store i32 -1, i32* %1
br label %151
26: ; preds = %16
br label %27
27: ; preds = %26
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %13
30: ; preds = %13
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%32 = load %struct.m_bitmap*, %struct.m_bitmap** %2
%33 = call i32 @mbm_set_first_clear(%struct.m_bitmap* %32)
store i32 %33, i32* %3
%34 = load i32, i32* %3
%35 = icmp ne i32 %34, 1024
br i1 %35, label %36, label %39
36: ; preds = %30
%37 = load i32, i32* %3
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i32 %37)
store i32 -1, i32* %1
br label %151
39: ; preds = %30
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%41 = load %struct.m_bitmap*, %struct.m_bitmap** %2
%42 = call i32 @mbm_clear_bit(%struct.m_bitmap* %41, i32 100)
store i32 %42, i32* %5
%43 = load i32, i32* %5
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %39
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %1
br label %151
47: ; preds = %39
%48 = load %struct.m_bitmap*, %struct.m_bitmap** %2
%49 = call i32 @mbm_clear_bit(%struct.m_bitmap* %48, i32 512)
store i32 %49, i32* %5
%50 = load i32, i32* %5
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %54
52: ; preds = %47
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %1
br label %151
54: ; preds = %47
%55 = load %struct.m_bitmap*, %struct.m_bitmap** %2
%56 = call i32 @mbm_clear_bit(%struct.m_bitmap* %55, i32 1)
store i32 %56, i32* %5
%57 = load i32, i32* %5
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %54
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %1
br label %151
61: ; preds = %54
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%63 = load %struct.m_bitmap*, %struct.m_bitmap** %2
%64 = call i32 @mbm_set_first_clear(%struct.m_bitmap* %63)
store i32 %64, i32* %3
%65 = load i32, i32* %3
%66 = icmp ne i32 %65, 1
br i1 %66, label %67, label %70
67: ; preds = %61
%68 = load i32, i32* %3
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), i32 %68)
store i32 -1, i32* %1
br label %151
70: ; preds = %61
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0))
%72 = load %struct.m_bitmap*, %struct.m_bitmap** %2
%73 = call i32 @mbm_clear_bit(%struct.m_bitmap* %72, i32 1002)
store i32 %73, i32* %5
%74 = load i32, i32* %5
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %70
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %1
br label %151
78: ; preds = %70
%79 = load %struct.m_bitmap*, %struct.m_bitmap** %2
%80 = call i32 @mbm_clear_bit(%struct.m_bitmap* %79, i32 800)
store i32 %80, i32* %5
%81 = load i32, i32* %5
%82 = icmp ne i32 %81, 0
br i1 %82, label %83, label %85
83: ; preds = %78
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %1
br label %151
85: ; preds = %78
%86 = load %struct.m_bitmap*, %struct.m_bitmap** %2
%87 = call i32 @mbm_clear_bit(%struct.m_bitmap* %86, i32 511)
store i32 %87, i32* %5
%88 = load i32, i32* %5
%89 = icmp ne i32 %88, 0
br i1 %89, label %90, label %92
90: ; preds = %85
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %1
br label %151
92: ; preds = %85
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0))
%94 = load %struct.m_bitmap*, %struct.m_bitmap** %2
%95 = call i32 @mbm_set_first_clear(%struct.m_bitmap* %94)
store i32 %95, i32* %3
%96 = load i32, i32* %3
%97 = icmp ne i32 %96, 100
br i1 %97, label %98, label %101
98: ; preds = %92
%99 = load i32, i32* %3
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.12, i64 0, i64 0), i32 %99)
store i32 -1, i32* %1
br label %151
101: ; preds = %92
%102 = load %struct.m_bitmap*, %struct.m_bitmap** %2
%103 = call i32 @mbm_set_first_clear(%struct.m_bitmap* %102)
store i32 %103, i32* %3
%104 = load i32, i32* %3
%105 = icmp ne i32 %104, 511
br i1 %105, label %106, label %109
106: ; preds = %101
%107 = load i32, i32* %3
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.13, i64 0, i64 0), i32 %107)
store i32 -1, i32* %1
br label %151
109: ; preds = %101
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.14, i64 0, i64 0))
%111 = load %struct.m_bitmap*, %struct.m_bitmap** %2
%112 = call i32 @mbm_flush_to_disk(%struct.m_bitmap* %111)
%113 = load %struct.m_bitmap*, %struct.m_bitmap** %2
%114 = call i32 @mbm_free_bitmap(%struct.m_bitmap* %113)
%115 = call %struct.m_bitmap* @mbm_load_bitmap(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 0)
store %struct.m_bitmap* %115, %struct.m_bitmap** %2
%116 = load %struct.m_bitmap*, %struct.m_bitmap** %2
%117 = icmp eq %struct.m_bitmap* %116, null
br i1 %117, label %118, label %120
118: ; preds = %109
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.15, i64 0, i64 0))
store i32 -1, i32* %1
br label %151
120: ; preds = %109
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0))
%122 = load %struct.m_bitmap*, %struct.m_bitmap** %2
%123 = call i64 @mbm_is_bit_set(%struct.m_bitmap* %122, i32 511)
%124 = icmp ne i64 %123, 0
br i1 %124, label %127, label %125
125: ; preds = %120
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.17, i64 0, i64 0))
store i32 -1, i32* %1
br label %151
127: ; preds = %120
%128 = load %struct.m_bitmap*, %struct.m_bitmap** %2
%129 = call i64 @mbm_is_bit_set(%struct.m_bitmap* %128, i32 100)
%130 = icmp ne i64 %129, 0
br i1 %130, label %133, label %131
131: ; preds = %127
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.18, i64 0, i64 0))
store i32 -1, i32* %1
br label %151
133: ; preds = %127
%134 = load %struct.m_bitmap*, %struct.m_bitmap** %2
%135 = call i64 @mbm_is_bit_set(%struct.m_bitmap* %134, i32 800)
%136 = icmp ne i64 %135, 0
br i1 %136, label %137, label %139
137: ; preds = %133
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.19, i64 0, i64 0))
store i32 -1, i32* %1
br label %151
139: ; preds = %133
%140 = load %struct.m_bitmap*, %struct.m_bitmap** %2
%141 = call i64 @mbm_is_bit_set(%struct.m_bitmap* %140, i32 1002)
%142 = icmp ne i64 %141, 0
br i1 %142, label %143, label %145
143: ; preds = %139
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.20, i64 0, i64 0))
store i32 -1, i32* %1
br label %151
145: ; preds = %139
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.21, i64 0, i64 0))
%147 = load %struct.m_bitmap*, %struct.m_bitmap** %2
%148 = call i32 @mbm_free_bitmap(%struct.m_bitmap* %147)
%149 = call i32 @unlink(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%150 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.22, i64 0, i64 0))
store i32 0, i32* %1
br label %151
151: ; preds = %145, %143, %137, %131, %125, %118, %106, %98, %90, %83, %76, %67, %59, %52, %45, %36, %22, %9
%152 = load i32, i32* %1
ret i32 %152
}

LLVM IR (-O2):
%struct.m_bitmap = type { i32 }
@.str = [15 x i8] c"./metadata.dat\00"
@.str.3 = [36 x i8] c"freeblk %lu expected, recieved %lu\0A\00"
@.str.5 = [37 x i8] c"freeblk 1024 expected, recieved %lu\0A\00"
@.str.9 = [34 x i8] c"freeblk 1 expected, recieved %lu\0A\00"
@.str.12 = [36 x i8] c"freeblk 100 expected, recieved %lu\0A\00"
@.str.13 = [36 x i8] c"freeblk 511 expected, recieved %lu\0A\00"
@str = [22 x i8] c"Create test passed...\00"
@str.23 = [25 x i8] c"set_bit test-1 passed...\00"
@str.24 = [25 x i8] c"set_bit test-2 passed...\00"
@str.25 = [27 x i8] c"clear_bit test-1 passed...\00"
@str.26 = [25 x i8] c"set_bit test-3 passed...\00"
@str.27 = [27 x i8] c"clear_bit test-2 passed...\00"
@str.28 = [25 x i8] c"set_bit test-4 passed...\00"
@str.29 = [20 x i8] c"load test passed...\00"
@str.30 = [42 x i8] c"Wrong status in metadata file for bit 511\00"
@str.31 = [42 x i8] c"Wrong status in metadata file for bit 100\00"
@str.32 = [29 x i8] c"Load metadata test passed...\00"
@str.33 = [17 x i8] c"All tests Passed\00"
@str.34 = [43 x i8] c"Wrong status in metadata file for bit 1002\00"
@str.35 = [42 x i8] c"Wrong status in metadata file for bit 800\00"
@str.36 = [20 x i8] c"load test failed...\00"
@str.42 = [17 x i8] c"clear_blk failed\00"
@str.43 = [22 x i8] c"Create test failed...\00"
define i32 @main() {
%1 = tail call %struct.m_bitmap* @mbm_create_bitmap(i32 67108864, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 0)
%2 = icmp eq %struct.m_bitmap* %1, null
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.43, i64 0, i64 0))
br label %105
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %7
7: ; preds = %5, %13
%8 = phi i32 [ 0, %5 ], [ %14, %13 ]
%9 = tail call i32 @mbm_set_first_clear(%struct.m_bitmap* %1)
%10 = icmp eq i32 %9, %8
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %8, i32 %9)
br label %105
13: ; preds = %7
%14 = add nuw nsw i32 %8, 1
%15 = icmp eq i32 %14, 1024
br i1 %15, label %16, label %7
16: ; preds = %13
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.23, i64 0, i64 0))
%18 = tail call i32 @mbm_set_first_clear(%struct.m_bitmap* %1)
%19 = icmp eq i32 %18, 1024
br i1 %19, label %22, label %20
20: ; preds = %16
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i32 %18)
br label %105
22: ; preds = %16
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.24, i64 0, i64 0))
%24 = tail call i32 @mbm_clear_bit(%struct.m_bitmap* %1, i32 100)
%25 = icmp eq i32 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %22
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.42, i64 0, i64 0))
br label %105
28: ; preds = %22
%29 = tail call i32 @mbm_clear_bit(%struct.m_bitmap* %1, i32 512)
%30 = icmp eq i32 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %28
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.42, i64 0, i64 0))
br label %105
33: ; preds = %28
%34 = tail call i32 @mbm_clear_bit(%struct.m_bitmap* %1, i32 1)
%35 = icmp eq i32 %34, 0
br i1 %35, label %38, label %36
36: ; preds = %33
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.42, i64 0, i64 0))
br label %105
38: ; preds = %33
%39 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.25, i64 0, i64 0))
%40 = tail call i32 @mbm_set_first_clear(%struct.m_bitmap* %1)
%41 = icmp eq i32 %40, 1
br i1 %41, label %44, label %42
42: ; preds = %38
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), i32 %40)
br label %105
44: ; preds = %38
%45 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.26, i64 0, i64 0))
%46 = tail call i32 @mbm_clear_bit(%struct.m_bitmap* %1, i32 1002)
%47 = icmp eq i32 %46, 0
br i1 %47, label %50, label %48
48: ; preds = %44
%49 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.42, i64 0, i64 0))
br label %105
50: ; preds = %44
%51 = tail call i32 @mbm_clear_bit(%struct.m_bitmap* %1, i32 800)
%52 = icmp eq i32 %51, 0
br i1 %52, label %55, label %53
53: ; preds = %50
%54 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.42, i64 0, i64 0))
br label %105
55: ; preds = %50
%56 = tail call i32 @mbm_clear_bit(%struct.m_bitmap* %1, i32 511)
%57 = icmp eq i32 %56, 0
br i1 %57, label %60, label %58
58: ; preds = %55
%59 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.42, i64 0, i64 0))
br label %105
60: ; preds = %55
%61 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.27, i64 0, i64 0))
%62 = tail call i32 @mbm_set_first_clear(%struct.m_bitmap* %1)
%63 = icmp eq i32 %62, 100
br i1 %63, label %66, label %64
64: ; preds = %60
%65 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.12, i64 0, i64 0), i32 %62)
br label %105
66: ; preds = %60
%67 = tail call i32 @mbm_set_first_clear(%struct.m_bitmap* %1)
%68 = icmp eq i32 %67, 511
br i1 %68, label %71, label %69
69: ; preds = %66
%70 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.13, i64 0, i64 0), i32 %67)
br label %105
71: ; preds = %66
%72 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.28, i64 0, i64 0))
%73 = tail call i32 @mbm_flush_to_disk(%struct.m_bitmap* %1)
%74 = tail call i32 @mbm_free_bitmap(%struct.m_bitmap* %1)
%75 = tail call %struct.m_bitmap* @mbm_load_bitmap(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 0)
%76 = icmp eq %struct.m_bitmap* %75, null
br i1 %76, label %77, label %79
77: ; preds = %71
%78 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.36, i64 0, i64 0))
br label %105
79: ; preds = %71
%80 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.29, i64 0, i64 0))
%81 = tail call i64 @mbm_is_bit_set(%struct.m_bitmap* %75, i32 511)
%82 = icmp eq i64 %81, 0
br i1 %82, label %83, label %85
83: ; preds = %79
%84 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.30, i64 0, i64 0))
br label %105
85: ; preds = %79
%86 = tail call i64 @mbm_is_bit_set(%struct.m_bitmap* %75, i32 100)
%87 = icmp eq i64 %86, 0
br i1 %87, label %88, label %90
88: ; preds = %85
%89 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.31, i64 0, i64 0))
br label %105
90: ; preds = %85
%91 = tail call i64 @mbm_is_bit_set(%struct.m_bitmap* %75, i32 800)
%92 = icmp eq i64 %91, 0
br i1 %92, label %95, label %93
93: ; preds = %90
%94 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.35, i64 0, i64 0))
br label %105
95: ; preds = %90
%96 = tail call i64 @mbm_is_bit_set(%struct.m_bitmap* %75, i32 1002)
%97 = icmp eq i64 %96, 0
br i1 %97, label %100, label %98
98: ; preds = %95
%99 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.34, i64 0, i64 0))
br label %105
100: ; preds = %95
%101 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.32, i64 0, i64 0))
%102 = tail call i32 @mbm_free_bitmap(%struct.m_bitmap* %75)
%103 = tail call i32 @unlink(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%104 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.33, i64 0, i64 0))
br label %105
105: ; preds = %26, %31, %36, %42, %48, %53, %58, %64, %69, %77, %83, %88, %93, %98, %100, %20, %11, %3
%106 = phi i32 [ -1, %3 ], [ -1, %11 ], [ -1, %20 ], [ -1, %26 ], [ -1, %31 ], [ -1, %36 ], [ -1, %42 ], [ -1, %48 ], [ -1, %53 ], [ -1, %58 ], [ -1, %64 ], [ -1, %69 ], [ -1, %77 ], [ -1, %93 ], [ -1, %98 ], [ 0, %100 ], [ -1, %88 ], [ -1, %83 ]
ret i32 %106
}