#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] = "logs/";
  sprintf(logName, "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
xor    %esi,%esi
mov    $0xff,%edx
call   1050 <memset@plt>
movb   $0x6c,-0x120(%rbp)
movb   $0x6f,-0x11f(%rbp)
movb   $0x67,-0x11e(%rbp)
movb   $0x73,-0x11d(%rbp)
movb   $0x2f,-0x11c(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xe44(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x120(%rbp),%rdi
lea    0xe49(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11fb <closePlayLog+0x9b>
lea    -0x120(%rbp),%rsi
lea    0xe2a(%rip),%rdi
call   1040 <printf@plt>
jmp    1226 <closePlayLog+0xc6>
mov    -0x18(%rbp),%rdi
lea    0xe2e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x4(%rbp),%ecx
lea    0xe32(%rip),%rsi
mov    $0x0,%al
call   1060 <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
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movups %xmm0,0xef(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x73676f6c,(%rsp)
movb   $0x2f,0x4(%rsp)
lea    0xe11(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <sprintf@plt>
lea    0xe17(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1242 <closePlayLog+0xe2>
lea    0xe1c(%rip),%rdi
mov    $0x1c,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
lea    0xe20(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    1251 <closePlayLog+0xf1>
lea    0xdd2(%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 = [24 x i8] c"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 = bitcast [255 x i8]* %8 to i8*
%10 = bitcast i8* %9 to [255 x i8]*
%11 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i32 0, i32 0
store i8 108, i8* %11
%12 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i32 0, i32 1
store i8 111, i8* %12
%13 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i32 0, i32 2
store i8 103, i8* %13
%14 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i32 0, i32 3
store i8 115, i8* %14
%15 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i32 0, i32 4
store i8 47, i8* %15
%16 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%17 = load i32, i32* %5
%18 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %7
%21 = load i32*, i32** %7
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %26
23: ; preds = %3
%24 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%25 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %24)
br label %33
26: ; preds = %3
%27 = load i32*, i32** %7
%28 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%29 = load i32*, i32** %7
%30 = load i8*, i8** %6
%31 = load i32, i32* %4
%32 = call i32 (i32*, i8*, ...) @fprintf(i32* %29, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %30, i32 %31)
br label %33
33: ; preds = %26, %23
%34 = load i32*, i32** %7
%35 = call i32 @fclose(i32* %34)
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"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
store i8 108, i8* %5
%6 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 1
store i8 111, i8* %6
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 2
store i8 103, i8* %7
%8 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 3
store i8 115, i8* %8
%9 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 4
store i8 47, i8* %9
%10 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %1)
%11 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %3
%14 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %5)
br label %18
15: ; preds = %3
%16 = tail call i64 @fwrite(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i64 28, i64 1, i32* %11)
%17 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %2, i32 %0)
br label %18
18: ; preds = %15, %13
%19 = call i32 @fclose(i32* %11)
ret void
}