#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 */

/* Variables and functions */
int O_CREAT;
int O_WRONLY;
int /*<<< orphan*/ SEEK_SET;
int get_mod_time(char *, char *);
int /*<<< orphan*/ lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
int open(char *, int, int);
int /*<<< orphan*/ sprintf(char *, char *);
int /*<<< orphan*/ write(int, char *, int);
int get_run_time(char s[]) {
  int r, i;
  r = get_mod_time(s, "last.txt");
  if (r < 0)
    sprintf(s, "0");
  i = open("last.txt", O_WRONLY | O_CREAT, 200);
  write(i, "a", 1);
  lseek(i, 0, SEEK_SET);
  return r;
}


x86 assembly (clang, -O0):
<get_run_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1040 <get_mod_time@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1189 <get_run_time+0x39>
mov    -0x8(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1070 <sprintf@plt>
mov    0x2e38(%rip),%rax
mov    (%rax),%esi
mov    0x2e5f(%rip),%rax
or     (%rax),%esi
lea    0xe5e(%rip),%rdi
mov    $0xc8,%edx
call   1060 <open@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
lea    0xe52(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x10(%rbp),%edi
mov    0x2e0b(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <lseek@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_run_time>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xeb3(%rip),%rsi
call   1040 <get_mod_time@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    115d <get_run_time+0x1d>
movw   $0x30,(%rbx)
mov    0x2e64(%rip),%rax
mov    0x2e8d(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xe8a(%rip),%rdi
mov    $0xc8,%edx
call   1060 <open@plt>
mov    %eax,%ebx
lea    0xe80(%rip),%rsi
mov    %eax,%edi
mov    $0x1,%edx
call   1030 <write@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %esi,%esi
call   1050 <lseek@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"last.txt\00"
@.str.1 = [2 x i8] c"0\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@.str.2 = [2 x i8] c"a\00"
@SEEK_SET = global i32 0
define i32 @get_run_time(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @get_mod_time(i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %9, %1
%13 = load i32, i32* @O_WRONLY
%14 = load i32, i32* @O_CREAT
%15 = or i32 %13, %14
%16 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %15, i32 200)
store i32 %16, i32* %4
%17 = load i32, i32* %4
%18 = call i32 @write(i32 %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%19 = load i32, i32* %4
%20 = load i32, i32* @SEEK_SET
%21 = call i32 @lseek(i32 %19, i32 0, i32 %20)
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@.str = [9 x i8] c"last.txt\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@.str.2 = [2 x i8] c"a\00"
@SEEK_SET = global i32 0
define i32 @get_run_time(i8* %0) {
%2 = tail call i32 @get_mod_time(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%3 = icmp slt i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = bitcast i8* %0 to i16*
store i16 48, i16* %5
br label %6
6: ; preds = %4, %1
%7 = load i32, i32* @O_WRONLY
%8 = load i32, i32* @O_CREAT
%9 = or i32 %8, %7
%10 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %9, i32 200)
%11 = tail call i32 @write(i32 %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%12 = load i32, i32* @SEEK_SET
%13 = tail call i32 @lseek(i32 %10, i32 0, i32 %12)
ret i32 %2
}