#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__ access(char *, int);
int /*<<< orphan*/ foo(char *, int);
int fopen(char *, int /*<<< orphan*/);
int /*<<< orphan*/ myfree(char *);
int /*<<< orphan*/ mysprintf(char *, char *);
char *hprofStartupp(char *outputFileName, char *ctx) {
  char fileName[1000];
  int fp;
  mysprintf(fileName, outputFileName);
  if (access(fileName, 1) == 0) {
    myfree(ctx);
    return 0;
  }
  fp = fopen(fileName, 0);
  if (fp == 0) {
    myfree(ctx);
    return 0;
  }
  foo(outputFileName, fp);
  return ctx;
}


x86 assembly (clang, -O0):
<hprofStartupp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x400(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <mysprintf@plt>
lea    -0x400(%rbp),%rdi
mov    $0x1,%esi
call   1040 <access@plt>
cmp    $0x0,%rax
jne    11a4 <hprofStartupp+0x54>
mov    -0x18(%rbp),%rdi
call   1070 <myfree@plt>
movq   $0x0,-0x8(%rbp)
jmp    11f2 <hprofStartupp+0xa2>
lea    -0x400(%rbp),%rdi
xor    %esi,%esi
call   1050 <fopen@plt>
mov    %eax,-0x404(%rbp)
cmpl   $0x0,-0x404(%rbp)
jne    11db <hprofStartupp+0x8b>
mov    -0x18(%rbp),%rdi
call   1070 <myfree@plt>
movq   $0x0,-0x8(%rbp)
jmp    11f2 <hprofStartupp+0xa2>
mov    -0x10(%rbp),%rdi
mov    -0x404(%rbp),%esi
call   1030 <foo@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hprofStartupp>:
push   %r15
push   %r14
push   %rbx
sub    $0x3f0,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <mysprintf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <access@plt>
test   %rax,%rax
je     119c <hprofStartupp+0x4c>
mov    %rsp,%rdi
xor    %esi,%esi
call   1050 <fopen@plt>
test   %eax,%eax
je     119c <hprofStartupp+0x4c>
mov    %r15,%rdi
mov    %eax,%esi
call   1030 <foo@plt>
jmp    11a7 <hprofStartupp+0x57>
mov    %r14,%rdi
call   1070 <myfree@plt>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x3f0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @hprofStartupp(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [1000 x i8]
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%9 = load i8*, i8** %4
%10 = call i32 @mysprintf(i8* %8, i8* %9)
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%12 = call i64 @access(i8* %11, i32 1)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i8*, i8** %5
%16 = call i32 @myfree(i8* %15)
store i8* null, i8** %3
br label %30
17: ; preds = %2
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%19 = call i32 @fopen(i8* %18, i32 0)
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = load i8*, i8** %5
%24 = call i32 @myfree(i8* %23)
store i8* null, i8** %3
br label %30
25: ; preds = %17
%26 = load i8*, i8** %4
%27 = load i32, i32* %7
%28 = call i32 @foo(i8* %26, i32 %27)
%29 = load i8*, i8** %5
store i8* %29, i8** %3
br label %30
30: ; preds = %25, %22, %14
%31 = load i8*, i8** %3
ret i8* %31
}

LLVM IR (-O2):
define i8* @hprofStartupp(i8* %0, i8* %1) {
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%5 = call i32 @mysprintf(i8* %4, i8* %0)
%6 = call i64 @access(i8* %4, i32 1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 @myfree(i8* %1)
br label %17
10: ; preds = %2
%11 = call i32 @fopen(i8* %4, i32 0)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @myfree(i8* %1)
br label %17
15: ; preds = %10
%16 = call i32 @foo(i8* %0, i32 %11)
br label %17
17: ; preds = %15, %13, %8
%18 = phi i8* [ null, %8 ], [ null, %13 ], [ %1, %15 ]
ret i8* %18
}