#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 config_readKV(char const *, char const *, char *);
int config_readLKV(char const *, char const *, char const *, char *, int);
int config_readSLKV(char const *, char const *, char const *, char *);
int config_readString(const char *configfile, const char *label,
                      const char *key, char *value, int num) {
  if (configfile == NULL || key == NULL) {
    return -1;
  }
  if (label == NULL) {
    return config_readKV(configfile, key, value);
  } else if (num == 0) {
    return config_readSLKV(configfile, label, key, value);
  } else {
    return config_readLKV(configfile, label, key, value, num);
  }
}


x86 assembly (clang, -O0):
<config_readString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1162 <config_readString+0x32>
cmpq   $0x0,-0x20(%rbp)
jne    116e <config_readString+0x3e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d5 <config_readString+0xa5>
cmpq   $0x0,-0x18(%rbp)
jne    1192 <config_readString+0x62>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <config_readKV@plt>
mov    %eax,-0x4(%rbp)
jmp    11d5 <config_readString+0xa5>
cmpl   $0x0,-0x2c(%rbp)
jne    11b9 <config_readString+0x89>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1050 <config_readSLKV@plt>
mov    %eax,-0x4(%rbp)
jmp    11d5 <config_readString+0xa5>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
call   1030 <config_readLKV@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_readString>:
test   %rdi,%rdi
je     1149 <config_readString+0x19>
test   %rdx,%rdx
je     1149 <config_readString+0x19>
test   %rsi,%rsi
je     114f <config_readString+0x1f>
test   %r8d,%r8d
je     115a <config_readString+0x2a>
jmp    1030 <config_readLKV@plt>
mov    $0xffffffff,%eax
ret
mov    %rdx,%rsi
mov    %rcx,%rdx
jmp    1040 <config_readKV@plt>
jmp    1050 <config_readSLKV@plt>

LLVM IR (-O0):
define i32 @config_readString(i8* %0, i8* %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i32 %4, i32* %11
%12 = load i8*, i8** %7
%13 = icmp eq i8* %12, null
br i1 %13, label %17, label %14
14: ; preds = %5
%15 = load i8*, i8** %9
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %18
17: ; preds = %14, %5
store i32 -1, i32* %6
br label %42
18: ; preds = %14
%19 = load i8*, i8** %8
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load i8*, i8** %7
%23 = load i8*, i8** %9
%24 = load i8*, i8** %10
%25 = call i32 @config_readKV(i8* %22, i8* %23, i8* %24)
store i32 %25, i32* %6
br label %42
26: ; preds = %18
%27 = load i32, i32* %11
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %26
%30 = load i8*, i8** %7
%31 = load i8*, i8** %8
%32 = load i8*, i8** %9
%33 = load i8*, i8** %10
%34 = call i32 @config_readSLKV(i8* %30, i8* %31, i8* %32, i8* %33)
store i32 %34, i32* %6
br label %42
35: ; preds = %26
%36 = load i8*, i8** %7
%37 = load i8*, i8** %8
%38 = load i8*, i8** %9
%39 = load i8*, i8** %10
%40 = load i32, i32* %11
%41 = call i32 @config_readLKV(i8* %36, i8* %37, i8* %38, i8* %39, i32 %40)
store i32 %41, i32* %6
br label %42
42: ; preds = %35, %29, %21, %17
%43 = load i32, i32* %6
ret i32 %43
}

LLVM IR (-O2):
define i32 @config_readString(i8* %0, i8* %1, i8* %2, i8* %3, i32 %4) {
%6 = icmp eq i8* %0, null
%7 = icmp eq i8* %2, null
%8 = or i1 %6, %7
br i1 %8, label %19, label %9
9: ; preds = %5
%10 = icmp eq i8* %1, null
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = tail call i32 @config_readKV(i8* %0, i8* %2, i8* %3)
br label %19
13: ; preds = %9
%14 = icmp eq i32 %4, 0
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = tail call i32 @config_readSLKV(i8* %0, i8* %1, i8* %2, i8* %3)
br label %19
17: ; preds = %13
%18 = tail call i32 @config_readLKV(i8* %0, i8* %1, i8* %2, i8* %3, i32 %4)
br label %19
19: ; preds = %5, %17, %15, %11
%20 = phi i32 [ %12, %11 ], [ %16, %15 ], [ %18, %17 ], [ -1, %5 ]
ret i32 %20
}