#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 fmap {
  int dummy;
};

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
scalar_t__ fmap_append_area_test(struct fmap **);
struct fmap *fmap_create_test();
int /*<<< orphan*/ fmap_destroy(struct fmap *);
int fmap_find_area_test(struct fmap *);
scalar_t__ fmap_find_test(struct fmap *);
int fmap_flags_to_string_test();
int fmap_print_test(struct fmap *);
int fmap_size_test();
int /*<<< orphan*/ printf(char *);
int fmap_test(void) {
  int rc = EXIT_SUCCESS;
  struct fmap *my_fmap;
  if ((my_fmap = fmap_create_test()) == NULL) {
    rc = EXIT_FAILURE;
    goto fmap_test_exit;
  }
  if (fmap_find_test(my_fmap)) {
    rc = EXIT_FAILURE;
    goto fmap_test_exit;
  }
  if (fmap_append_area_test(&my_fmap)) {
    rc = EXIT_FAILURE;
    goto fmap_test_exit;
  }
  rc |= fmap_find_area_test(my_fmap);
  rc |= fmap_size_test();
  rc |= fmap_flags_to_string_test();
  rc |= fmap_print_test(my_fmap);
fmap_test_exit:
  fmap_destroy(my_fmap);
  if (rc)
    printf("FAILED\n");
  return rc;
}


x86 assembly (clang, -O0):
<fmap_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e39(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1050 <fmap_create_test@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11ca <fmap_test+0x3a>
mov    0x2e20(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    124a <fmap_test+0xba>
mov    -0x10(%rbp),%rdi
call   1080 <fmap_find_test@plt>
cmp    $0x0,%rax
je     11ee <fmap_test+0x5e>
mov    0x2dfc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    124a <fmap_test+0xba>
lea    -0x10(%rbp),%rdi
call   1090 <fmap_append_area_test@plt>
cmp    $0x0,%rax
je     1212 <fmap_test+0x82>
mov    0x2dd8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    124a <fmap_test+0xba>
mov    -0x10(%rbp),%rdi
call   10a0 <fmap_find_area_test@plt>
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1030 <fmap_size_test@plt>
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1070 <fmap_flags_to_string_test@plt>
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rdi
call   10b0 <fmap_print_test@plt>
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <fmap_destroy@plt>
cmpl   $0x0,-0x4(%rbp)
je     1269 <fmap_test+0xd9>
lea    0xd9c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fmap_test>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x2e39(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   1050 <fmap_create_test@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     11ce <fmap_test+0x3e>
mov    %rax,%rdi
call   1080 <fmap_find_test@plt>
test   %rax,%rax
jne    11ce <fmap_test+0x3e>
lea    0x8(%rsp),%rdi
call   1090 <fmap_append_area_test@plt>
test   %rax,%rax
je     11fc <fmap_test+0x6c>
mov    0x2e0b(%rip),%rax
mov    (%rax),%ebx
mov    0x8(%rsp),%rdi
call   1060 <fmap_destroy@plt>
test   %ebx,%ebx
je     11f1 <fmap_test+0x61>
lea    0xe14(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x8(%rsp),%rdi
call   10a0 <fmap_find_area_test@plt>
mov    %eax,%r14d
or     %ebx,%r14d
xor    %eax,%eax
call   1040 <fmap_size_test@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1070 <fmap_flags_to_string_test@plt>
mov    %eax,%ebp
or     %ebx,%ebp
mov    0x8(%rsp),%rdi
call   10b0 <fmap_print_test@plt>
mov    %eax,%ebx
or     %ebp,%ebx
or     %r14d,%ebx
jmp    11d7 <fmap_test+0x47>

LLVM IR (-O0):
%struct.fmap = type { i32 }
@EXIT_SUCCESS = global i32 0
@EXIT_FAILURE = global i32 0
@.str = [8 x i8] c"FAILED\0A\00"
define i32 @fmap_test() {
%1 = alloca i32
%2 = alloca %struct.fmap*
%3 = load i32, i32* @EXIT_SUCCESS
store i32 %3, i32* %1
%4 = call %struct.fmap* (...) @fmap_create_test()
store %struct.fmap* %4, %struct.fmap** %2
%5 = icmp eq %struct.fmap* %4, null
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = load i32, i32* @EXIT_FAILURE
store i32 %7, i32* %1
br label %34
8: ; preds = %0
%9 = load %struct.fmap*, %struct.fmap** %2
%10 = call i64 @fmap_find_test(%struct.fmap* %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = load i32, i32* @EXIT_FAILURE
store i32 %13, i32* %1
br label %34
14: ; preds = %8
%15 = call i64 @fmap_append_area_test(%struct.fmap** %2)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = load i32, i32* @EXIT_FAILURE
store i32 %18, i32* %1
br label %34
19: ; preds = %14
%20 = load %struct.fmap*, %struct.fmap** %2
%21 = call i32 @fmap_find_area_test(%struct.fmap* %20)
%22 = load i32, i32* %1
%23 = or i32 %22, %21
store i32 %23, i32* %1
%24 = call i32 (...) @fmap_size_test()
%25 = load i32, i32* %1
%26 = or i32 %25, %24
store i32 %26, i32* %1
%27 = call i32 (...) @fmap_flags_to_string_test()
%28 = load i32, i32* %1
%29 = or i32 %28, %27
store i32 %29, i32* %1
%30 = load %struct.fmap*, %struct.fmap** %2
%31 = call i32 @fmap_print_test(%struct.fmap* %30)
%32 = load i32, i32* %1
%33 = or i32 %32, %31
store i32 %33, i32* %1
br label %34
34: ; preds = %19, %17, %12, %6
%35 = load %struct.fmap*, %struct.fmap** %2
%36 = call i32 @fmap_destroy(%struct.fmap* %35)
%37 = load i32, i32* %1
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %34
%40 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %41
41: ; preds = %39, %34
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
%struct.fmap = type { i32 }
@EXIT_SUCCESS = global i32 0
@EXIT_FAILURE = global i32 0
@str = [7 x i8] c"FAILED\00"
define i32 @fmap_test() {
%1 = alloca %struct.fmap*
%2 = load i32, i32* @EXIT_SUCCESS
%3 = bitcast %struct.fmap** %1 to i8*
%4 = tail call %struct.fmap* (...) @fmap_create_test()
store %struct.fmap* %4, %struct.fmap** %1
%5 = icmp eq %struct.fmap* %4, null
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = load i32, i32* @EXIT_FAILURE
br label %29
8: ; preds = %0
%9 = tail call i64 @fmap_find_test(%struct.fmap* %4)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = load i32, i32* @EXIT_FAILURE
br label %29
13: ; preds = %8
%14 = call i64 @fmap_append_area_test(%struct.fmap** %1)
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = load i32, i32* @EXIT_FAILURE
br label %29
18: ; preds = %13
%19 = load %struct.fmap*, %struct.fmap** %1
%20 = call i32 @fmap_find_area_test(%struct.fmap* %19)
%21 = or i32 %20, %2
%22 = call i32 (...) @fmap_size_test()
%23 = or i32 %21, %22
%24 = call i32 (...) @fmap_flags_to_string_test()
%25 = or i32 %23, %24
%26 = load %struct.fmap*, %struct.fmap** %1
%27 = call i32 @fmap_print_test(%struct.fmap* %26)
%28 = or i32 %25, %27
br label %29
29: ; preds = %18, %16, %11, %6
%30 = phi i32 [ %7, %6 ], [ %12, %11 ], [ %17, %16 ], [ %28, %18 ]
%31 = load %struct.fmap*, %struct.fmap** %1
%32 = call i32 @fmap_destroy(%struct.fmap* %31)
%33 = icmp eq i32 %30, 0
br i1 %33, label %36, label %34
34: ; preds = %29
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
br label %36
36: ; preds = %34, %29
ret i32 %30
}