#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*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, unsigned long,
                           unsigned int, char const *);
void perf_map_write_entry(FILE *file, const void *code_addr,
                          unsigned int code_size, const char *entry,
                          int flush) {
  if (file) {
    fprintf(file, "%lx %x %s\n", (unsigned long)code_addr, code_size, entry);
    if (flush)
      fflush(file);
  }
}


x86 assembly (clang, -O0):
<perf_map_write_entry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1179 <perf_map_write_entry+0x59>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%r8
lea    0xea4(%rip),%rsi
call   1030 <fprintf@plt>
cmpl   $0x0,-0x24(%rbp)
je     1174 <perf_map_write_entry+0x54>
mov    -0x8(%rbp),%rdi
call   1040 <fflush@plt>
jmp    1179 <perf_map_write_entry+0x59>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<perf_map_write_entry>:
push   %rbp
push   %rbx
push   %rax
test   %rdi,%rdi
je     1154 <perf_map_write_entry+0x34>
mov    %r8d,%ebp
mov    %rcx,%r8
mov    %edx,%ecx
mov    %rsi,%rdx
mov    %rdi,%rbx
lea    0xec3(%rip),%rsi
call   1030 <fprintf@plt>
test   %ebp,%ebp
je     1154 <perf_map_write_entry+0x34>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <fflush@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%lx %x %s\0A\00"
define void @perf_map_write_entry(i32* %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
store i32* %0, i32** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%11 = load i32*, i32** %6
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %26
13: ; preds = %5
%14 = load i32*, i32** %6
%15 = load i8*, i8** %7
%16 = ptrtoint i8* %15 to i64
%17 = load i32, i32* %8
%18 = load i8*, i8** %9
%19 = call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64 %16, i32 %17, i8* %18)
%20 = load i32, i32* %10
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %13
%23 = load i32*, i32** %6
%24 = call i32 @fflush(i32* %23)
br label %25
25: ; preds = %22, %13
br label %26
26: ; preds = %25, %5
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"%lx %x %s\0A\00"
define void @perf_map_write_entry(i32* %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = icmp eq i32* %0, null
br i1 %6, label %13, label %7
7: ; preds = %5
%8 = ptrtoint i8* %1 to i64
%9 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64 %8, i32 %2, i8* %3)
%10 = icmp eq i32 %4, 0
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = tail call i32 @fflush(i32* %0)
br label %13
13: ; preds = %7, %11, %5
ret void
}