#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 */
char *Config_get_str(char const *);
int /*<<< orphan*/ sscanf(char *, char *, unsigned int *);
int Config_get_int(const char *par_name) {
  unsigned int intval;
  char *strval = Config_get_str(par_name);
  if (strval == NULL)
    return -1;
  if (!sscanf(strval, "0x%04x", &intval) && !sscanf(strval, "%d", &intval)) {
    return -1;
  }
  return (intval);
}


x86 assembly (clang, -O0):
<Config_get_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <Config_get_str@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1150 <Config_get_int+0x30>
movl   $0xffffffff,-0x4(%rbp)
jmp    119c <Config_get_int+0x7c>
mov    -0x20(%rbp),%rdi
lea    0xea5(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <sscanf@plt>
cmp    $0x0,%eax
jne    1196 <Config_get_int+0x76>
mov    -0x20(%rbp),%rdi
lea    0xe8f(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <sscanf@plt>
cmp    $0x0,%eax
jne    1196 <Config_get_int+0x76>
movl   $0xffffffff,-0x4(%rbp)
jmp    119c <Config_get_int+0x7c>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Config_get_int>:
push   %rbp
push   %rbx
push   %rax
call   1030 <Config_get_str@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
je     1169 <Config_get_int+0x49>
mov    %rax,%rbx
lea    0xec4(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rax,%rdi
call   1040 <sscanf@plt>
test   %eax,%eax
jne    1165 <Config_get_int+0x45>
lea    0xeb3(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
call   1040 <sscanf@plt>
test   %eax,%eax
je     1169 <Config_get_int+0x49>
mov    0x4(%rsp),%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"0x%04x\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @Config_get_int(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i8* @Config_get_str(i8* %6)
store i8* %7, i8** %5
%8 = load i8*, i8** %5
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 -1, i32* %2
br label %22
11: ; preds = %1
%12 = load i8*, i8** %5
%13 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %4)
%14 = icmp ne i32 %13, 0
br i1 %14, label %20, label %15
15: ; preds = %11
%16 = load i8*, i8** %5
%17 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%18 = icmp ne i32 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %15
store i32 -1, i32* %2
br label %22
20: ; preds = %15, %11
%21 = load i32, i32* %4
store i32 %21, i32* %2
br label %22
22: ; preds = %20, %19, %10
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
@.str = [7 x i8] c"0x%04x\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @Config_get_int(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i8* @Config_get_str(i8* %0)
%5 = icmp eq i8* %4, null
br i1 %5, label %14, label %6
6: ; preds = %1
%7 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %2)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9, %6
%13 = load i32, i32* %2
br label %14
14: ; preds = %9, %1, %12
%15 = phi i32 [ %13, %12 ], [ -1, %1 ], [ -1, %9 ]
ret i32 %15
}