#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 */
typedef int /*<<< orphan*/ int32_t;

/* Variables and functions */
scalar_t__ errno;
int /*<<< orphan*/ strtol(char const *, char **, int);
int ngf_proplist_parse_integer(const char *value, int32_t *integer_value) {
  char *endptr = NULL;
  if (value == NULL || value[0] == '\0' || integer_value == NULL)
    return 0;
  errno = 0;
  *integer_value = strtol(value, &endptr, 10);
  if (errno != 0 || endptr[0] != '\0')
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<ngf_proplist_parse_integer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     114e <ngf_proplist_parse_integer+0x3e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     114e <ngf_proplist_parse_integer+0x3e>
cmpq   $0x0,-0x18(%rbp)
jne    115a <ngf_proplist_parse_integer+0x4a>
movl   $0x0,-0x4(%rbp)
jmp    11b6 <ngf_proplist_parse_integer+0xa6>
mov    0x2e7f(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    0x2e57(%rip),%rax
cmpq   $0x0,(%rax)
jne    11a3 <ngf_proplist_parse_integer+0x93>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11af <ngf_proplist_parse_integer+0x9f>
movl   $0x0,-0x4(%rbp)
jmp    11b6 <ngf_proplist_parse_integer+0xa6>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ngf_proplist_parse_integer>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
xor    %ebp,%ebp
test   %rdi,%rdi
je     1168 <ngf_proplist_parse_integer+0x58>
mov    %rsi,%rbx
test   %rsi,%rsi
je     1168 <ngf_proplist_parse_integer+0x58>
cmpb   $0x0,(%rdi)
je     1168 <ngf_proplist_parse_integer+0x58>
mov    0x2ea4(%rip),%r14
movq   $0x0,(%r14)
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %eax,(%rbx)
cmpq   $0x0,(%r14)
jne    1168 <ngf_proplist_parse_integer+0x58>
mov    0x8(%rsp),%rax
xor    %ebp,%ebp
cmpb   $0x0,(%rax)
sete   %bpl
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i64 0
define i32 @ngf_proplist_parse_integer(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8*
store i8* %0, i8** %4
store i32* %1, i32** %5
store i8* null, i8** %6
%7 = load i8*, i8** %4
%8 = icmp eq i8* %7, null
br i1 %8, label %18, label %9
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %9
%16 = load i32*, i32** %5
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %19
18: ; preds = %15, %9, %2
store i32 0, i32* %3
br label %33
19: ; preds = %15
store i64 0, i64* @errno
%20 = load i8*, i8** %4
%21 = call i32 @strtol(i8* %20, i8** %6, i32 10)
%22 = load i32*, i32** %5
store i32 %21, i32* %22
%23 = load i64, i64* @errno
%24 = icmp ne i64 %23, 0
br i1 %24, label %31, label %25
25: ; preds = %19
%26 = load i8*, i8** %6
%27 = getelementptr inbounds i8, i8* %26, i64 0
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %25, %19
store i32 0, i32* %3
br label %33
32: ; preds = %25
store i32 1, i32* %3
br label %33
33: ; preds = %32, %31, %18
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@errno = global i64 0
define i32 @ngf_proplist_parse_integer(i8* %0, i32* writeonly %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%5 = icmp eq i8* %0, null
br i1 %5, label %20, label %6
6: ; preds = %2
%7 = load i8, i8* %0
%8 = icmp eq i8 %7, 0
%9 = icmp eq i32* %1, null
%10 = or i1 %9, %8
br i1 %10, label %20, label %11
11: ; preds = %6
store i64 0, i64* @errno
%12 = call i32 @strtol(i8* %0, i8** %3, i32 10)
store i32 %12, i32* %1
%13 = load i64, i64* @errno
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
%19 = zext i1 %18 to i32
br label %20
20: ; preds = %15, %11, %2, %6
%21 = phi i32 [ 0, %6 ], [ 0, %2 ], [ 0, %11 ], [ %19, %15 ]
ret i32 %21
}