#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
void closePlayLog(int playNumber, int gameCounter, char playerName[]) {
  FILE *playLog;
  char logName[255];
  sprintf(logName, "data/logs/TripletsLog-%d.txt", gameCounter);
  playLog = fopen(logName, "at");
  if (playLog == NULL) {
    printf("\n\tERR: Couldn't close %s", logName);
  } else {
    fprintf(playLog, "# Game closed successfully!\n");
    fprintf(playLog, "# Winner: %s - %d moves", playerName, playNumber);
  }
  fclose(playLog);
}


x86 assembly (clang, -O0):
<closePlayLog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xe8a(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x120(%rbp),%rdi
lea    0xe94(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b5 <closePlayLog+0x65>
lea    -0x120(%rbp),%rsi
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
jmp    11e0 <closePlayLog+0x90>
mov    -0x18(%rbp),%rdi
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x4(%rbp),%ecx
lea    0xe7d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<closePlayLog>:
push   %rbp
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rdx,%r14
mov    %esi,%edx
mov    %edi,%ebp
lea    0xe87(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <sprintf@plt>
lea    0xe92(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11cc <closePlayLog+0x6c>
lea    0xe97(%rip),%rdi
mov    $0x1c,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    11db <closePlayLog+0x7b>
lea    0xe4d(%rip),%rdi
mov    %rsp,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"data/logs/TripletsLog-%d.txt\00"
@.str.1 = [3 x i8] c"at\00"
@.str.2 = [25 x i8] c"\0A\09ERR: Couldn't close %s\00"
@.str.3 = [29 x i8] c"# Game closed successfully!\0A\00"
@.str.4 = [24 x i8] c"# Winner: %s - %d moves\00"
define void @closePlayLog(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca [255 x i8]
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%9 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%10 = load i32, i32* %5
%11 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %13, i32** %7
%14 = load i32*, i32** %7
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %3
%17 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%18 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %17)
br label %26
19: ; preds = %3
%20 = load i32*, i32** %7
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%22 = load i32*, i32** %7
%23 = load i8*, i8** %6
%24 = load i32, i32* %4
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %23, i32 %24)
br label %26
26: ; preds = %19, %16
%27 = load i32*, i32** %7
%28 = call i32 @fclose(i32* %27)
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"data/logs/TripletsLog-%d.txt\00"
@.str.1 = [3 x i8] c"at\00"
@.str.2 = [25 x i8] c"\0A\09ERR: Couldn't close %s\00"
@.str.3 = [29 x i8] c"# Game closed successfully!\0A\00"
@.str.4 = [24 x i8] c"# Winner: %s - %d moves\00"
define void @closePlayLog(i32 %0, i32 %1, i8* %2) {
%4 = alloca [255 x i8]
%5 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%6 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %1)
%7 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %5)
br label %14
11: ; preds = %3
%12 = tail call i64 @fwrite(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i64 28, i64 1, i32* %7)
%13 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %2, i32 %0)
br label %14
14: ; preds = %11, %9
%15 = call i32 @fclose(i32* %7)
ret void
}