#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 *_conf_value(char const *, char const *);
int /*<<< orphan*/ free(char *);
int sscanf(char *, char *, int *);
int _conf_val_int(const char *buf, const char *option, int *oldval) {
  char *strval = NULL;
  int value, rc = 0;
  if ((strval = _conf_value(buf, option)) != NULL &&
      sscanf(strval, "%d", &value) == 1) {
    *oldval = value;
    rc = 1;
  }
  free(strval);
  return rc;
}


x86 assembly (clang, -O0):
<_conf_val_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <_conf_value@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     119b <_conf_val_int+0x6b>
mov    -0x20(%rbp),%rdi
lea    0xe87(%rip),%rsi
lea    -0x24(%rbp),%rdx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
jne    119b <_conf_val_int+0x6b>
mov    -0x24(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_conf_val_int>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
call   1040 <_conf_value@plt>
mov    %rax,%rbx
xor    %ebp,%ebp
test   %rax,%rax
je     116f <_conf_val_int+0x3f>
lea    0xeaf(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
call   1050 <sscanf@plt>
cmp    $0x1,%eax
jne    116f <_conf_val_int+0x3f>
mov    0xc(%rsp),%eax
mov    %eax,(%r14)
mov    $0x1,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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