#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, long);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
int LogFile_printHops(char *FileName, long int TotalHopAttempt,
                      long int FailedHop) {
  char buf[256];
  snprintf(buf, sizeof buf, "%s%s", FileName, ".log");
  FILE *LogFile;
  if ((LogFile = fopen(buf, "a")) == NULL) {
    printf("ERROR! unable to open .log file!\n");
    exit(1);
  }
  fprintf(LogFile, "Total Hop Attempts  %ld\n", TotalHopAttempt);
  fprintf(LogFile, "Total Failed Hops   %ld\n", FailedHop);
  fclose(LogFile);
  return 0;
}


x86 assembly (clang, -O0):
<LogFile_printHops>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x100,%esi
lea    0xe72(%rip),%rdx
lea    0xe70(%rip),%r8
call   1050 <snprintf@plt>
lea    -0x120(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x128(%rbp)
cmp    $0x0,%rax
jne    11d4 <LogFile_printHops+0x74>
lea    0xe47(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x128(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe48(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x128(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe4a(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x128(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LogFile_printHops>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rcx
lea    0xe84(%rip),%rdx
lea    0xe82(%rip),%r8
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1050 <snprintf@plt>
lea    0xe70(%rip),%rsi
mov    %rbx,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     11e5 <LogFile_printHops+0x85>
mov    %rax,%rbx
lea    0xe5b(%rip),%rsi
mov    %rax,%rdi
mov    %r15,%rdx
call   1060 <fprintf@plt>
lea    0xe62(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe52(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%s%s\00"
@.str.1 = [5 x i8] c".log\00"
@.str.2 = [2 x i8] c"a\00"
@.str.3 = [34 x i8] c"ERROR! unable to open .log file!\0A\00"
@.str.4 = [25 x i8] c"Total Hop Attempts %ld\0A\00"
@.str.5 = [25 x i8] c"Total Failed Hops %ld\0A\00"
define i32 @LogFile_printHops(i8* %0, i64 %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca [256 x i8]
%8 = alloca i32*
store i8* %0, i8** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%10 = load i8*, i8** %4
%11 = call i32 @snprintf(i8* %9, i32 256, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %13, i32** %8
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %3
%16 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %3
%19 = load i32*, i32** %8
%20 = load i64, i64* %5
%21 = call i32 @fprintf(i32* %19, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i64 %20)
%22 = load i32*, i32** %8
%23 = load i64, i64* %6
%24 = call i32 @fprintf(i32* %22, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i64 %23)
%25 = load i32*, i32** %8
%26 = call i32 @fclose(i32* %25)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s%s\00"
@.str.1 = [5 x i8] c".log\00"
@.str.2 = [2 x i8] c"a\00"
@.str.4 = [25 x i8] c"Total Hop Attempts %ld\0A\00"
@.str.5 = [25 x i8] c"Total Failed Hops %ld\0A\00"
@str = [33 x i8] c"ERROR! unable to open .log file!\00"
define i32 @LogFile_printHops(i8* %0, i64 %1, i64 %2) {
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = call i32 @snprintf(i8* %5, i32 256, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %3
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %3
%13 = call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i64 %1)
%14 = call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i64 %2)
%15 = call i32 @fclose(i32* %7)
ret i32 0
}