#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 fast_log_buf {
  int dummy;
};
typedef int /*<<< orphan*/ fname;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
scalar_t__ EINTR;
int O_CREAT;
int O_RDWR;
int O_TRUNC;
int PATH_MAX;
int close(int);
scalar_t__ errno;
struct fast_log_buf *fast_log_create(char *);
int /*<<< orphan*/ fast_log_destroy(struct fast_log_buf *);
int fast_log_dump(struct fast_log_buf *, struct fast_log_buf *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char *);
int open(char *, int, int);
scalar_t__ simple_io_read_whole_file_zt(char *, char *, int);
int /*<<< orphan*/ stderr;
int strcmp(char *, char const *);
int zsnprintf(char *, int, char *, char const *);
int dump_empty_buf(const char *tdir) {
  char fname[PATH_MAX];
  char buf[512] = {0};
  const char expected[] = "*** FASTLOG empty\n";
  struct fast_log_buf *scratch, *empty;
  int res, fd;
  do {
    int __my_ret__ = zsnprintf(fname, sizeof(fname), "%s/empty", tdir);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 92,
              "zsnprintf(fname, sizeof(fname), \"%s/empty\", tdir)");
      return __my_ret__;
    }
  } while (0);
  ;
  fd = open(fname, O_CREAT | O_TRUNC | O_RDWR, 0644);
  do {
    if (fd < 0) {
      fprintf(stderr, "failed on line %d: %s\n", 94, "fd");
      return 1;
    }
  } while (0);
  ;
  scratch = fast_log_create("scratch");
  do {
    if (scratch == NULL) {
      fprintf(stderr, "failed on line %d: %s\n", 96, "scratch");
      return 1;
    }
  } while (0);
  ;
  empty = fast_log_create("empty");
  do {
    if (empty == NULL) {
      fprintf(stderr, "failed on line %d: %s\n", 98, "empty");
      return 1;
    }
  } while (0);
  ;
  do {
    int __my_ret__ = fast_log_dump(empty, scratch, fd);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 99,
              "fast_log_dump(empty, scratch, fd)");
      return __my_ret__;
    }
  } while (0);
  ;
  do {
    res = close(fd);
  } while ((res == -1) && (errno == EINTR));
  ;
  fast_log_destroy(empty);
  fast_log_destroy(scratch);
  do {
    if (simple_io_read_whole_file_zt(fname, buf, sizeof(buf)) <= 0) {
      fprintf(stderr, "failed on line %d: %s\n", 104,
              "simple_io_read_whole_file_zt(fname, buf, sizeof(buf))");
      return 1;
    }
  } while (0);
  ;
  do {
    int __my_ret__ = strcmp(buf, expected);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 105, "strcmp(buf, expected)");
      return __my_ret__;
    }
  } while (0);
  ;
  return 0;
}


x86 assembly (clang, -O0):
<dump_empty_buf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x280,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2e2a(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x278(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x270(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
lea    -0x220(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1060 <memset@plt>
mov    0xe01(%rip),%rax
mov    %rax,-0x240(%rbp)
mov    0xdfb(%rip),%rax
mov    %rax,-0x238(%rbp)
mov    0xdf5(%rip),%ax
mov    %ax,-0x230(%rbp)
mov    0xdea(%rip),%al
mov    %al,-0x22e(%rbp)
mov    -0x270(%rbp),%rdi
mov    -0x278(%rbp),%rax
mov    %eax,%esi
mov    -0x10(%rbp),%rcx
lea    0xdca(%rip),%rdx
call   10b0 <zsnprintf@plt>
mov    %eax,-0x25c(%rbp)
cmpl   $0x0,-0x25c(%rbp)
je     129a <dump_empty_buf+0xfa>
mov    0x2d58(%rip),%rax
mov    (%rax),%edi
lea    0xdab(%rip),%rsi
mov    $0x5c,%edx
lea    0xdb6(%rip),%rcx
call   1090 <fprintf@plt>
mov    -0x25c(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x260(%rbp)
jmp    15ac <dump_empty_buf+0x40c>
jmp    129f <dump_empty_buf+0xff>
jmp    12a4 <dump_empty_buf+0x104>
mov    -0x270(%rbp),%rdi
mov    0x2d46(%rip),%rax
mov    (%rax),%esi
mov    0x2d35(%rip),%rax
or     (%rax),%esi
mov    0x2d0c(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
call   10c0 <open@plt>
mov    %eax,-0x258(%rbp)
cmpl   $0x0,-0x258(%rbp)
jge    131a <dump_empty_buf+0x17a>
mov    0x2cd6(%rip),%rax
mov    (%rax),%edi
lea    0xd29(%rip),%rsi
mov    $0x5e,%edx
lea    0xd66(%rip),%rcx
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x260(%rbp)
jmp    15ac <dump_empty_buf+0x40c>
jmp    131f <dump_empty_buf+0x17f>
jmp    1324 <dump_empty_buf+0x184>
lea    0xd3d(%rip),%rdi
call   1040 <fast_log_create@plt>
mov    %rax,-0x248(%rbp)
cmpq   $0x0,-0x248(%rbp)
jne    137c <dump_empty_buf+0x1dc>
mov    0x2c74(%rip),%rax
mov    (%rax),%edi
lea    0xcc7(%rip),%rsi
mov    $0x60,%edx
lea    0xd07(%rip),%rcx
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x260(%rbp)
jmp    15ac <dump_empty_buf+0x40c>
jmp    1381 <dump_empty_buf+0x1e1>
jmp    1386 <dump_empty_buf+0x1e6>
lea    0xc89(%rip),%rdi
call   1040 <fast_log_create@plt>
mov    %rax,-0x250(%rbp)
cmpq   $0x0,-0x250(%rbp)
jne    13de <dump_empty_buf+0x23e>
mov    0x2c12(%rip),%rax
mov    (%rax),%edi
lea    0xc65(%rip),%rsi
mov    $0x62,%edx
lea    0xc53(%rip),%rcx
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x260(%rbp)
jmp    15ac <dump_empty_buf+0x40c>
jmp    13e3 <dump_empty_buf+0x243>
jmp    13e8 <dump_empty_buf+0x248>
jmp    13ed <dump_empty_buf+0x24d>
mov    -0x250(%rbp),%rdi
mov    -0x248(%rbp),%rsi
mov    -0x258(%rbp),%edx
call   10a0 <fast_log_dump@plt>
mov    %eax,-0x264(%rbp)
cmpl   $0x0,-0x264(%rbp)
je     1452 <dump_empty_buf+0x2b2>
mov    0x2ba0(%rip),%rax
mov    (%rax),%edi
lea    0xbf3(%rip),%rsi
mov    $0x63,%edx
lea    0xc3b(%rip),%rcx
call   1090 <fprintf@plt>
mov    -0x264(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x260(%rbp)
jmp    15ac <dump_empty_buf+0x40c>
jmp    1457 <dump_empty_buf+0x2b7>
jmp    145c <dump_empty_buf+0x2bc>
jmp    1461 <dump_empty_buf+0x2c1>
mov    -0x258(%rbp),%edi
call   1070 <close@plt>
mov    %eax,-0x254(%rbp)
xor    %eax,%eax
cmpl   $0xffffffff,-0x254(%rbp)
mov    %al,-0x279(%rbp)
jne    14a4 <dump_empty_buf+0x304>
mov    0x2b2a(%rip),%rax
mov    (%rax),%rax
mov    0x2b18(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x279(%rbp)
mov    -0x279(%rbp),%al
test   $0x1,%al
jne    1461 <dump_empty_buf+0x2c1>
mov    -0x250(%rbp),%rdi
call   1030 <fast_log_destroy@plt>
mov    -0x248(%rbp),%rdi
call   1030 <fast_log_destroy@plt>
mov    -0x270(%rbp),%rdi
lea    -0x220(%rbp),%rsi
mov    $0x200,%edx
call   1050 <simple_io_read_whole_file_zt@plt>
cmp    $0x0,%rax
jg     1523 <dump_empty_buf+0x383>
mov    0x2acd(%rip),%rax
mov    (%rax),%edi
lea    0xb20(%rip),%rsi
mov    $0x68,%edx
lea    0xb8a(%rip),%rcx
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x260(%rbp)
jmp    15ac <dump_empty_buf+0x40c>
jmp    1528 <dump_empty_buf+0x388>
jmp    152d <dump_empty_buf+0x38d>
jmp    1532 <dump_empty_buf+0x392>
lea    -0x220(%rbp),%rdi
lea    -0x240(%rbp),%rsi
call   1080 <strcmp@plt>
mov    %eax,-0x268(%rbp)
cmpl   $0x0,-0x268(%rbp)
je     1591 <dump_empty_buf+0x3f1>
mov    0x2a61(%rip),%rax
mov    (%rax),%edi
lea    0xab4(%rip),%rsi
mov    $0x69,%edx
lea    0xb54(%rip),%rcx
call   1090 <fprintf@plt>
mov    -0x268(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x260(%rbp)
jmp    15ac <dump_empty_buf+0x40c>
jmp    1596 <dump_empty_buf+0x3f6>
jmp    159b <dump_empty_buf+0x3fb>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x260(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_empty_buf>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %rdi,%r14
mov    0x2e22(%rip),%rax
mov    (%rax),%ebx
mov    %rsp,%r13
mov    %rbx,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
lea    -0x230(%rbp),%rdi
mov    $0x200,%edx
xor    %esi,%esi
call   1060 <memset@plt>
lea    0xe25(%rip),%rdx
mov    %r13,%rdi
mov    %ebx,%esi
mov    %r14,%rcx
call   10b0 <zsnprintf@plt>
test   %eax,%eax
je     1228 <dump_empty_buf+0x88>
mov    %eax,%r14d
mov    0x2db7(%rip),%rax
mov    (%rax),%edi
lea    0xe0a(%rip),%rsi
lea    0xe1a(%rip),%rcx
mov    $0x5c,%edx
call   1090 <fprintf@plt>
jmp    131c <dump_empty_buf+0x17c>
mov    0x2dc9(%rip),%rax
mov    0x2dba(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2d8f(%rip),%rax
or     (%rax),%esi
mov    %r13,%rdi
mov    $0x1a4,%edx
call   10c0 <open@plt>
test   %eax,%eax
js     12b9 <dump_empty_buf+0x119>
mov    %eax,%r15d
lea    0xe0a(%rip),%rdi
call   1040 <fast_log_create@plt>
test   %rax,%rax
je     12d7 <dump_empty_buf+0x137>
mov    %rax,%r12
lea    0xda4(%rip),%rdi
call   1040 <fast_log_create@plt>
test   %rax,%rax
je     12f5 <dump_empty_buf+0x155>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
call   10a0 <fast_log_dump@plt>
test   %eax,%eax
je     132e <dump_empty_buf+0x18e>
mov    %eax,%r14d
mov    0x2d21(%rip),%rax
mov    (%rax),%edi
lea    0xd74(%rip),%rsi
lea    0xdc1(%rip),%rcx
mov    $0x63,%edx
jmp    121e <dump_empty_buf+0x7e>
mov    0x2d00(%rip),%rax
mov    (%rax),%edi
lea    0xd53(%rip),%rsi
lea    0xd95(%rip),%rcx
mov    $0x5e,%edx
jmp    1311 <dump_empty_buf+0x171>
mov    0x2ce2(%rip),%rax
mov    (%rax),%edi
lea    0xd35(%rip),%rsi
lea    0xd7a(%rip),%rcx
mov    $0x60,%edx
jmp    1311 <dump_empty_buf+0x171>
mov    0x2cc4(%rip),%rax
mov    (%rax),%edi
lea    0xd17(%rip),%rsi
lea    0xd0a(%rip),%rcx
mov    $0x62,%edx
call   1090 <fprintf@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,-0x30(%rbp)
mov    0x2c7f(%rip),%r14
mov    0x2c70(%rip),%rbx
mov    %r15d,%edi
call   1070 <close@plt>
cmp    $0xffffffff,%eax
jne    1355 <dump_empty_buf+0x1b5>
mov    (%rbx),%rax
cmp    %rax,(%r14)
je     1340 <dump_empty_buf+0x1a0>
mov    -0x30(%rbp),%rdi
call   1030 <fast_log_destroy@plt>
mov    %r12,%rdi
call   1030 <fast_log_destroy@plt>
lea    -0x230(%rbp),%rsi
mov    %r13,%rdi
mov    $0x200,%edx
call   1050 <simple_io_read_whole_file_zt@plt>
test   %rax,%rax
jle    13ba <dump_empty_buf+0x21a>
lea    0xc7a(%rip),%rsi
lea    -0x230(%rbp),%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     13db <dump_empty_buf+0x23b>
mov    %eax,%r14d
mov    0x2c20(%rip),%rax
mov    (%rax),%edi
lea    0xc73(%rip),%rsi
lea    0xd18(%rip),%rcx
mov    $0x69,%edx
jmp    121e <dump_empty_buf+0x7e>
mov    0x2bff(%rip),%rax
mov    (%rax),%edi
lea    0xc52(%rip),%rsi
lea    0xcc1(%rip),%rcx
mov    $0x68,%edx
jmp    1311 <dump_empty_buf+0x171>
xor    %r14d,%r14d
jmp    131c <dump_empty_buf+0x17c>

LLVM IR (-O0):
%struct.fast_log_buf = type { i32 }
@PATH_MAX = global i32 0
@__const.dump_empty_buf.expected = [19 x i8] c"*** FASTLOG empty\0A\00"
@.str = [9 x i8] c"%s/empty\00"
@stderr = global i32 0
@.str.1 = [23 x i8] c"failed on line %d: %s\0A\00"
@.str.2 = [50 x i8] c"zsnprintf(fname, sizeof(fname), \22%s/empty\22, tdir)\00"
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@O_RDWR = global i32 0
@.str.3 = [3 x i8] c"fd\00"
@.str.4 = [8 x i8] c"scratch\00"
@.str.5 = [6 x i8] c"empty\00"
@.str.6 = [34 x i8] c"fast_log_dump(empty, scratch, fd)\00"
@errno = global i64 0
@EINTR = global i64 0
@.str.7 = [54 x i8] c"simple_io_read_whole_file_zt(fname, buf, sizeof(buf))\00"
@.str.8 = [22 x i8] c"strcmp(buf, expected)\00"
define i32 @dump_empty_buf(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca [512 x i8]
%7 = alloca [19 x i8]
%8 = alloca %struct.fast_log_buf*
%9 = alloca %struct.fast_log_buf*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i8* %0, i8** %3
%16 = load i32, i32* @PATH_MAX
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %4
%19 = alloca i8, i64 %17
store i64 %17, i64* %5
%20 = bitcast [512 x i8]* %6 to i8*
%21 = bitcast [19 x i8]* %7 to i8*
br label %22
22: ; preds = %1
%23 = trunc i64 %17 to i32
%24 = load i8*, i8** %3
%25 = call i32 @zsnprintf(i8* %19, i32 %23, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %24)
store i32 %25, i32* %12
%26 = load i32, i32* %12
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %22
%29 = load i32, i32* @stderr
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 92, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%31 = load i32, i32* %12
store i32 %31, i32* %2
store i32 1, i32* %13
br label %124
32: ; preds = %22
br label %33
33: ; preds = %32
br label %34
34: ; preds = %33
%35 = load i32, i32* @O_CREAT
%36 = load i32, i32* @O_TRUNC
%37 = or i32 %35, %36
%38 = load i32, i32* @O_RDWR
%39 = or i32 %37, %38
%40 = call i32 @open(i8* %19, i32 %39, i32 420)
store i32 %40, i32* %11
br label %41
41: ; preds = %34
%42 = load i32, i32* %11
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %41
%45 = load i32, i32* @stderr
%46 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 94, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %2
store i32 1, i32* %13
br label %124
47: ; preds = %41
br label %48
48: ; preds = %47
br label %49
49: ; preds = %48
%50 = call %struct.fast_log_buf* @fast_log_create(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
store %struct.fast_log_buf* %50, %struct.fast_log_buf** %8
br label %51
51: ; preds = %49
%52 = load %struct.fast_log_buf*, %struct.fast_log_buf** %8
%53 = icmp eq %struct.fast_log_buf* %52, null
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = load i32, i32* @stderr
%56 = call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 96, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %2
store i32 1, i32* %13
br label %124
57: ; preds = %51
br label %58
58: ; preds = %57
br label %59
59: ; preds = %58
%60 = call %struct.fast_log_buf* @fast_log_create(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
store %struct.fast_log_buf* %60, %struct.fast_log_buf** %9
br label %61
61: ; preds = %59
%62 = load %struct.fast_log_buf*, %struct.fast_log_buf** %9
%63 = icmp eq %struct.fast_log_buf* %62, null
br i1 %63, label %64, label %67
64: ; preds = %61
%65 = load i32, i32* @stderr
%66 = call i32 @fprintf(i32 %65, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 98, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %2
store i32 1, i32* %13
br label %124
67: ; preds = %61
br label %68
68: ; preds = %67
br label %69
69: ; preds = %68
br label %70
70: ; preds = %69
%71 = load %struct.fast_log_buf*, %struct.fast_log_buf** %9
%72 = load %struct.fast_log_buf*, %struct.fast_log_buf** %8
%73 = load i32, i32* %11
%74 = call i32 @fast_log_dump(%struct.fast_log_buf* %71, %struct.fast_log_buf* %72, i32 %73)
store i32 %74, i32* %14
%75 = load i32, i32* %14
%76 = icmp ne i32 %75, 0
br i1 %76, label %77, label %81
77: ; preds = %70
%78 = load i32, i32* @stderr
%79 = call i32 @fprintf(i32 %78, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 99, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
%80 = load i32, i32* %14
store i32 %80, i32* %2
store i32 1, i32* %13
br label %124
81: ; preds = %70
br label %82
82: ; preds = %81
br label %83
83: ; preds = %82
br label %84
84: ; preds = %94, %83
%85 = load i32, i32* %11
%86 = call i32 @close(i32 %85)
store i32 %86, i32* %10
br label %87
87: ; preds = %84
%88 = load i32, i32* %10
%89 = icmp eq i32 %88, -1
br i1 %89, label %90, label %94
90: ; preds = %87
%91 = load i64, i64* @errno
%92 = load i64, i64* @EINTR
%93 = icmp eq i64 %91, %92
br label %94
94: ; preds = %90, %87
%95 = phi i1 [ false, %87 ], [ %93, %90 ]
br i1 %95, label %84, label %96
96: ; preds = %94
%97 = load %struct.fast_log_buf*, %struct.fast_log_buf** %9
%98 = call i32 @fast_log_destroy(%struct.fast_log_buf* %97)
%99 = load %struct.fast_log_buf*, %struct.fast_log_buf** %8
%100 = call i32 @fast_log_destroy(%struct.fast_log_buf* %99)
br label %101
101: ; preds = %96
%102 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%103 = call i64 @simple_io_read_whole_file_zt(i8* %19, i8* %102, i32 512)
%104 = icmp sle i64 %103, 0
br i1 %104, label %105, label %108
105: ; preds = %101
%106 = load i32, i32* @stderr
%107 = call i32 @fprintf(i32 %106, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 104, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %2
store i32 1, i32* %13
br label %124
108: ; preds = %101
br label %109
109: ; preds = %108
br label %110
110: ; preds = %109
br label %111
111: ; preds = %110
%112 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%113 = getelementptr inbounds [19 x i8], [19 x i8]* %7, i64 0, i64 0
%114 = call i32 @strcmp(i8* %112, i8* %113)
store i32 %114, i32* %15
%115 = load i32, i32* %15
%116 = icmp ne i32 %115, 0
br i1 %116, label %117, label %121
117: ; preds = %111
%118 = load i32, i32* @stderr
%119 = call i32 @fprintf(i32 %118, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 105, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
%120 = load i32, i32* %15
store i32 %120, i32* %2
store i32 1, i32* %13
br label %124
121: ; preds = %111
br label %122
122: ; preds = %121
br label %123
123: ; preds = %122
store i32 0, i32* %2
store i32 1, i32* %13
br label %124
124: ; preds = %123, %117, %105, %77, %64, %54, %44, %28
%125 = load i8*, i8** %4
%126 = load i32, i32* %2
ret i32 %126
}

LLVM IR (-O2):
%struct.fast_log_buf = type { i32 }
@PATH_MAX = global i32 0
@__const.dump_empty_buf.expected = [19 x i8] c"*** FASTLOG empty\0A\00"
@.str = [9 x i8] c"%s/empty\00"
@stderr = global i32 0
@.str.1 = [23 x i8] c"failed on line %d: %s\0A\00"
@.str.2 = [50 x i8] c"zsnprintf(fname, sizeof(fname), \22%s/empty\22, tdir)\00"
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@O_RDWR = global i32 0
@.str.3 = [3 x i8] c"fd\00"
@.str.4 = [8 x i8] c"scratch\00"
@.str.5 = [6 x i8] c"empty\00"
@.str.6 = [34 x i8] c"fast_log_dump(empty, scratch, fd)\00"
@errno = global i64 0
@EINTR = global i64 0
@.str.7 = [54 x i8] c"simple_io_read_whole_file_zt(fname, buf, sizeof(buf))\00"
@.str.8 = [22 x i8] c"strcmp(buf, expected)\00"
define i32 @dump_empty_buf(i8* %0) {
%2 = alloca [512 x i8]
%3 = load i32, i32* @PATH_MAX
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%7 = call i32 @zsnprintf(i8* %5, i32 %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 92, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
br label %62
12: ; preds = %1
%13 = load i32, i32* @O_CREAT
%14 = load i32, i32* @O_TRUNC
%15 = or i32 %14, %13
%16 = load i32, i32* @O_RDWR
%17 = or i32 %15, %16
%18 = call i32 @open(i8* %5, i32 %17, i32 420)
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %12
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 94, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %62
23: ; preds = %12
%24 = call %struct.fast_log_buf* @fast_log_create(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%25 = icmp eq %struct.fast_log_buf* %24, null
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 96, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %62
29: ; preds = %23
%30 = call %struct.fast_log_buf* @fast_log_create(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%31 = icmp eq %struct.fast_log_buf* %30, null
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 98, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %62
35: ; preds = %29
%36 = call i32 @fast_log_dump(%struct.fast_log_buf* %30, %struct.fast_log_buf* %24, i32 %18)
%37 = icmp eq i32 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %35
%39 = load i32, i32* @stderr
%40 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 99, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
br label %62
41: ; preds = %35, %41
%42 = call i32 @close(i32 %18)
%43 = icmp eq i32 %42, -1
%44 = load i64, i64* @errno
%45 = load i64, i64* @EINTR
%46 = icmp eq i64 %44, %45
%47 = select i1 %43, i1 %46, i1 false
br i1 %47, label %41, label %48
48: ; preds = %41
%49 = call i32 @fast_log_destroy(%struct.fast_log_buf* %30)
%50 = call i32 @fast_log_destroy(%struct.fast_log_buf* %24)
%51 = call i64 @simple_io_read_whole_file_zt(i8* %5, i8* %6, i32 512)
%52 = icmp slt i64 %51, 1
br i1 %52, label %53, label %56
53: ; preds = %48
%54 = load i32, i32* @stderr
%55 = call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 104, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.7, i64 0, i64 0))
br label %62
56: ; preds = %48
%57 = call i32 @strcmp(i8* %6, i8* dereferenceable(19) getelementptr inbounds ([19 x i8], [19 x i8]* @__const.dump_empty_buf.expected, i64 0, i64 0))
%58 = icmp eq i32 %57, 0
br i1 %58, label %62, label %59
59: ; preds = %56
%60 = load i32, i32* @stderr
%61 = call i32 @fprintf(i32 %60, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 105, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
br label %62
62: ; preds = %59, %56, %38, %9, %53, %32, %26, %20
%63 = phi i32 [ 1, %20 ], [ 1, %26 ], [ 1, %32 ], [ 1, %53 ], [ %7, %9 ], [ %36, %38 ], [ 0, %56 ], [ %57, %59 ]
ret i32 %63
}