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

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ getString(char const *, char const *, char const *, char *,
                             char *, int);
int getInt(const char *buf, const char *section, const char *key,
           int defaultValue) {
  char value[21] = {0};
  getString(buf, section, key, "", value, sizeof(value));
  if (value[0] == '\0')
    return defaultValue;
  return atoi(value);
}


x86 assembly (clang, -O0):
<getInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x15,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    -0x40(%rbp),%r8
lea    0xe92(%rip),%rcx
mov    $0x15,%r9d
call   1030 <getString@plt>
movsbl -0x40(%rbp),%eax
cmp    $0x0,%eax
jne    1191 <getInt+0x61>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    119d <getInt+0x6d>
lea    -0x40(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getInt>:
push   %rbx
sub    $0x20,%rsp
mov    %ecx,%ebx
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movq   $0x0,0xd(%rsp)
lea    0xec2(%rip),%rcx
mov    %rsp,%r8
mov    $0x15,%r9d
call   1030 <getString@plt>
cmpb   $0x0,(%rsp)
je     115c <getInt+0x3c>
mov    %rsp,%rdi
call   1040 <atoi@plt>
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i32 @getInt(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca [21 x i8]
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%11 = bitcast [21 x i8]* %10 to i8*
%12 = load i8*, i8** %6
%13 = load i8*, i8** %7
%14 = load i8*, i8** %8
%15 = getelementptr inbounds [21 x i8], [21 x i8]* %10, i64 0, i64 0
%16 = call i32 @getString(i8* %12, i8* %13, i8* %14, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %15, i32 21)
%17 = getelementptr inbounds [21 x i8], [21 x i8]* %10, i64 0, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %4
%22 = load i32, i32* %9
store i32 %22, i32* %5
br label %26
23: ; preds = %4
%24 = getelementptr inbounds [21 x i8], [21 x i8]* %10, i64 0, i64 0
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %5
br label %26
26: ; preds = %23, %21
%27 = load i32, i32* %5
ret i32 %27
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i32 @getInt(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca [21 x i8]
%6 = getelementptr inbounds [21 x i8], [21 x i8]* %5, i64 0, i64 0
%7 = call i32 @getString(i8* %0, i8* %1, i8* %2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %6, i32 21)
%8 = load i8, i8* %6
%9 = icmp eq i8 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %4
%11 = call i32 @atoi(i8* %6)
br label %12
12: ; preds = %4, %10
%13 = phi i32 [ %11, %10 ], [ %3, %4 ]
ret i32 %13
}