#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 *);
int read_profile_string(char const *, char const *, char **, char *,
                        char const *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int read_profile_int(const char *section, const char *key, int idefault_value,
                     const char *buf) {
  char *value;
  char default_value[256];
  sprintf(default_value, "%d", idefault_value);
  if (read_profile_string(section, key, &value, default_value, buf) == -1) {
    return -1;
  } else {
    int retv = atoi(value);
    free(value);
    return retv;
  }
}


x86 assembly (clang, -O0):
<read_profile_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xe95(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x130(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    -0x30(%rbp),%rdx
call   1040 <read_profile_string@plt>
cmp    $0xffffffff,%eax
jne    11a1 <read_profile_int+0x61>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c2 <read_profile_int+0x82>
mov    -0x30(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x134(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x134(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_profile_int>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x110,%rsp
mov    %rcx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xea1(%rip),%rsi
lea    0x10(%rsp),%r12
mov    %r12,%rdi
call   1060 <sprintf@plt>
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rcx
mov    %r14,%r8
call   1040 <read_profile_string@plt>
cmp    $0xffffffff,%eax
je     11a0 <read_profile_int+0x60>
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    11a5 <read_profile_int+0x65>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x110,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @read_profile_int(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [256 x i8]
%12 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%14 = load i32, i32* %8
%15 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i8*, i8** %6
%17 = load i8*, i8** %7
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%19 = load i8*, i8** %9
%20 = call i32 @read_profile_string(i8* %16, i8* %17, i8** %10, i8* %18, i8* %19)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %23
22: ; preds = %4
store i32 -1, i32* %5
br label %29
23: ; preds = %4
%24 = load i8*, i8** %10
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %12
%26 = load i8*, i8** %10
%27 = call i32 @free(i8* %26)
%28 = load i32, i32* %12
store i32 %28, i32* %5
br label %29
29: ; preds = %23, %22
%30 = load i32, i32* %5
ret i32 %30
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @read_profile_int(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca [256 x i8]
%7 = bitcast i8** %5 to i8*
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%9 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %2)
%10 = call i32 @read_profile_string(i8* %0, i8* %1, i8** %5, i8* %8, i8* %3)
%11 = icmp eq i32 %10, -1
br i1 %11, label %16, label %12
12: ; preds = %4
%13 = load i8*, i8** %5
%14 = call i32 @atoi(i8* %13)
%15 = call i32 @free(i8* %13)
br label %16
16: ; preds = %4, %12
%17 = phi i32 [ %14, %12 ], [ -1, %4 ]
ret i32 %17
}