#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 *, char *, int, int,
                           char);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
void savePlayLog(char playerName[], int playNumber, int moveX, char moveY,
                 int gameCounter) {
  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 write to %s", logName);
  } else {
    fprintf(playLog, "Player %s ; Play %d ; Move [%d][%c]\n", playerName,
            playNumber, moveX, moveY);
  }
  fclose(playLog);
}


x86 assembly (clang, -O0):
<savePlayLog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %cl,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    %r8d,-0x18(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xe81(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x120(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11be <savePlayLog+0x6e>
lea    -0x120(%rbp),%rsi
lea    0xe6c(%rip),%rdi
call   1040 <printf@plt>
jmp    11de <savePlayLog+0x8e>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
lea    0xe68(%rip),%rsi
movsbl -0x11(%rbp),%r9d
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<savePlayLog>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %ecx,%ebp
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%r12
lea    0xe8f(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r8d,%edx
call   1070 <sprintf@plt>
lea    0xe97(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11b4 <savePlayLog+0x64>
movsbl %bpl,%r9d
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdi
mov    %r12,%rdx
mov    %r15d,%ecx
mov    %r14d,%r8d
call   1050 <fprintf@plt>
jmp    11c3 <savePlayLog+0x73>
lea    0xe65(%rip),%rdi
mov    %rsp,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
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 = [28 x i8] c"\0A\09ERR: Couldn't write to %s\00"
@.str.3 = [37 x i8] c"Player %s ; Play %d ; Move [%d][%c]\0A\00"
define void @savePlayLog(i8* %0, i32 %1, i32 %2, i8 signext %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
%10 = alloca i32
%11 = alloca i32*
%12 = alloca [255 x i8]
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i8 %3, i8* %9
store i32 %4, i32* %10
%13 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%14 = load i32, i32* %10
%15 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %17, i32** %11
%18 = load i32*, i32** %11
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %23
20: ; preds = %5
%21 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%22 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %21)
br label %30
23: ; preds = %5
%24 = load i32*, i32** %11
%25 = load i8*, i8** %6
%26 = load i32, i32* %7
%27 = load i32, i32* %8
%28 = load i8, i8* %9
%29 = call i32 @fprintf(i32* %24, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %25, i32 %26, i32 %27, i8 signext %28)
br label %30
30: ; preds = %23, %20
%31 = load i32*, i32** %11
%32 = call i32 @fclose(i32* %31)
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 = [28 x i8] c"\0A\09ERR: Couldn't write to %s\00"
@.str.3 = [37 x i8] c"Player %s ; Play %d ; Move [%d][%c]\0A\00"
define void @savePlayLog(i8* %0, i32 %1, i32 %2, i8 signext %3, i32 %4) {
%6 = alloca [255 x i8]
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%8 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %4)
%9 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %5
%12 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %7)
br label %15
13: ; preds = %5
%14 = tail call i32 @fprintf(i32* %9, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %0, i32 %1, i32 %2, i8 signext %3)
br label %15
15: ; preds = %13, %11
%16 = call i32 @fclose(i32* %9)
ret void
}