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

/* Variables and functions */
int /*<<< orphan*/ closeFile(int /*<<< orphan*/ **);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, void *);
int /*<<< orphan*/ printFile(int /*<<< orphan*/ **, char const *);
int /*<<< orphan*/ printFn(int /*<<< orphan*/ **, char const *);
int /*<<< orphan*/ printLine(int /*<<< orphan*/ **, int);
int /*<<< orphan*/ updateLog(int /*<<< orphan*/ **);
void printOpt(int i, const char *str, const char *file, void *p, int a) {
  FILE *fp;
  updateLog(&fp);
  printFile(&fp, file);
  printFn(&fp, str);
  printLine(&fp, i);
  if (a == 1) {
    fprintf(fp, "free :%p ", p);
  } else {
    fprintf(fp, "new :%p ", p);
  }
  closeFile(&fp);
}


x86 assembly (clang, -O0):
<printOpt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
lea    -0x30(%rbp),%rdi
call   1080 <updateLog@plt>
mov    -0x18(%rbp),%rsi
lea    -0x30(%rbp),%rdi
call   1040 <printFile@plt>
mov    -0x10(%rbp),%rsi
lea    -0x30(%rbp),%rdi
call   1030 <printFn@plt>
mov    -0x4(%rbp),%esi
lea    -0x30(%rbp),%rdi
call   1070 <printLine@plt>
cmpl   $0x1,-0x24(%rbp)
jne    11cd <printOpt+0x6d>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe3d(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11e1 <printOpt+0x81>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe2e(%rip),%rsi
call   1050 <fprintf@plt>
lea    -0x30(%rbp),%rdi
call   1060 <closeFile@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printOpt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r15d
mov    %rcx,%r14
mov    %rdx,%rbp
mov    %rsi,%r12
mov    %edi,%r13d
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1080 <updateLog@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <printFile@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <printFn@plt>
mov    %rbx,%rdi
mov    %r13d,%esi
call   1070 <printLine@plt>
cmp    $0x1,%r15d
mov    (%rsp),%rdi
lea    0xe4b(%rip),%rax
lea    0xe4e(%rip),%rsi
cmove  %rax,%rsi
mov    %r14,%rdx
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1060 <closeFile@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"free :%p \00"
@.str.1 = [9 x i8] c"new :%p \00"
define void @printOpt(i32 %0, i8* %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32*
store i32 %0, i32* %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%12 = call i32 @updateLog(i32** %11)
%13 = load i8*, i8** %8
%14 = call i32 @printFile(i32** %11, i8* %13)
%15 = load i8*, i8** %7
%16 = call i32 @printFn(i32** %11, i8* %15)
%17 = load i32, i32* %6
%18 = call i32 @printLine(i32** %11, i32 %17)
%19 = load i32, i32* %10
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %25
21: ; preds = %5
%22 = load i32*, i32** %11
%23 = load i8*, i8** %9
%24 = call i32 @fprintf(i32* %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %23)
br label %29
25: ; preds = %5
%26 = load i32*, i32** %11
%27 = load i8*, i8** %9
%28 = call i32 @fprintf(i32* %26, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %27)
br label %29
29: ; preds = %25, %21
%30 = call i32 @closeFile(i32** %11)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"free :%p \00"
@.str.1 = [9 x i8] c"new :%p \00"
define void @printOpt(i32 %0, i8* %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca i32*
%7 = bitcast i32** %6 to i8*
%8 = call i32 @updateLog(i32** %6)
%9 = call i32 @printFile(i32** %6, i8* %2)
%10 = call i32 @printFn(i32** %6, i8* %1)
%11 = call i32 @printLine(i32** %6, i32 %0)
%12 = icmp eq i32 %4, 1
%13 = load i32*, i32** %6
%14 = select i1 %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0)
%15 = call i32 @fprintf(i32* %13, i8* %14, i8* %3)
%16 = call i32 @closeFile(i32** %6)
ret void
}