#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 const *);
int /*<<< orphan*/ exit(int);
char *get_key_value(void *, char const *, char const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char const *, char const *);
int getconfint(void *cfgdata, const char *section, const char *key, int isnull,
               int notfound, int min, int max) {
  const char *cp;
  int v;
  cp = get_key_value(cfgdata, section, key, NULL);
  if (!cp && !isnull) {
    printf("Config Item: [%s] %s: not set\n", section, key);
    exit(1);
  } else if (!cp && isnull)
    return notfound;
  else {
    v = atoi(cp);
    if (max && (v < min || v > max)) {
      printf("Config Item: [%s] %s: set error\n", section, key);
      exit(1);
    }
    return v;
  }
}


x86 assembly (clang, -O0):
<getconfint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1030 <get_key_value@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11ae <getconfint+0x6e>
cmpl   $0x0,-0x24(%rbp)
jne    11ae <getconfint+0x6e>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe61(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
cmpq   $0x0,-0x38(%rbp)
jne    11ce <getconfint+0x8e>
cmpl   $0x0,-0x24(%rbp)
je     11ce <getconfint+0x8e>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1220 <getconfint+0xe0>
mov    -0x38(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,0x10(%rbp)
je     121a <getconfint+0xda>
mov    -0x3c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jl     11fc <getconfint+0xbc>
mov    -0x3c(%rbp),%eax
cmp    0x10(%rbp),%eax
jle    121a <getconfint+0xda>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe14(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getconfint>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r9d,%r15d
mov    %r8d,%ebp
mov    %ecx,%ebx
mov    %rdx,%r14
mov    %rsi,%r12
xor    %ecx,%ecx
call   1030 <get_key_value@plt>
test   %ebx,%ebx
jne    1166 <getconfint+0x26>
test   %rax,%rax
je     1195 <getconfint+0x55>
test   %ebx,%ebx
je     116f <getconfint+0x2f>
test   %rax,%rax
je     118a <getconfint+0x4a>
mov    0x30(%rsp),%ebx
mov    %rax,%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
test   %ebx,%ebx
je     118a <getconfint+0x4a>
cmp    %r15d,%ebp
jl     119e <getconfint+0x5e>
cmp    %ebx,%ebp
jg     119e <getconfint+0x5e>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe64(%rip),%rdi
jmp    11a5 <getconfint+0x65>
lea    0xe7a(%rip),%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"Config Item: [%s] %s: not set\0A\00"
@.str.1 = [33 x i8] c"Config Item: [%s] %s: set error\0A\00"
define i32 @getconfint(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i32
store i8* %0, i8** %9
store i8* %1, i8** %10
store i8* %2, i8** %11
store i32 %3, i32* %12
store i32 %4, i32* %13
store i32 %5, i32* %14
store i32 %6, i32* %15
%18 = load i8*, i8** %9
%19 = load i8*, i8** %10
%20 = load i8*, i8** %11
%21 = call i8* @get_key_value(i8* %18, i8* %19, i8* %20, i32* null)
store i8* %21, i8** %16
%22 = load i8*, i8** %16
%23 = icmp ne i8* %22, null
br i1 %23, label %32, label %24
24: ; preds = %7
%25 = load i32, i32* %12
%26 = icmp ne i32 %25, 0
br i1 %26, label %32, label %27
27: ; preds = %24
%28 = load i8*, i8** %10
%29 = load i8*, i8** %11
%30 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %28, i8* %29)
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %24, %7
%33 = load i8*, i8** %16
%34 = icmp ne i8* %33, null
br i1 %34, label %40, label %35
35: ; preds = %32
%36 = load i32, i32* %12
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = load i32, i32* %13
store i32 %39, i32* %8
br label %60
40: ; preds = %35, %32
%41 = load i8*, i8** %16
%42 = call i32 @atoi(i8* %41)
store i32 %42, i32* %17
%43 = load i32, i32* %15
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %58
45: ; preds = %40
%46 = load i32, i32* %17
%47 = load i32, i32* %14
%48 = icmp slt i32 %46, %47
br i1 %48, label %53, label %49
49: ; preds = %45
%50 = load i32, i32* %17
%51 = load i32, i32* %15
%52 = icmp sgt i32 %50, %51
br i1 %52, label %53, label %58
53: ; preds = %49, %45
%54 = load i8*, i8** %10
%55 = load i8*, i8** %11
%56 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %54, i8* %55)
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %49, %40
%59 = load i32, i32* %17
store i32 %59, i32* %8
br label %60
60: ; preds = %58, %38
%61 = load i32, i32* %8
ret i32 %61
}

LLVM IR (-O2):
@.str = [31 x i8] c"Config Item: [%s] %s: not set\0A\00"
@.str.1 = [33 x i8] c"Config Item: [%s] %s: set error\0A\00"
define i32 @getconfint(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = tail call i8* @get_key_value(i8* %0, i8* %1, i8* %2, i32* null)
%9 = icmp ne i8* %8, null
%10 = icmp ne i32 %3, 0
%11 = or i1 %10, %9
br i1 %11, label %15, label %12
12: ; preds = %7
%13 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2)
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %7
%16 = icmp eq i8* %8, null
%17 = and i1 %10, %16
br i1 %17, label %28, label %18
18: ; preds = %15
%19 = tail call i32 @atoi(i8* %8)
%20 = icmp eq i32 %6, 0
br i1 %20, label %28, label %21
21: ; preds = %18
%22 = icmp slt i32 %19, %5
%23 = icmp sgt i32 %19, %6
%24 = or i1 %22, %23
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %2)
%27 = tail call i32 @exit(i32 1)
unreachable
28: ; preds = %18, %21, %15
%29 = phi i32 [ %4, %15 ], [ %19, %21 ], [ %19, %18 ]
ret i32 %29
}