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


x86 assembly (clang, -O0):
<_conf_val_long>:
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,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <_conf_value@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     119d <_conf_val_long+0x6d>
mov    -0x20(%rbp),%rdi
lea    0xe87(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
je     119d <_conf_val_long+0x6d>
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_conf_val_long>:
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     1170 <_conf_val_long+0x40>
lea    0xeaf(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1050 <sscanf@plt>
cmp    $0x1,%eax
je     1170 <_conf_val_long+0x40>
mov    0x8(%rsp),%rax
mov    %rax,(%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 = [4 x i8] c"%ld\00"
define i32 @_conf_val_long(i8* %0, i8* %1, i64* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64* %2, i64** %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 ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %8)
%17 = icmp ne i32 %16, 1
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = load i64, i64* %8
%20 = load i64*, i64** %6
store i64 %19, i64* %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 = [4 x i8] c"%ld\00"
define i32 @_conf_val_long(i8* %0, i8* %1, i64* nocapture writeonly %2) {
%4 = alloca i64
%5 = bitcast i64* %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 ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %4)
%10 = icmp eq i32 %9, 1
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = load i64, i64* %4
store i64 %12, i64* %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
}