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

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ read_config_string(char *, char *, char *, char *, int,
                                      char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int read_config_int(char *filename, char *section, char *key, int defvalue) {
  char def[32];
  char result[512];
  sprintf(def, "%d", defvalue);
  read_config_string(filename, section, key, result, sizeof(result), def);
  return (atoi(result));
}


x86 assembly (clang, -O0):
<read_config_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xea8(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x240(%rbp),%rcx
lea    -0x40(%rbp),%r9
mov    $0x200,%r8d
call   1030 <read_config_string@plt>
lea    -0x240(%rbp),%rdi
call   1040 <atoi@plt>
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_config_int>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x220,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xeb0(%rip),%rsi
mov    %rsp,%r12
mov    %r12,%rdi
mov    %ecx,%edx
call   1050 <sprintf@plt>
lea    0x20(%rsp),%r13
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %r13,%rcx
mov    $0x200,%r8d
mov    %r12,%r9
call   1030 <read_config_string@plt>
mov    %r13,%rdi
call   1040 <atoi@plt>
add    $0x220,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @read_config_int(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [32 x i8]
%10 = alloca [512 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%11 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%12 = load i32, i32* %8
%13 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i8*, i8** %5
%15 = load i8*, i8** %6
%16 = load i8*, i8** %7
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%18 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%19 = call i32 @read_config_string(i8* %14, i8* %15, i8* %16, i8* %17, i32 512, i8* %18)
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%21 = call i32 @atoi(i8* %20)
ret i32 %21
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @read_config_int(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca [32 x i8]
%6 = alloca [512 x i8]
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%9 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %3)
%10 = call i32 @read_config_string(i8* %0, i8* %1, i8* %2, i8* %8, i32 512, i8* %7)
%11 = call i32 @atoi(i8* %8)
ret i32 %11
}