#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*/ time_t;
struct tm {
  int tm_mday;
  int tm_mon;
  int tm_year;
  int tm_hour;
  int tm_min;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ close(int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void high_save(int lines, int scores) {
  FILE *fd = NULL;
  time_t tmp_time;
  struct tm *cur_time = NULL;
  if ((fd = fopen("TEsTris.scores", "a+")) == NULL) {
    fprintf(stderr, "[ERROR] Cannot open highscores file in %s at line %d.\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/sbusard/testris/refs/heads/master/src/"
            "highscores.c",
            45);
    return;
  }
  tmp_time = time(NULL);
  if ((cur_time = localtime(&tmp_time)) == NULL) {
    fprintf(stderr, "[ERROR] Cannot get time of day in %s at line *d.\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/sbusard/testris/refs/heads/master/src/"
            "highscores.c",
            55);
    close(fd);
    return;
  }
  fprintf(fd, "%d.%d.%d %d:%d \t%d \t%d\n", cur_time->tm_mday,
          cur_time->tm_mon + 1, cur_time->tm_year + 1900, cur_time->tm_hour,
          cur_time->tm_min, lines, scores);
  fclose(fd);
}


x86 assembly (clang, -O0):
<high_save>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
lea    0xe7b(%rip),%rdi
lea    0xe83(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11c8 <high_save+0x68>
mov    0x2e3a(%rip),%rax
movslq (%rax),%rdi
lea    0xe62(%rip),%rsi
lea    0xe92(%rip),%rdx
mov    $0x2d,%ecx
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    127b <high_save+0x11b>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    121d <high_save+0xbd>
mov    0x2dee(%rip),%rax
movslq (%rax),%rdi
lea    0xeda(%rip),%rsi
lea    0xe46(%rip),%rdx
mov    $0x37,%ecx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <close@plt>
jmp    127b <high_save+0x11b>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%r8d
add    $0x76c,%r8d
mov    -0x20(%rbp),%rax
mov    0xc(%rax),%r9d
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%r11d
mov    -0x4(%rbp),%r10d
mov    -0x8(%rbp),%eax
lea    0xeaa(%rip),%rsi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<high_save>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r15d
mov    %edi,%r14d
lea    0xe8a(%rip),%rdi
lea    0xe92(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11e7 <high_save+0x87>
mov    %rax,%rbx
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
test   %rax,%rax
je     1214 <high_save+0xb4>
mov    (%rax),%edx
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    $0x76c,%r8d
add    0x8(%rax),%r8d
mov    0xc(%rax),%r9d
mov    0x10(%rax),%r10d
sub    $0x8,%rsp
lea    0xf3f(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
push   %r15
push   %r14
push   %r10
call   1060 <fprintf@plt>
add    $0x20,%rsp
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    1240 <high_save+0xe0>
mov    0x2df2(%rip),%rax
movslq (%rax),%rdi
lea    0xe1a(%rip),%rsi
lea    0xe4a(%rip),%rdx
mov    $0x2d,%ecx
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <fprintf@plt>
mov    0x2dc5(%rip),%rax
movslq (%rax),%rdi
lea    0xeb1(%rip),%rsi
lea    0xe1d(%rip),%rdx
mov    $0x37,%ecx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1050 <close@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32 }
@.str = [15 x i8] c"TEsTris.scores\00"
@.str.1 = [3 x i8] c"a+\00"
@stderr = global i32 0
@.str.2 = [55 x i8] c"[ERROR] Cannot open highscores file in %s at line %d.\0A\00"
@.str.3 = [141 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/sbusard/testris/refs/heads/master/src/highscores.c\00"
@.str.4 = [50 x i8] c"[ERROR] Cannot get time of day in %s at line *d.\0A\00"
@.str.5 = [24 x i8] c"%d.%d.%d %d:%d \09%d \09%d\0A\00"
define void @high_save(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca %struct.tm*
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32* null, i32** %5
store %struct.tm* null, %struct.tm** %7
%8 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %5
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = sext i32 %11 to i64
%13 = inttoptr i64 %12 to i32*
%14 = call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.3, i64 0, i64 0), i32 45)
br label %50
15: ; preds = %2
%16 = call i32 @time(i32* null)
store i32 %16, i32* %6
%17 = call %struct.tm* @localtime(i32* %6)
store %struct.tm* %17, %struct.tm** %7
%18 = icmp eq %struct.tm* %17, null
br i1 %18, label %19, label %26
19: ; preds = %15
%20 = load i32, i32* @stderr
%21 = sext i32 %20 to i64
%22 = inttoptr i64 %21 to i32*
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.3, i64 0, i64 0), i32 55)
%24 = load i32*, i32** %5
%25 = call i32 @close(i32* %24)
br label %50
26: ; preds = %15
%27 = load i32*, i32** %5
%28 = load %struct.tm*, %struct.tm** %7
%29 = getelementptr inbounds %struct.tm, %struct.tm* %28, i32 0, i32 0
%30 = load i32, i32* %29
%31 = load %struct.tm*, %struct.tm** %7
%32 = getelementptr inbounds %struct.tm, %struct.tm* %31, i32 0, i32 1
%33 = load i32, i32* %32
%34 = add nsw i32 %33, 1
%35 = load %struct.tm*, %struct.tm** %7
%36 = getelementptr inbounds %struct.tm, %struct.tm* %35, i32 0, i32 2
%37 = load i32, i32* %36
%38 = add nsw i32 %37, 1900
%39 = load %struct.tm*, %struct.tm** %7
%40 = getelementptr inbounds %struct.tm, %struct.tm* %39, i32 0, i32 3
%41 = load i32, i32* %40
%42 = load %struct.tm*, %struct.tm** %7
%43 = getelementptr inbounds %struct.tm, %struct.tm* %42, i32 0, i32 4
%44 = load i32, i32* %43
%45 = load i32, i32* %3
%46 = load i32, i32* %4
%47 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %30, i32 %34, i32 %38, i32 %41, i32 %44, i32 %45, i32 %46)
%48 = load i32*, i32** %5
%49 = call i32 @fclose(i32* %48)
br label %50
50: ; preds = %26, %19, %10
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32 }
@.str = [15 x i8] c"TEsTris.scores\00"
@.str.1 = [3 x i8] c"a+\00"
@stderr = global i32 0
@.str.2 = [55 x i8] c"[ERROR] Cannot open highscores file in %s at line %d.\0A\00"
@.str.3 = [141 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/sbusard/testris/refs/heads/master/src/highscores.c\00"
@.str.4 = [50 x i8] c"[ERROR] Cannot get time of day in %s at line *d.\0A\00"
@.str.5 = [24 x i8] c"%d.%d.%d %d:%d \09%d \09%d\0A\00"
define void @high_save(i32 %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = sext i32 %8 to i64
%10 = inttoptr i64 %9 to i32*
%11 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %10, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.3, i64 0, i64 0), i32 45)
br label %37
12: ; preds = %2
%13 = tail call i32 @time(i32* null)
store i32 %13, i32* %3
%14 = call %struct.tm* @localtime(i32* %3)
%15 = icmp eq %struct.tm* %14, null
br i1 %15, label %16, label %22
16: ; preds = %12
%17 = load i32, i32* @stderr
%18 = sext i32 %17 to i64
%19 = inttoptr i64 %18 to i32*
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.3, i64 0, i64 0), i32 55)
%21 = call i32 @close(i32* %5)
br label %37
22: ; preds = %12
%23 = getelementptr inbounds %struct.tm, %struct.tm* %14, i64 0, i32 0
%24 = load i32, i32* %23
%25 = getelementptr inbounds %struct.tm, %struct.tm* %14, i64 0, i32 1
%26 = load i32, i32* %25
%27 = add nsw i32 %26, 1
%28 = getelementptr inbounds %struct.tm, %struct.tm* %14, i64 0, i32 2
%29 = load i32, i32* %28
%30 = add nsw i32 %29, 1900
%31 = getelementptr inbounds %struct.tm, %struct.tm* %14, i64 0, i32 3
%32 = load i32, i32* %31
%33 = getelementptr inbounds %struct.tm, %struct.tm* %14, i64 0, i32 4
%34 = load i32, i32* %33
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %24, i32 %27, i32 %30, i32 %32, i32 %34, i32 %0, i32 %1)
%36 = call i32 @fclose(i32* %5)
br label %37
37: ; preds = %22, %16, %7
ret void
}