#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 atoi(char *);
int /*<<< orphan*/ free(char *);
scalar_t__ omb_utils_file_exists(char *);
char *omb_utils_read(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *);
int omb_utils_gettimer() {
  char tmp[255];
  sprintf(tmp, "%s/%s/.%s", "/omb", "open-multiboot", "timer");
  if (omb_utils_file_exists(tmp)) {
    char *tmp = omb_utils_read("timer");
    if (tmp) {
      int ret = atoi(tmp);
      free(tmp);
      return ret;
    }
  }
  return 5;
}


x86 assembly (clang, -O0):
<omb_utils_gettimer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
lea    -0x110(%rbp),%rdi
lea    0xe97(%rip),%rsi
lea    0xe9a(%rip),%rdx
lea    0xe98(%rip),%rcx
lea    0xea0(%rip),%r8
call   1070 <sprintf@plt>
lea    -0x110(%rbp),%rdi
call   1030 <omb_utils_file_exists@plt>
cmp    $0x0,%rax
je     11eb <omb_utils_gettimer+0x9b>
lea    0xe7e(%rip),%rdi
call   1050 <omb_utils_read@plt>
mov    %rax,-0x118(%rbp)
cmpq   $0x0,-0x118(%rbp)
je     11e6 <omb_utils_gettimer+0x96>
mov    -0x118(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x11c(%rbp)
mov    -0x118(%rbp),%rdi
call   1040 <free@plt>
mov    -0x11c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f2 <omb_utils_gettimer+0xa2>
jmp    11eb <omb_utils_gettimer+0x9b>
movl   $0x5,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<omb_utils_gettimer>:
push   %rbp
push   %rbx
sub    $0x108,%rsp
lea    0xea0(%rip),%rsi
lea    0xea3(%rip),%rdx
lea    0xea1(%rip),%rcx
lea    0xea9(%rip),%r8
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <omb_utils_file_exists@plt>
mov    $0x5,%ebp
test   %rax,%rax
je     11b8 <omb_utils_gettimer+0x68>
lea    0xe85(%rip),%rdi
call   1050 <omb_utils_read@plt>
test   %rax,%rax
je     11b8 <omb_utils_gettimer+0x68>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <free@plt>
mov    %ebp,%eax
add    $0x108,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%s/%s/.%s\00"
@.str.1 = [5 x i8] c"/omb\00"
@.str.2 = [15 x i8] c"open-multiboot\00"
@.str.3 = [6 x i8] c"timer\00"
define i32 @omb_utils_gettimer() {
%1 = alloca i32
%2 = alloca [255 x i8]
%3 = alloca i8*
%4 = alloca i32
%5 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%6 = call i32 @sprintf(i8* %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%8 = call i64 @omb_utils_file_exists(i8* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %0
%11 = call i8* @omb_utils_read(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i8* %11, i8** %3
%12 = load i8*, i8** %3
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %20
14: ; preds = %10
%15 = load i8*, i8** %3
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %4
%17 = load i8*, i8** %3
%18 = call i32 @free(i8* %17)
%19 = load i32, i32* %4
store i32 %19, i32* %1
br label %22
20: ; preds = %10
br label %21
21: ; preds = %20, %0
store i32 5, i32* %1
br label %22
22: ; preds = %21, %14
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str = [10 x i8] c"%s/%s/.%s\00"
@.str.1 = [5 x i8] c"/omb\00"
@.str.2 = [15 x i8] c"open-multiboot\00"
@.str.3 = [6 x i8] c"timer\00"
define i32 @omb_utils_gettimer() {
%1 = alloca [255 x i8]
%2 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 0
%3 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%4 = call i64 @omb_utils_file_exists(i8* %2)
%5 = icmp eq i64 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %0
%7 = call i8* @omb_utils_read(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = call i32 @atoi(i8* %7)
%11 = call i32 @free(i8* %7)
br label %12
12: ; preds = %6, %0, %9
%13 = phi i32 [ %10, %9 ], [ 5, %0 ], [ 5, %6 ]
ret i32 %13
}