#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 */

/* Variables and functions */
scalar_t__ env_cleanup();
int /*<<< orphan*/ printf(char *);
scalar_t__ test_file_creation();
scalar_t__ test_file_write();
scalar_t__ test_fs_creation();
int main(int argc, char **argv) {
  if (test_fs_creation()) {
    printf("test_fs_creation failed.\n");
    if (env_cleanup()) {
      return 1;
    }
  } else {
    printf("test_fs_creation successful.\n");
  }
  if (test_file_creation()) {
    printf("test_file_creation failed.\n");
    if (env_cleanup()) {
      return 1;
    }
  } else {
    printf("test_file_creation successful.\n");
  }
  if (test_file_write()) {
    printf("test_file_write failed.\n");
    if (env_cleanup()) {
      return 1;
    }
  } else {
    printf("test_file_write successful.\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <test_fs_creation@plt>
cmp    $0x0,%rax
je     11a5 <main+0x55>
lea    0xe82(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <env_cleanup@plt>
cmp    $0x0,%rax
je     11a0 <main+0x50>
movl   $0x1,-0x4(%rbp)
jmp    124e <main+0xfe>
jmp    11b1 <main+0x61>
lea    0xe6e(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <test_file_creation@plt>
cmp    $0x0,%rax
je     11f0 <main+0xa0>
lea    0xe6f(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <env_cleanup@plt>
cmp    $0x0,%rax
je     11eb <main+0x9b>
movl   $0x1,-0x4(%rbp)
jmp    124e <main+0xfe>
jmp    11fc <main+0xac>
lea    0xe5d(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <test_file_write@plt>
cmp    $0x0,%rax
je     123b <main+0xeb>
lea    0xe60(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <env_cleanup@plt>
cmp    $0x0,%rax
je     1236 <main+0xe6>
movl   $0x1,-0x4(%rbp)
jmp    124e <main+0xfe>
jmp    1247 <main+0xf7>
lea    0xe4b(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1050 <test_fs_creation@plt>
test   %rax,%rax
je     117f <main+0x2f>
lea    0xf27(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <env_cleanup@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
je     118b <main+0x3b>
pop    %rcx
ret
lea    0xe7a(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <test_file_creation@plt>
test   %rax,%rax
je     11b9 <main+0x69>
lea    0xed2(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <env_cleanup@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    117d <main+0x2d>
jmp    11c5 <main+0x75>
lea    0xe5d(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1070 <test_file_write@plt>
test   %rax,%rax
je     11f3 <main+0xa3>
lea    0xe80(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <env_cleanup@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    117d <main+0x2d>
jmp    11ff <main+0xaf>
lea    0xe42(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"test_fs_creation failed.\0A\00"
@.str.1 = [30 x i8] c"test_fs_creation successful.\0A\00"
@.str.2 = [28 x i8] c"test_file_creation failed.\0A\00"
@.str.3 = [32 x i8] c"test_file_creation successful.\0A\00"
@.str.4 = [25 x i8] c"test_file_write failed.\0A\00"
@.str.5 = [29 x i8] c"test_file_write successful.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i64 (...) @test_fs_creation()
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%10 = call i64 (...) @env_cleanup()
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
store i32 1, i32* %3
br label %39
13: ; preds = %8
br label %16
14: ; preds = %2
%15 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %13
%17 = call i64 (...) @test_file_creation()
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %16
%20 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%21 = call i64 (...) @env_cleanup()
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %19
store i32 1, i32* %3
br label %39
24: ; preds = %19
br label %27
25: ; preds = %16
%26 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %25, %24
%28 = call i64 (...) @test_file_write()
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %36
30: ; preds = %27
%31 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%32 = call i64 (...) @env_cleanup()
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %30
store i32 1, i32* %3
br label %39
35: ; preds = %30
br label %38
36: ; preds = %27
%37 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
br label %38
38: ; preds = %36, %35
store i32 0, i32* %3
br label %39
39: ; preds = %38, %34, %23, %12
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@str = [29 x i8] c"test_fs_creation successful.\00"
@str.6 = [31 x i8] c"test_file_creation successful.\00"
@str.7 = [28 x i8] c"test_file_write successful.\00"
@str.8 = [24 x i8] c"test_file_write failed.\00"
@str.9 = [27 x i8] c"test_file_creation failed.\00"
@str.10 = [25 x i8] c"test_fs_creation failed.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 (...) @test_fs_creation()
%4 = icmp eq i64 %3, 0
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.10, i64 0, i64 0))
%7 = tail call i64 (...) @env_cleanup()
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %30
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
br label %11
11: ; preds = %5, %9
%12 = tail call i64 (...) @test_file_creation()
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %11
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.9, i64 0, i64 0))
%16 = tail call i64 (...) @env_cleanup()
%17 = icmp eq i64 %16, 0
br i1 %17, label %20, label %30
18: ; preds = %11
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.6, i64 0, i64 0))
br label %20
20: ; preds = %14, %18
%21 = tail call i64 (...) @test_file_write()
%22 = icmp eq i64 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %20
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.8, i64 0, i64 0))
%25 = tail call i64 (...) @env_cleanup()
%26 = icmp eq i64 %25, 0
br i1 %26, label %29, label %30
27: ; preds = %20
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.7, i64 0, i64 0))
br label %29
29: ; preds = %23, %27
br label %30
30: ; preds = %23, %14, %5, %29
%31 = phi i32 [ 0, %29 ], [ 1, %5 ], [ 1, %14 ], [ 1, %23 ]
ret i32 %31
}