#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;
typedef scalar_t__ ssize_t;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
char *get_conf_file();
int open(char *, int /*<<< orphan*/);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
time_t get_delta() {
  int delta = 0;
  char buffer[128] = {0};
  char *conf_file = get_conf_file();
  int fd = open(conf_file, O_RDONLY);
  if (fd != -1) {
    ssize_t nread = read(fd, buffer, (128 - 1));
    if (nread > 0) {
      sscanf(buffer, "%d", &delta);
    }
    close(fd);
  }
  return (time_t)delta;
}


x86 assembly (clang, -O0):
<get_delta>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
mov    $0x0,%al
call   1030 <get_conf_file@plt>
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rdi
mov    0x2e47(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x9c(%rbp)
cmpl   $0xffffffff,-0x9c(%rbp)
je     1209 <get_delta+0xa9>
mov    -0x9c(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    $0x7f,%edx
call   1060 <read@plt>
mov    %rax,-0xa8(%rbp)
cmpq   $0x0,-0xa8(%rbp)
jle    11fe <get_delta+0x9e>
lea    -0x90(%rbp),%rdi
lea    0xe0b(%rip),%rsi
lea    -0x4(%rbp),%rdx
call   1070 <sscanf@plt>
mov    -0x9c(%rbp),%edi
call   1050 <close@plt>
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_delta>:
push   %rbp
push   %rbx
sub    $0x98,%rsp
movl   $0x0,0xc(%rsp)
xorps  %xmm0,%xmm0
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)
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <get_conf_file@plt>
mov    0x2e49(%rip),%rcx
mov    (%rcx),%esi
mov    %rax,%rdi
call   1070 <open@plt>
cmp    $0xffffffff,%eax
je     11e7 <get_delta+0x97>
mov    %eax,%ebx
lea    0x10(%rsp),%rsi
mov    %eax,%edi
mov    $0x7f,%edx
call   1050 <read@plt>
test   %rax,%rax
jle    11dc <get_delta+0x8c>
lea    0xe33(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
call   1060 <sscanf@plt>
mov    %ebx,%edi
call   1040 <close@plt>
mov    0xc(%rsp),%ebp
mov    %ebp,%eax
add    $0x98,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
@.str = [3 x i8] c"%d\00"
define i32 @get_delta() {
%1 = alloca i32
%2 = alloca [128 x i8]
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i64
store i32 0, i32* %1
%6 = bitcast [128 x i8]* %2 to i8*
%7 = call i8* (...) @get_conf_file()
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = load i32, i32* @O_RDONLY
%10 = call i32 @open(i8* %8, i32 %9)
store i32 %10, i32* %4
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, -1
br i1 %12, label %13, label %25
13: ; preds = %0
%14 = load i32, i32* %4
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%16 = call i64 @read(i32 %14, i8* %15, i32 127)
store i64 %16, i64* %5
%17 = load i64, i64* %5
%18 = icmp sgt i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%21 = call i32 @sscanf(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
br label %22
22: ; preds = %19, %13
%23 = load i32, i32* %4
%24 = call i32 @close(i32 %23)
br label %25
25: ; preds = %22, %0
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str = [3 x i8] c"%d\00"
define i32 @get_delta() {
%1 = alloca i32
%2 = alloca [128 x i8]
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%5 = tail call i8* (...) @get_conf_file()
%6 = load i32, i32* @O_RDONLY
%7 = tail call i32 @open(i8* %5, i32 %6)
%8 = icmp eq i32 %7, -1
br i1 %8, label %17, label %9
9: ; preds = %0
%10 = call i64 @read(i32 %7, i8* %4, i32 127)
%11 = icmp sgt i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
br label %14
14: ; preds = %12, %9
%15 = call i32 @close(i32 %7)
%16 = load i32, i32* %1
br label %17
17: ; preds = %14, %0
%18 = phi i32 [ %16, %14 ], [ 0, %0 ]
ret i32 %18
}