#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 errno;
long long strtoll(char const *, char **, int /*<<< orphan*/);
long long libconfig_parse_integer(const char *s, int *ok) {
  long long llval;
  char *endptr;
  int errsave = errno;
  errno = 0;
  llval = strtoll(s, &endptr, 0);
  if (*endptr || errno) {
    errno = 0;
    *ok = 0;
    return (0);
  }
  errno = errsave;
  *ok = 1;
  return (llval);
}


x86 assembly (clang, -O0):
<libconfig_parse_integer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0x2eb9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2ead(%rip),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
xor    %edx,%edx
call   1030 <strtoll@plt>
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    116c <libconfig_parse_integer+0x5c>
mov    0x2e7d(%rip),%rax
cmpl   $0x0,(%rax)
je     1190 <libconfig_parse_integer+0x80>
mov    0x2e6d(%rip),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    11ae <libconfig_parse_integer+0x9e>
mov    -0x2c(%rbp),%ecx
mov    0x2e46(%rip),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<libconfig_parse_integer>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    0x2ebf(%rip),%rbx
mov    (%rbx),%ebp
movl   $0x0,(%rbx)
mov    %rsp,%rsi
xor    %r15d,%r15d
xor    %edx,%edx
call   1030 <strtoll@plt>
mov    (%rsp),%rcx
cmpb   $0x0,(%rcx)
setne  %cl
cmpl   $0x0,(%rbx)
setne  %dl
or     %cl,%dl
mov    %edx,%ecx
xor    $0x1,%cl
test   %dl,%dl
cmovne %r15d,%ebp
movzbl %cl,%ecx
cmovne %r15,%rax
mov    %ebp,(%rbx)
mov    %ecx,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i32 0
define i64 @libconfig_parse_integer(i8* %0, i32* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
%9 = load i32, i32* @errno
store i32 %9, i32* %8
store i32 0, i32* @errno
%10 = load i8*, i8** %4
%11 = call i64 @strtoll(i8* %10, i8** %7, i32 0)
store i64 %11, i64* %6
%12 = load i8*, i8** %7
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %2
%17 = load i32, i32* @errno
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16, %2
store i32 0, i32* @errno
%20 = load i32*, i32** %5
store i32 0, i32* %20
store i64 0, i64* %3
br label %25
21: ; preds = %16
%22 = load i32, i32* %8
store i32 %22, i32* @errno
%23 = load i32*, i32** %5
store i32 1, i32* %23
%24 = load i64, i64* %6
store i64 %24, i64* %3
br label %25
25: ; preds = %21, %19
%26 = load i64, i64* %3
ret i64 %26
}

LLVM IR (-O2):
@errno = global i32 0
define i64 @libconfig_parse_integer(i8* %0, i32* nocapture writeonly %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = load i32, i32* @errno
store i32 0, i32* @errno
%6 = call i64 @strtoll(i8* %0, i8** %3, i32 0)
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
%10 = load i32, i32* @errno
%11 = icmp ne i32 %10, 0
%12 = select i1 %9, i1 true, i1 %11
%13 = select i1 %12, i32 0, i32 %5
%14 = xor i1 %12, true
%15 = zext i1 %14 to i32
%16 = select i1 %12, i64 0, i64 %6
store i32 %13, i32* @errno
store i32 %15, i32* %1
ret i64 %16
}