#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*/ getDate(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
void createLogs(int gameCounter, int dimension) {
  FILE *newLog;
  char logName[255];
  char dateExtended[32] = "";
  getDate(dateExtended);
  sprintf(logName, "logs/TripletsLog-%d.txt", gameCounter);
  newLog = fopen(logName, "wt");
  if (newLog == NULL) {
    printf("\n\tERR: Unable to create Log!");
  } else {
    fprintf(newLog, "--Triplets Log--\n");
    fprintf(newLog, "Game #%d\n", gameCounter);
    fprintf(newLog, "Matrix Dimension: %dx%d\n", dimension, dimension);
    fprintf(newLog, "Started on: %s\n", dateExtended);
  }
  fclose(newLog);
}


x86 assembly (clang, -O0):
<createLogs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0x130(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1060 <memset@plt>
lea    -0x130(%rbp),%rdi
call   1030 <getDate@plt>
lea    -0x110(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe4f(%rip),%rsi
call   1090 <sprintf@plt>
lea    -0x110(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11e9 <createLogs+0x79>
lea    0xe3c(%rip),%rdi
call   1050 <printf@plt>
jmp    1241 <createLogs+0xd1>
mov    -0x10(%rbp),%rdi
lea    0xe44(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe41(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xe33(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x130(%rbp),%rdx
lea    0xe33(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createLogs>:
push   %rbp
push   %r14
push   %rbx
sub    $0x120,%rsp
mov    %esi,%r14d
mov    %edi,%ebp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
call   1030 <getDate@plt>
lea    0xe65(%rip),%rsi
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    %ebp,%edx
call   1080 <sprintf@plt>
lea    0xe67(%rip),%rsi
mov    %rbx,%rdi
call   1070 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     121a <createLogs+0xaa>
lea    0xe70(%rip),%rdi
mov    $0x11,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1090 <fwrite@plt>
lea    0xe69(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xe60(%rip),%rsi
mov    %rbx,%rdi
mov    %r14d,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xe62(%rip),%rsi
mov    %rsp,%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    1226 <createLogs+0xb6>
lea    0xdfa(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x120,%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"wt\00"
@.str.2 = [29 x i8] c"\0A\09ERR: Unable to create Log!\00"
@.str.3 = [18 x i8] c"--Triplets Log--\0A\00"
@.str.4 = [10 x i8] c"Game #%d\0A\00"
@.str.5 = [25 x i8] c"Matrix Dimension: %dx%d\0A\00"
@.str.6 = [16 x i8] c"Started on: %s\0A\00"
define void @createLogs(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca [255 x i8]
%7 = alloca [32 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = bitcast [32 x i8]* %7 to i8*
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%10 = call i32 @getDate(i8* %9)
%11 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%12 = load i32, i32* %3
%13 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %15, i32** %5
%16 = load i32*, i32** %5
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %33
20: ; preds = %2
%21 = load i32*, i32** %5
%22 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%23 = load i32*, i32** %5
%24 = load i32, i32* %3
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %23, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %24)
%26 = load i32*, i32** %5
%27 = load i32, i32* %4
%28 = load i32, i32* %4
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %27, i32 %28)
%30 = load i32*, i32** %5
%31 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%32 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %31)
br label %33
33: ; preds = %20, %18
%34 = load i32*, i32** %5
%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"wt\00"
@.str.2 = [29 x i8] c"\0A\09ERR: Unable to create Log!\00"
@.str.3 = [18 x i8] c"--Triplets Log--\0A\00"
@.str.4 = [10 x i8] c"Game #%d\0A\00"
@.str.5 = [25 x i8] c"Matrix Dimension: %dx%d\0A\00"
@.str.6 = [16 x i8] c"Started on: %s\0A\00"
define void @createLogs(i32 %0, i32 %1) {
%3 = alloca [255 x i8]
%4 = alloca [32 x i8]
%5 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%7 = call i32 @getDate(i8* %6)
%8 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %0)
%9 = call i32* @fopen(i8* %5, 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 = %2
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %18
13: ; preds = %2
%14 = call i64 @fwrite(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i64 17, i64 1, i32* %9)
%15 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %0)
%16 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %1, i32 %1)
%17 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %6)
br label %18
18: ; preds = %13, %11
%19 = call i32 @fclose(i32* %9)
ret void
}