#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 /*<<< orphan*/ uint64_t;
typedef int uint32_t;
struct stat {
  int /*<<< orphan*/ st_size;
};

/* Variables and functions */
int EEXIST;
char *GetRealPath(char *);
int O_CREAT;
int O_RDWR;
int O_SYNC;
char *basename(char *);
char *dirname(char *);
int errno;
int /*<<< orphan*/ free(char *);
char *malloc(int);
int open(char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *);
int stat(char *, struct stat *);
char *strdup(char *);
char *strerror(int);
int strlen(char *);
char *write64Int(char *, int /*<<< orphan*/);
char *writeInt(char *, int);
char *writeString(char *, char *, int);
int TryCreateFile(char *fileName, char *md5, uint64_t size, char **buf,
                  uint32_t *bufLen) {
  int err = 0;
  char *errStr = "";
  char *filePath = GetRealPath(fileName);
  uint32_t totalLen = 0;
  char *writeIndex = NULL;
  uint64_t offset = 0;
  char tempFilePath[256] = {'\0'};
  char *_tempFilePath = strdup(filePath);
  char *_tempFileName = strdup(fileName);
  char *_tempFileDir = dirname(_tempFilePath);
  sprintf(tempFilePath, "%s/.%s_%s", _tempFileDir, md5,
          basename(_tempFileName));
  free(_tempFilePath);
  free(_tempFileName);
  struct stat st;
  printf("filepath: %s, tempFilePath: %s\n", filePath, tempFilePath);
  do {
    err = stat(filePath, &st);
    if (err == 0) {
      err = EEXIST;
      errStr = "file exists! can't upload";
      break;
    }
    err = stat(tempFilePath, &st);
    if (err == 0) {
      printf("find temp put file!!!, offset: %ldd\n", st.st_size);
      offset = st.st_size;
      break;
    }
    err = 0;
    int fd = open(tempFilePath, O_RDWR | O_CREAT | O_SYNC, 0644);
    if (fd < 0) {
      err = errno;
      errStr = strerror(err);
      printf("create file failed!!!");
      break;
    }
    offset = 0;
  } while (0);
  totalLen += 4 + 4 + strlen(errStr);
  if (err == 0) {
    totalLen += 8;
  }
  *buf = malloc(totalLen + 4);
  writeIndex = *buf;
  *bufLen = totalLen + 4;
  writeIndex = writeInt(writeIndex, totalLen);
  writeIndex = writeInt(writeIndex, err);
  writeIndex = writeString(writeIndex, errStr, strlen(errStr));
  if (err == 0) {
    writeIndex = write64Int(writeIndex, offset);
  }
  if (filePath != NULL) {
    free(filePath);
    filePath = NULL;
  }
  printf("try create file , err: %d, errstr: %s\n", err, errStr);
  return err;
}


x86 assembly (clang, -O0):
<TryCreateFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    0xe3c(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1110 <GetRealPath@plt>
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
movq   $0x0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
lea    -0x160(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1080 <memset@plt>
mov    -0x40(%rbp),%rdi
call   10f0 <strdup@plt>
mov    %rax,-0x168(%rbp)
mov    -0x8(%rbp),%rdi
call   10f0 <strdup@plt>
mov    %rax,-0x170(%rbp)
mov    -0x168(%rbp),%rdi
call   1070 <dirname@plt>
mov    %rax,-0x178(%rbp)
lea    -0x160(%rbp),%rax
mov    %rax,-0x1a0(%rbp)
mov    -0x178(%rbp),%rax
mov    %rax,-0x198(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x190(%rbp)
mov    -0x170(%rbp),%rdi
call   1090 <basename@plt>
mov    -0x1a0(%rbp),%rdi
mov    -0x198(%rbp),%rdx
mov    -0x190(%rbp),%rcx
mov    %rax,%r8
lea    0xd15(%rip),%rsi
call   10e0 <sprintf@plt>
mov    -0x168(%rbp),%rdi
call   1040 <free@plt>
mov    -0x170(%rbp),%rdi
call   1040 <free@plt>
mov    -0x40(%rbp),%rsi
lea    -0x160(%rbp),%rdx
lea    0xcf0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x40(%rbp),%rdi
lea    -0x180(%rbp),%rsi
call   10a0 <stat@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    135a <TryCreateFile+0x15a>
mov    0x2c83(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
lea    0xcd9(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    1414 <TryCreateFile+0x214>
lea    -0x160(%rbp),%rdi
lea    -0x180(%rbp),%rsi
call   10a0 <stat@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    139c <TryCreateFile+0x19c>
mov    -0x180(%rbp),%esi
lea    0xcbd(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x180(%rbp),%eax
mov    %eax,-0x54(%rbp)
jmp    1414 <TryCreateFile+0x214>
movl   $0x0,-0x2c(%rbp)
lea    -0x160(%rbp),%rdi
mov    0x2c2f(%rip),%rax
mov    (%rax),%esi
mov    0x2c3e(%rip),%rax
or     (%rax),%esi
mov    0x2c15(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
call   10d0 <open@plt>
mov    %eax,-0x184(%rbp)
cmpl   $0x0,-0x184(%rbp)
jge    140d <TryCreateFile+0x20d>
mov    0x2bd7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
call   1100 <strerror@plt>
mov    %rax,-0x38(%rbp)
lea    0xc68(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1414 <TryCreateFile+0x214>
movl   $0x0,-0x54(%rbp)
mov    -0x38(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x8,%eax
add    -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    1439 <TryCreateFile+0x239>
mov    -0x44(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%edi
add    $0x4,%edi
call   10c0 <malloc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    -0x44(%rbp),%ecx
add    $0x4,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x50(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   1030 <writeInt@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1030 <writeInt@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x1b0(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x1a8(%rbp)
mov    -0x38(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x1b0(%rbp),%rdi
mov    -0x1a8(%rbp),%rsi
mov    %eax,%edx
call   10b0 <writeString@plt>
mov    %rax,-0x50(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    14d7 <TryCreateFile+0x2d7>
mov    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%esi
call   1120 <write64Int@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     14f3 <TryCreateFile+0x2f3>
mov    -0x40(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x40(%rbp)
mov    -0x2c(%rbp),%esi
mov    -0x38(%rbp),%rdx
lea    0xb7e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TryCreateFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    %r8,0x18(%rsp)
mov    %rcx,0x10(%rsp)
mov    %rsi,%r12
mov    %rdi,%rbp
call   1100 <GetRealPath@plt>
mov    %rax,%r13
xorps  %xmm0,%xmm0
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
mov    %rax,%rdi
call   10e0 <strdup@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   10e0 <strdup@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1070 <dirname@plt>
mov    %rax,%r14
mov    %rbp,%rdi
call   1080 <basename@plt>
lea    0xd46(%rip),%rsi
lea    0x20(%rsp),%r15
mov    %r15,%rdi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %rax,%r8
call   10d0 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
mov    %rbp,%rdi
call   1040 <free@plt>
lea    0xd23(%rip),%rdi
xor    %r12d,%r12d
mov    %r13,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %r13,%rdi
call   1090 <stat@plt>
test   %eax,%eax
je     1358 <TryCreateFile+0x168>
lea    0x20(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1090 <stat@plt>
test   %eax,%eax
je     136b <TryCreateFile+0x17b>
mov    0x2cbe(%rip),%rax
mov    0x2ccf(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2ca4(%rip),%rax
or     (%rax),%esi
lea    0x20(%rsp),%rdi
mov    $0x1a4,%edx
call   10c0 <open@plt>
test   %eax,%eax
js     138d <TryCreateFile+0x19d>
lea    0xd18(%rip),%r14
xor    %r12d,%r12d
xor    %r15d,%r15d
jmp    13b3 <TryCreateFile+0x1c3>
mov    0x2c69(%rip),%rax
mov    (%rax),%r15d
lea    0xcc1(%rip),%r14
jmp    13b3 <TryCreateFile+0x1c3>
mov    0x8(%rsp),%r12d
lea    0xccd(%rip),%rdi
xor    %r15d,%r15d
mov    %r12d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xcdd(%rip),%r14
jmp    13b3 <TryCreateFile+0x1c3>
mov    0x2c2c(%rip),%rax
mov    (%rax),%r15d
mov    %r15d,%edi
call   10f0 <strerror@plt>
mov    %rax,%r14
lea    0xcc0(%rip),%rdi
xor    %r12d,%r12d
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
xor    %ecx,%ecx
test   %r15d,%r15d
sete   %cl
lea    (%rax,%rcx,8),%ebx
add    $0x8,%ebx
lea    (%rax,%rcx,8),%ebp
add    $0xc,%ebp
mov    %ebp,%edi
call   10b0 <malloc@plt>
mov    0x10(%rsp),%rcx
mov    %rax,(%rcx)
mov    0x18(%rsp),%rcx
mov    %ebp,(%rcx)
mov    %rax,%rdi
mov    %ebx,%esi
call   1030 <writeInt@plt>
mov    %rax,%rdi
mov    %r15d,%esi
call   1030 <writeInt@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   10a0 <writeString@plt>
test   %r15d,%r15d
jne    1422 <TryCreateFile+0x232>
mov    %rax,%rdi
mov    %r12d,%esi
call   1110 <write64Int@plt>
test   %r13,%r13
je     142f <TryCreateFile+0x23f>
mov    %r13,%rdi
call   1040 <free@plt>
lea    0xc49(%rip),%rdi
mov    %r15d,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15d,%eax
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [1 x i8] zeroinitializer
@.str.1 = [10 x i8] c"%s/.%s_%s\00"
@.str.2 = [32 x i8] c"filepath: %s, tempFilePath: %s\0A\00"
@EEXIST = global i32 0
@.str.3 = [26 x i8] c"file exists! can't upload\00"
@.str.4 = [37 x i8] c"find temp put file!!!, offset: %ldd\0A\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_SYNC = global i32 0
@errno = global i32 0
@.str.5 = [22 x i8] c"create file failed!!!\00"
@.str.6 = [39 x i8] c"try create file , err: %d, errstr: %s\0A\00"
define i32 @TryCreateFile(i8* %0, i8* %1, i32 %2, i8** %3, i32* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i32
%17 = alloca [256 x i8]
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i8*
%21 = alloca %struct.stat
%22 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8** %3, i8*** %9
store i32* %4, i32** %10
store i32 0, i32* %11
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %12
%23 = load i8*, i8** %6
%24 = call i8* @GetRealPath(i8* %23)
store i8* %24, i8** %13
store i32 0, i32* %14
store i8* null, i8** %15
store i32 0, i32* %16
%25 = bitcast [256 x i8]* %17 to i8*
%26 = load i8*, i8** %13
%27 = call i8* @strdup(i8* %26)
store i8* %27, i8** %18
%28 = load i8*, i8** %6
%29 = call i8* @strdup(i8* %28)
store i8* %29, i8** %19
%30 = load i8*, i8** %18
%31 = call i8* @dirname(i8* %30)
store i8* %31, i8** %20
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%33 = load i8*, i8** %20
%34 = load i8*, i8** %7
%35 = load i8*, i8** %19
%36 = call i8* @basename(i8* %35)
%37 = call i32 @sprintf(i8* %32, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %33, i8* %34, i8* %36)
%38 = load i8*, i8** %18
%39 = call i32 @free(i8* %38)
%40 = load i8*, i8** %19
%41 = call i32 @free(i8* %40)
%42 = load i8*, i8** %13
%43 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %42, i8* %43)
br label %45
45: ; preds = %5
%46 = load i8*, i8** %13
%47 = call i32 @stat(i8* %46, %struct.stat* %21)
store i32 %47, i32* %11
%48 = load i32, i32* %11
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %45
%51 = load i32, i32* @EEXIST
store i32 %51, i32* %11
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8** %12
br label %79
52: ; preds = %45
%53 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%54 = call i32 @stat(i8* %53, %struct.stat* %21)
store i32 %54, i32* %11
%55 = load i32, i32* %11
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %63
57: ; preds = %52
%58 = getelementptr inbounds %struct.stat, %struct.stat* %21, i32 0, i32 0
%59 = load i32, i32* %58
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %59)
%61 = getelementptr inbounds %struct.stat, %struct.stat* %21, i32 0, i32 0
%62 = load i32, i32* %61
store i32 %62, i32* %16
br label %79
63: ; preds = %52
store i32 0, i32* %11
%64 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%65 = load i32, i32* @O_RDWR
%66 = load i32, i32* @O_CREAT
%67 = or i32 %65, %66
%68 = load i32, i32* @O_SYNC
%69 = or i32 %67, %68
%70 = call i32 @open(i8* %64, i32 %69, i32 420)
store i32 %70, i32* %22
%71 = load i32, i32* %22
%72 = icmp slt i32 %71, 0
br i1 %72, label %73, label %78
73: ; preds = %63
%74 = load i32, i32* @errno
store i32 %74, i32* %11
%75 = load i32, i32* %11
%76 = call i8* @strerror(i32 %75)
store i8* %76, i8** %12
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
br label %79
78: ; preds = %63
store i32 0, i32* %16
br label %79
79: ; preds = %78, %73, %57, %50
%80 = load i8*, i8** %12
%81 = call i32 @strlen(i8* %80)
%82 = add nsw i32 8, %81
%83 = load i32, i32* %14
%84 = add nsw i32 %83, %82
store i32 %84, i32* %14
%85 = load i32, i32* %11
%86 = icmp eq i32 %85, 0
br i1 %86, label %87, label %90
87: ; preds = %79
%88 = load i32, i32* %14
%89 = add nsw i32 %88, 8
store i32 %89, i32* %14
br label %90
90: ; preds = %87, %79
%91 = load i32, i32* %14
%92 = add nsw i32 %91, 4
%93 = call i8* @malloc(i32 %92)
%94 = load i8**, i8*** %9
store i8* %93, i8** %94
%95 = load i8**, i8*** %9
%96 = load i8*, i8** %95
store i8* %96, i8** %15
%97 = load i32, i32* %14
%98 = add nsw i32 %97, 4
%99 = load i32*, i32** %10
store i32 %98, i32* %99
%100 = load i8*, i8** %15
%101 = load i32, i32* %14
%102 = call i8* @writeInt(i8* %100, i32 %101)
store i8* %102, i8** %15
%103 = load i8*, i8** %15
%104 = load i32, i32* %11
%105 = call i8* @writeInt(i8* %103, i32 %104)
store i8* %105, i8** %15
%106 = load i8*, i8** %15
%107 = load i8*, i8** %12
%108 = load i8*, i8** %12
%109 = call i32 @strlen(i8* %108)
%110 = call i8* @writeString(i8* %106, i8* %107, i32 %109)
store i8* %110, i8** %15
%111 = load i32, i32* %11
%112 = icmp eq i32 %111, 0
br i1 %112, label %113, label %117
113: ; preds = %90
%114 = load i8*, i8** %15
%115 = load i32, i32* %16
%116 = call i8* @write64Int(i8* %114, i32 %115)
store i8* %116, i8** %15
br label %117
117: ; preds = %113, %90
%118 = load i8*, i8** %13
%119 = icmp ne i8* %118, null
br i1 %119, label %120, label %123
120: ; preds = %117
%121 = load i8*, i8** %13
%122 = call i32 @free(i8* %121)
store i8* null, i8** %13
br label %123
123: ; preds = %120, %117
%124 = load i32, i32* %11
%125 = load i8*, i8** %12
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), i32 %124, i8* %125)
%127 = load i32, i32* %11
ret i32 %127
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [1 x i8] zeroinitializer
@.str.1 = [10 x i8] c"%s/.%s_%s\00"
@.str.2 = [32 x i8] c"filepath: %s, tempFilePath: %s\0A\00"
@EEXIST = global i32 0
@.str.3 = [26 x i8] c"file exists! can't upload\00"
@.str.4 = [37 x i8] c"find temp put file!!!, offset: %ldd\0A\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_SYNC = global i32 0
@errno = global i32 0
@.str.5 = [22 x i8] c"create file failed!!!\00"
@.str.6 = [39 x i8] c"try create file , err: %d, errstr: %s\0A\00"
define i32 @TryCreateFile(i8* %0, i8* %1, i32 %2, i8** nocapture writeonly %3, i32* nocapture writeonly %4) {
%6 = alloca [256 x i8]
%7 = alloca %struct.stat
%8 = tail call i8* @GetRealPath(i8* %0)
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%10 = tail call i8* @strdup(i8* %8)
%11 = tail call i8* @strdup(i8* %0)
%12 = tail call i8* @dirname(i8* %10)
%13 = tail call i8* @basename(i8* %11)
%14 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %12, i8* %1, i8* %13)
%15 = tail call i32 @free(i8* %10)
%16 = tail call i32 @free(i8* %11)
%17 = bitcast %struct.stat* %7 to i8*
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %8, i8* %9)
%19 = call i32 @stat(i8* %8, %struct.stat* %7)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %5
%22 = load i32, i32* @EEXIST
br label %42
23: ; preds = %5
%24 = call i32 @stat(i8* %9, %struct.stat* %7)
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = getelementptr inbounds %struct.stat, %struct.stat* %7, i64 0, i32 0
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %28)
br label %42
30: ; preds = %23
%31 = load i32, i32* @O_RDWR
%32 = load i32, i32* @O_CREAT
%33 = or i32 %32, %31
%34 = load i32, i32* @O_SYNC
%35 = or i32 %33, %34
%36 = call i32 @open(i8* %9, i32 %35, i32 420)
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %30
%39 = load i32, i32* @errno
%40 = call i8* @strerror(i32 %39)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
br label %42
42: ; preds = %38, %30, %26, %21
%43 = phi i32 [ 0, %21 ], [ %28, %26 ], [ 0, %30 ], [ 0, %38 ]
%44 = phi i8* [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), %21 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %26 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %30 ], [ %40, %38 ]
%45 = phi i32 [ %22, %21 ], [ 0, %26 ], [ 0, %30 ], [ %39, %38 ]
%46 = call i32 @strlen(i8* %44)
%47 = icmp eq i32 %45, 0
%48 = select i1 %47, i32 16, i32 8
%49 = add nsw i32 %48, %46
%50 = add nsw i32 %49, 4
%51 = call i8* @malloc(i32 %50)
store i8* %51, i8** %3
store i32 %50, i32* %4
%52 = call i8* @writeInt(i8* %51, i32 %49)
%53 = call i8* @writeInt(i8* %52, i32 %45)
%54 = call i32 @strlen(i8* %44)
%55 = call i8* @writeString(i8* %53, i8* %44, i32 %54)
br i1 %47, label %56, label %58
56: ; preds = %42
%57 = call i8* @write64Int(i8* %55, i32 %43)
br label %58
58: ; preds = %56, %42
%59 = icmp eq i8* %8, null
br i1 %59, label %62, label %60
60: ; preds = %58
%61 = call i32 @free(i8* %8)
br label %62
62: ; preds = %60, %58
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), i32 %45, i8* %44)
ret i32 %45
}