#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 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) {
  if (section == NULL || keyname == NULL || keyvalue == NULL ||
      filename == NULL) {
    return -1;
  }
  int rs;
  char kev[12];
  memset(kev, 0, 12);
  rs = getconfigstr(section, keyname, kev, 12, filename);
  if (rs == 0)
    *keyvalue = atoi(kev);
  return rs;
}


x86 assembly (clang, -O0):
<getconfigint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1174 <getconfigint+0x44>
cmpq   $0x0,-0x18(%rbp)
je     1174 <getconfigint+0x44>
cmpq   $0x0,-0x20(%rbp)
je     1174 <getconfigint+0x44>
cmpq   $0x0,-0x28(%rbp)
jne    1180 <getconfigint+0x50>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ce <getconfigint+0x9e>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x38(%rbp),%rdx
mov    -0x28(%rbp),%r8
mov    $0xc,%ecx
call   1030 <getconfigstr@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    11c8 <getconfigint+0x98>
lea    -0x38(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getconfigint>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    $0xffffffff,%ebp
test   %rdi,%rdi
je     119e <getconfigint+0x6e>
mov    %rsi,%r12
test   %rsi,%rsi
je     119e <getconfigint+0x6e>
mov    %rdx,%r14
test   %rdx,%rdx
je     119e <getconfigint+0x6e>
mov    %rcx,%r15
test   %rcx,%rcx
je     119e <getconfigint+0x6e>
mov    %rdi,%rbx
lea    0x4(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
mov    $0xc,%ecx
mov    %r15,%r8
call   1030 <getconfigstr@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    119e <getconfigint+0x6e>
lea    0x4(%rsp),%rdi
call   1050 <atoi@plt>
mov    %eax,(%r14)
mov    %ebp,%eax
add    $0x10,%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 i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca [12 x i8]
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32* %2, i32** %8
store i8* %3, i8** %9
%12 = load i8*, i8** %6
%13 = icmp eq i8* %12, null
br i1 %13, label %23, label %14
14: ; preds = %4
%15 = load i8*, i8** %7
%16 = icmp eq i8* %15, null
br i1 %16, label %23, label %17
17: ; preds = %14
%18 = load i32*, i32** %8
%19 = icmp eq i32* %18, null
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = load i8*, i8** %9
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %24
23: ; preds = %20, %17, %14, %4
store i32 -1, i32* %5
br label %40
24: ; preds = %20
%25 = getelementptr inbounds [12 x i8], [12 x i8]* %11, i64 0, i64 0
%26 = call i32 @memset(i8* %25, i32 0, i32 12)
%27 = load i8*, i8** %6
%28 = load i8*, i8** %7
%29 = getelementptr inbounds [12 x i8], [12 x i8]* %11, i64 0, i64 0
%30 = load i8*, i8** %9
%31 = call i32 @getconfigstr(i8* %27, i8* %28, i8* %29, i32 12, i8* %30)
store i32 %31, i32* %10
%32 = load i32, i32* %10
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %24
%35 = getelementptr inbounds [12 x i8], [12 x i8]* %11, i64 0, i64 0
%36 = call i32 @atoi(i8* %35)
%37 = load i32*, i32** %8
store i32 %36, i32* %37
br label %38
38: ; preds = %34, %24
%39 = load i32, i32* %10
store i32 %39, i32* %5
br label %40
40: ; preds = %38, %23
%41 = load i32, i32* %5
ret i32 %41
}

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