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

/* Variables and functions */
int atoi(char *);
int getconfigstr(char const *, char const *, char *, int, char const *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int getconfigint(const char *section, const char *keyname, int *keyvalue,
                 const char *filename) {
  int rs;
  char kev[20];
  memset(kev, 0, sizeof(kev));
  rs = getconfigstr(section, keyname, kev, sizeof(kev), filename);
  if (rs == 0)
    *keyvalue = atoi(kev);
  return rs;
}


x86 assembly (clang, -O0):
<getconfigint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x40(%rbp),%rdx
mov    -0x20(%rbp),%r8
mov    $0x14,%ecx
call   1030 <getconfigstr@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    1190 <getconfigint+0x60>
lea    -0x40(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x24(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getconfigint>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    %rsp,%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1040 <memset@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    $0x14,%ecx
mov    %r15,%r8
call   1030 <getconfigstr@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    1181 <getconfigint+0x51>
mov    %rsp,%rdi
call   1050 <atoi@plt>
mov    %eax,(%r14)
mov    %ebp,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @getconfigint(i8* %0, i8* %1, i32* nocapture writeonly %2, i8* %3) {
%5 = alloca [20 x i8]
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%7 = call i32 @memset(i8* %6, i32 0, i32 20)
%8 = call i32 @getconfigstr(i8* %0, i8* %1, i8* %6, i32 20, i8* %3)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %4
%11 = call i32 @atoi(i8* %6)
store i32 %11, i32* %2
br label %12
12: ; preds = %10, %4
ret i32 %8
}