#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] = "logs/";
  sprintf(logName, "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
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    -0x18(%rbp),%edx
lea    0xe3b(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x120(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1204 <savePlayLog+0xa4>
lea    -0x120(%rbp),%rsi
lea    0xe21(%rip),%rdi
call   1040 <printf@plt>
jmp    1224 <savePlayLog+0xc4>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
lea    0xe1d(%rip),%rsi
movsbl -0x11(%rbp),%r9d
call   1060 <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
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    0xe19(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r8d,%edx
call   1070 <sprintf@plt>
lea    0xe1c(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     122a <savePlayLog+0xda>
movsbl %bpl,%r9d
lea    0xe20(%rip),%rsi
mov    %rbx,%rdi
mov    %r12,%rdx
mov    %r15d,%ecx
mov    %r14d,%r8d
call   1050 <fprintf@plt>
jmp    1239 <savePlayLog+0xe9>
lea    0xdea(%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 = [24 x i8] c"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 = bitcast [255 x i8]* %12 to i8*
%14 = bitcast i8* %13 to [255 x i8]*
%15 = getelementptr inbounds [255 x i8], [255 x i8]* %14, i32 0, i32 0
store i8 108, i8* %15
%16 = getelementptr inbounds [255 x i8], [255 x i8]* %14, i32 0, i32 1
store i8 111, i8* %16
%17 = getelementptr inbounds [255 x i8], [255 x i8]* %14, i32 0, i32 2
store i8 103, i8* %17
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %14, i32 0, i32 3
store i8 115, i8* %18
%19 = getelementptr inbounds [255 x i8], [255 x i8]* %14, i32 0, i32 4
store i8 47, i8* %19
%20 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%21 = load i32, i32* %10
%22 = call i32 @sprintf(i8* %20, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %24, i32** %11
%25 = load i32*, i32** %11
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %30
27: ; preds = %5
%28 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%29 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %28)
br label %37
30: ; preds = %5
%31 = load i32*, i32** %11
%32 = load i8*, i8** %6
%33 = load i32, i32* %7
%34 = load i32, i32* %8
%35 = load i8, i8* %9
%36 = call i32 @fprintf(i32* %31, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %32, i32 %33, i32 %34, i8 signext %35)
br label %37
37: ; preds = %30, %27
%38 = load i32*, i32** %11
%39 = call i32 @fclose(i32* %38)
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 = [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
store i8 108, i8* %7
%8 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 1
store i8 111, i8* %8
%9 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 2
store i8 103, i8* %9
%10 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 3
store i8 115, i8* %10
%11 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 4
store i8 47, i8* %11
%12 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %4)
%13 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %5
%16 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %7)
br label %19
17: ; preds = %5
%18 = tail call i32 @fprintf(i32* %13, 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 %19
19: ; preds = %17, %15
%20 = call i32 @fclose(i32* %13)
ret void
}