#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 stat {
  int st_mode;
};

/* Variables and functions */
int O_DIRECTORY;
int O_RDONLY;
#define S_IFDIR 129
int S_IFMT;
#define S_IFREG 128
char *dirname(char *);
int /*<<< orphan*/ logger(int, char *, ...);
int open(char *, int);
int stat(char *, struct stat *);
int /*<<< orphan*/ sync();
scalar_t__ syncFileAndClose(int);
scalar_t__ syncFsAndClose(int);
int syncToDisk(char *path, int entireFilesystem) {
  int r, mode;
  struct stat path_stat;
  if (!path) {
    logger(3, "No path provided. Sync all buffered modifications.\n");
    sync();
    return 0;
  }
  r = stat(path, &path_stat);
  if (r != 0)
    logger(1, "Can't stat the file '%s'.\n", path);
  mode = path_stat.st_mode & S_IFMT;
  switch (mode) {
  case S_IFREG:
    if ((r = open(path, O_RDONLY)) == -1)
      logger(1, "Can't open regular file.");
    break;
  case S_IFDIR:
    if ((r = open(path, O_RDONLY | O_DIRECTORY)) == -1)
      logger(1, "Can't open directory file.");
    break;
  default:
    logger(1, "Unsupported file type.");
  }
  if (entireFilesystem) {
    logger(3, "Sync file-system determined by '%s'.\n", path);
    if (syncFsAndClose(r) != 0)
      logger(1, "Failed to sync filesystem.\n");
  } else {
    logger(3, "Sync file %s to disk.\n", path);
    if (syncFileAndClose(r) != 0)
      logger(1, "Failed to sync file %s.\n", path);
    logger(3, "Sync parent directory of file '%s' to disk.\n", path);
    logger(4, "Parent directory of '%s' is '%s'.\n", path, dirname(path));
    if ((r = open(dirname(path), O_RDONLY | O_DIRECTORY)) == -1)
      logger(1, "Can't open parent directory.");
    if (syncFileAndClose(r) != 0)
      logger(1, "Failed to sync.");
  }
  return 0;
}


x86 assembly (clang, -O0):
<syncToDisk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b0 <syncToDisk+0x40>
mov    $0x3,%edi
lea    0xe6a(%rip),%rsi
mov    $0x0,%al
call   1050 <logger@plt>
mov    $0x0,%al
call   1060 <sync@plt>
movl   $0x0,-0x4(%rbp)
jmp    13e3 <syncToDisk+0x273>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <stat@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     11e1 <syncToDisk+0x71>
mov    -0x10(%rbp),%rdx
mov    $0x1,%edi
lea    0xe5a(%rip),%rsi
mov    $0x0,%al
call   1050 <logger@plt>
mov    -0x20(%rbp),%eax
mov    0x2ded(%rip),%rcx
mov    (%rcx),%ecx
and    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x80,%eax
je     121b <syncToDisk+0xab>
jmp    1208 <syncToDisk+0x98>
mov    -0x24(%rbp),%eax
sub    $0x81,%eax
je     1251 <syncToDisk+0xe1>
jmp    1290 <syncToDisk+0x120>
mov    -0x10(%rbp),%rdi
mov    0x2dc2(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    124c <syncToDisk+0xdc>
mov    $0x1,%edi
lea    0xe0a(%rip),%rsi
mov    $0x0,%al
call   1050 <logger@plt>
jmp    12a3 <syncToDisk+0x133>
mov    -0x10(%rbp),%rdi
mov    0x2d8c(%rip),%rax
mov    (%rax),%esi
mov    0x2d6b(%rip),%rax
or     (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    128b <syncToDisk+0x11b>
mov    $0x1,%edi
lea    0xde4(%rip),%rsi
mov    $0x0,%al
call   1050 <logger@plt>
jmp    12a3 <syncToDisk+0x133>
mov    $0x1,%edi
lea    0xde7(%rip),%rsi
mov    $0x0,%al
call   1050 <logger@plt>
cmpl   $0x0,-0x14(%rbp)
je     12ee <syncToDisk+0x17e>
mov    -0x10(%rbp),%rdx
mov    $0x3,%edi
lea    0xddd(%rip),%rsi
mov    $0x0,%al
call   1050 <logger@plt>
mov    -0x18(%rbp),%edi
call   1090 <syncFsAndClose@plt>
cmp    $0x0,%rax
je     12e9 <syncToDisk+0x179>
mov    $0x1,%edi
lea    0xdde(%rip),%rsi
mov    $0x0,%al
call   1050 <logger@plt>
jmp    13dc <syncToDisk+0x26c>
mov    -0x10(%rbp),%rdx
mov    $0x3,%edi
lea    0xdde(%rip),%rsi
mov    $0x0,%al
call   1050 <logger@plt>
mov    -0x18(%rbp),%edi
call   1070 <syncFileAndClose@plt>
cmp    $0x0,%rax
je     132e <syncToDisk+0x1be>
mov    -0x10(%rbp),%rdx
mov    $0x1,%edi
lea    0xdcc(%rip),%rsi
mov    $0x0,%al
call   1050 <logger@plt>
mov    -0x10(%rbp),%rdx
mov    $0x3,%edi
lea    0xdce(%rip),%rsi
mov    $0x0,%al
call   1050 <logger@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <dirname@plt>
mov    -0x30(%rbp),%rdx
mov    %rax,%rcx
mov    $0x4,%edi
lea    0xdd0(%rip),%rsi
mov    $0x0,%al
call   1050 <logger@plt>
mov    -0x10(%rbp),%rdi
call   1030 <dirname@plt>
mov    %rax,%rdi
mov    0x2c65(%rip),%rax
mov    (%rax),%esi
mov    0x2c44(%rip),%rax
or     (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    13b2 <syncToDisk+0x242>
mov    $0x1,%edi
lea    0xdb1(%rip),%rsi
mov    $0x0,%al
call   1050 <logger@plt>
mov    -0x18(%rbp),%edi
call   1070 <syncFileAndClose@plt>
cmp    $0x0,%rax
je     13d7 <syncToDisk+0x267>
mov    $0x1,%edi
lea    0xda9(%rip),%rsi
mov    $0x0,%al
call   1050 <logger@plt>
jmp    13dc <syncToDisk+0x26c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<syncToDisk>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
test   %rdi,%rdi
je     11ea <syncToDisk+0x7a>
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
call   1040 <stat@plt>
mov    %eax,%ebp
test   %eax,%eax
je     11a9 <syncToDisk+0x39>
lea    0xe9a(%rip),%rsi
mov    $0x1,%edi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <logger@plt>
mov    0x2e28(%rip),%rax
mov    (%rax),%eax
and    0x8(%rsp),%eax
cmp    $0x81,%eax
je     1209 <syncToDisk+0x99>
cmp    $0x80,%eax
jne    1238 <syncToDisk+0xc8>
mov    0x2e1d(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1080 <open@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    124b <syncToDisk+0xdb>
mov    $0xffffffff,%ebp
lea    0xe67(%rip),%rsi
jmp    123f <syncToDisk+0xcf>
lea    0xe0f(%rip),%rsi
mov    $0x3,%edi
xor    %eax,%eax
call   1050 <logger@plt>
xor    %eax,%eax
call   1060 <sync@plt>
jmp    134c <syncToDisk+0x1dc>
mov    0x2dd8(%rip),%rax
mov    0x2db9(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %rbx,%rdi
call   1080 <open@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    124b <syncToDisk+0xdb>
mov    $0xffffffff,%ebp
lea    0xe32(%rip),%rsi
jmp    123f <syncToDisk+0xcf>
lea    0xe44(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1050 <logger@plt>
test   %r14d,%r14d
je     1282 <syncToDisk+0x112>
lea    0xe43(%rip),%rsi
mov    $0x3,%edi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <logger@plt>
mov    %ebp,%edi
call   1090 <syncFsAndClose@plt>
test   %rax,%rax
je     134c <syncToDisk+0x1dc>
lea    0xe43(%rip),%rsi
jmp    1340 <syncToDisk+0x1d0>
lea    0xe53(%rip),%rsi
mov    $0x3,%edi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <logger@plt>
mov    %ebp,%edi
call   1070 <syncFileAndClose@plt>
test   %rax,%rax
je     12ba <syncToDisk+0x14a>
lea    0xe48(%rip),%rsi
mov    $0x1,%edi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <logger@plt>
lea    0xe4b(%rip),%rsi
mov    $0x3,%edi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <logger@plt>
mov    %rbx,%rdi
call   1030 <dirname@plt>
lea    0xe5a(%rip),%rsi
mov    $0x4,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1050 <logger@plt>
mov    %rbx,%rdi
call   1030 <dirname@plt>
mov    0x2ce8(%rip),%rcx
mov    0x2cc9(%rip),%rdx
mov    (%rdx),%esi
or     (%rcx),%esi
mov    %rax,%rdi
call   1080 <open@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    132d <syncToDisk+0x1bd>
lea    0xe3b(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1050 <logger@plt>
mov    %ebx,%edi
call   1070 <syncFileAndClose@plt>
test   %rax,%rax
je     134c <syncToDisk+0x1dc>
lea    0xe39(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1050 <logger@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [52 x i8] c"No path provided. Sync all buffered modifications.\0A\00"
@.str.1 = [27 x i8] c"Can't stat the file '%s'.\0A\00"
@S_IFMT = global i32 0
@O_RDONLY = global i32 0
@.str.2 = [25 x i8] c"Can't open regular file.\00"
@O_DIRECTORY = global i32 0
@.str.3 = [27 x i8] c"Can't open directory file.\00"
@.str.4 = [23 x i8] c"Unsupported file type.\00"
@.str.5 = [38 x i8] c"Sync file-system determined by '%s'.\0A\00"
@.str.6 = [28 x i8] c"Failed to sync filesystem.\0A\00"
@.str.7 = [23 x i8] c"Sync file %s to disk.\0A\00"
@.str.8 = [25 x i8] c"Failed to sync file %s.\0A\00"
@.str.9 = [45 x i8] c"Sync parent directory of file '%s' to disk.\0A\00"
@.str.10 = [35 x i8] c"Parent directory of '%s' is '%s'.\0A\00"
@.str.11 = [29 x i8] c"Can't open parent directory.\00"
@.str.12 = [16 x i8] c"Failed to sync.\00"
define i32 @syncToDisk(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.stat
store i8* %0, i8** %4
store i32 %1, i32* %5
%9 = load i8*, i8** %4
%10 = icmp ne i8* %9, null
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = call i32 (i32, i8*, ...) @logger(i32 3, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (...) @sync()
store i32 0, i32* %3
br label %93
14: ; preds = %2
%15 = load i8*, i8** %4
%16 = call i32 @stat(i8* %15, %struct.stat* %8)
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = load i8*, i8** %4
%21 = call i32 (i32, i8*, ...) @logger(i32 1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %19, %14
%23 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%24 = load i32, i32* %23
%25 = load i32, i32* @S_IFMT
%26 = and i32 %24, %25
store i32 %26, i32* %7
%27 = load i32, i32* %7
switch i32 %27, label %46 [
i32 128, label %28
i32 129, label %36
]
28: ; preds = %22
%29 = load i8*, i8** %4
%30 = load i32, i32* @O_RDONLY
%31 = call i32 @open(i8* %29, i32 %30)
store i32 %31, i32* %6
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %35
33: ; preds = %28
%34 = call i32 (i32, i8*, ...) @logger(i32 1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %35
35: ; preds = %33, %28
br label %48
36: ; preds = %22
%37 = load i8*, i8** %4
%38 = load i32, i32* @O_RDONLY
%39 = load i32, i32* @O_DIRECTORY
%40 = or i32 %38, %39
%41 = call i32 @open(i8* %37, i32 %40)
store i32 %41, i32* %6
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %45
43: ; preds = %36
%44 = call i32 (i32, i8*, ...) @logger(i32 1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %45
45: ; preds = %43, %36
br label %48
46: ; preds = %22
%47 = call i32 (i32, i8*, ...) @logger(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %48
48: ; preds = %46, %45, %35
%49 = load i32, i32* %5
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %60
51: ; preds = %48
%52 = load i8*, i8** %4
%53 = call i32 (i32, i8*, ...) @logger(i32 3, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8* %52)
%54 = load i32, i32* %6
%55 = call i64 @syncFsAndClose(i32 %54)
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %51
%58 = call i32 (i32, i8*, ...) @logger(i32 1, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
br label %59
59: ; preds = %57, %51
br label %92
60: ; preds = %48
%61 = load i8*, i8** %4
%62 = call i32 (i32, i8*, ...) @logger(i32 3, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* %61)
%63 = load i32, i32* %6
%64 = call i64 @syncFileAndClose(i32 %63)
%65 = icmp ne i64 %64, 0
br i1 %65, label %66, label %69
66: ; preds = %60
%67 = load i8*, i8** %4
%68 = call i32 (i32, i8*, ...) @logger(i32 1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %67)
br label %69
69: ; preds = %66, %60
%70 = load i8*, i8** %4
%71 = call i32 (i32, i8*, ...) @logger(i32 3, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0), i8* %70)
%72 = load i8*, i8** %4
%73 = load i8*, i8** %4
%74 = call i8* @dirname(i8* %73)
%75 = call i32 (i32, i8*, ...) @logger(i32 4, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0), i8* %72, i8* %74)
%76 = load i8*, i8** %4
%77 = call i8* @dirname(i8* %76)
%78 = load i32, i32* @O_RDONLY
%79 = load i32, i32* @O_DIRECTORY
%80 = or i32 %78, %79
%81 = call i32 @open(i8* %77, i32 %80)
store i32 %81, i32* %6
%82 = icmp eq i32 %81, -1
br i1 %82, label %83, label %85
83: ; preds = %69
%84 = call i32 (i32, i8*, ...) @logger(i32 1, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0))
br label %85
85: ; preds = %83, %69
%86 = load i32, i32* %6
%87 = call i64 @syncFileAndClose(i32 %86)
%88 = icmp ne i64 %87, 0
br i1 %88, label %89, label %91
89: ; preds = %85
%90 = call i32 (i32, i8*, ...) @logger(i32 1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0))
br label %91
91: ; preds = %89, %85
br label %92
92: ; preds = %91, %59
store i32 0, i32* %3
br label %93
93: ; preds = %92, %11
%94 = load i32, i32* %3
ret i32 %94
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [52 x i8] c"No path provided. Sync all buffered modifications.\0A\00"
@.str.1 = [27 x i8] c"Can't stat the file '%s'.\0A\00"
@S_IFMT = global i32 0
@O_RDONLY = global i32 0
@.str.2 = [25 x i8] c"Can't open regular file.\00"
@O_DIRECTORY = global i32 0
@.str.3 = [27 x i8] c"Can't open directory file.\00"
@.str.4 = [23 x i8] c"Unsupported file type.\00"
@.str.5 = [38 x i8] c"Sync file-system determined by '%s'.\0A\00"
@.str.6 = [28 x i8] c"Failed to sync filesystem.\0A\00"
@.str.7 = [23 x i8] c"Sync file %s to disk.\0A\00"
@.str.8 = [25 x i8] c"Failed to sync file %s.\0A\00"
@.str.9 = [45 x i8] c"Sync parent directory of file '%s' to disk.\0A\00"
@.str.10 = [35 x i8] c"Parent directory of '%s' is '%s'.\0A\00"
@.str.11 = [29 x i8] c"Can't open parent directory.\00"
@.str.12 = [16 x i8] c"Failed to sync.\00"
define i32 @syncToDisk(i8* %0, i32 %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = icmp eq i8* %0, null
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 (i32, i8*, ...) @logger(i32 3, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 (...) @sync()
br label %65
9: ; preds = %2
%10 = call i32 @stat(i8* %0, %struct.stat* %3)
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 (i32, i8*, ...) @logger(i32 1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %14
14: ; preds = %12, %9
%15 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%16 = load i32, i32* %15
%17 = load i32, i32* @S_IFMT
%18 = and i32 %17, %16
switch i32 %18, label %29 [
i32 128, label %19
i32 129, label %23
]
19: ; preds = %14
%20 = load i32, i32* @O_RDONLY
%21 = tail call i32 @open(i8* %0, i32 %20)
%22 = icmp eq i32 %21, -1
br i1 %22, label %29, label %33
23: ; preds = %14
%24 = load i32, i32* @O_RDONLY
%25 = load i32, i32* @O_DIRECTORY
%26 = or i32 %25, %24
%27 = tail call i32 @open(i8* %0, i32 %26)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %33
29: ; preds = %14, %23, %19
%30 = phi i8* [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), %19 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), %23 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), %14 ]
%31 = phi i32 [ -1, %19 ], [ -1, %23 ], [ %10, %14 ]
%32 = tail call i32 (i32, i8*, ...) @logger(i32 1, i8* %30)
br label %33
33: ; preds = %29, %23, %19
%34 = phi i32 [ %27, %23 ], [ %21, %19 ], [ %31, %29 ]
%35 = icmp eq i32 %1, 0
br i1 %35, label %42, label %36
36: ; preds = %33
%37 = tail call i32 (i32, i8*, ...) @logger(i32 3, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8* %0)
%38 = tail call i64 @syncFsAndClose(i32 %34)
%39 = icmp eq i64 %38, 0
br i1 %39, label %65, label %40
40: ; preds = %36
%41 = tail call i32 (i32, i8*, ...) @logger(i32 1, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
br label %65
42: ; preds = %33
%43 = tail call i32 (i32, i8*, ...) @logger(i32 3, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* %0)
%44 = tail call i64 @syncFileAndClose(i32 %34)
%45 = icmp eq i64 %44, 0
br i1 %45, label %48, label %46
46: ; preds = %42
%47 = tail call i32 (i32, i8*, ...) @logger(i32 1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %0)
br label %48
48: ; preds = %46, %42
%49 = tail call i32 (i32, i8*, ...) @logger(i32 3, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0), i8* %0)
%50 = tail call i8* @dirname(i8* %0)
%51 = tail call i32 (i32, i8*, ...) @logger(i32 4, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0), i8* %0, i8* %50)
%52 = tail call i8* @dirname(i8* %0)
%53 = load i32, i32* @O_RDONLY
%54 = load i32, i32* @O_DIRECTORY
%55 = or i32 %54, %53
%56 = tail call i32 @open(i8* %52, i32 %55)
%57 = icmp eq i32 %56, -1
br i1 %57, label %58, label %60
58: ; preds = %48
%59 = tail call i32 (i32, i8*, ...) @logger(i32 1, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0))
br label %60
60: ; preds = %58, %48
%61 = tail call i64 @syncFileAndClose(i32 %56)
%62 = icmp eq i64 %61, 0
br i1 %62, label %65, label %63
63: ; preds = %60
%64 = tail call i32 (i32, i8*, ...) @logger(i32 1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0))
br label %65
65: ; preds = %40, %36, %63, %60, %6
ret i32 0
}