#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ getenv(char *);
char *stringAdd(char *, int /*<<< orphan*/, char *, char *,
                int /*<<< orphan*/ *);
void i8086clearLog() {
  FILE *file;
  char *linfilename;
  linfilename = (char *)calloc(1, sizeof(char));
  linfilename =
      stringAdd(linfilename, getenv("HOME"), "/.i8086emu/", "emu.log", NULL);
  file = fopen(linfilename, "w+");
  fclose(file);
}


x86 assembly (clang, -O0):
<i8086clearLog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x1,%esi
mov    %esi,%edi
call   1050 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    0xe89(%rip),%rdi
call   1030 <getenv@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%esi
lea    0xe7c(%rip),%rdx
lea    0xe81(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1070 <stringAdd@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe70(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<i8086clearLog>:
push   %rbx
mov    $0x1,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
lea    0xe96(%rip),%rdi
call   1030 <getenv@plt>
lea    0xe8f(%rip),%rdx
lea    0xe94(%rip),%rcx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %r8d,%r8d
call   1070 <stringAdd@plt>
lea    0xe88(%rip),%rsi
mov    %rax,%rdi
call   1060 <fopen@plt>
mov    %rax,%rdi
pop    %rbx
jmp    1040 <fclose@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [12 x i8] c"/.i8086emu/\00"
@.str.2 = [8 x i8] c"emu.log\00"
@.str.3 = [3 x i8] c"w+\00"
define void @i8086clearLog() {
%1 = alloca i32*
%2 = alloca i8*
%3 = call i64 @calloc(i32 1, i32 1)
%4 = inttoptr i64 %3 to i8*
store i8* %4, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = call i8* @stringAdd(i8* %5, i32 %6, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32* null)
store i8* %7, i8** %2
%8 = load i8*, i8** %2
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %9, i32** %1
%10 = load i32*, i32** %1
%11 = call i32 @fclose(i32* %10)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [12 x i8] c"/.i8086emu/\00"
@.str.2 = [8 x i8] c"emu.log\00"
@.str.3 = [3 x i8] c"w+\00"
define void @i8086clearLog() {
%1 = tail call i64 @calloc(i32 1, i32 1)
%2 = inttoptr i64 %1 to i8*
%3 = tail call i32 @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = tail call i8* @stringAdd(i8* %2, i32 %3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32* null)
%5 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%6 = tail call i32 @fclose(i32* %5)
ret void
}