#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 *opt_find(char const *, char const *);
long strtol(char const *, char **, int /*<<< orphan*/);
int opt_get_int(int *i, const char *group, const char *option) {
  long lval;
  const char *val;
  char *endptr = NULL;
  val = opt_find(group, option);
  if (!val)
    return (0);
  endptr = NULL;
  lval = strtol(val, &endptr, 0);
  if (endptr == val)
    return (3);
  if (i)
    *i = (int)lval;
  return (0);
}


x86 assembly (clang, -O0):
<opt_get_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <opt_find@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1164 <opt_get_int+0x44>
movl   $0x0,-0x4(%rbp)
jmp    11b7 <opt_get_int+0x97>
movq   $0x0,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
xor    %edx,%edx
call   1030 <strtol@plt>
mov    %rax,-0x28(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x30(%rbp),%rax
jne    1199 <opt_get_int+0x79>
movl   $0x3,-0x4(%rbp)
jmp    11b7 <opt_get_int+0x97>
cmpq   $0x0,-0x10(%rbp)
je     11b0 <opt_get_int+0x90>
mov    -0x28(%rbp),%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<opt_get_int>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1040 <opt_find@plt>
test   %rax,%rax
je     1169 <opt_get_int+0x49>
mov    %rax,%rbx
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rsi
xor    %ebp,%ebp
mov    %rax,%rdi
xor    %edx,%edx
call   1030 <strtol@plt>
cmp    %rbx,0x8(%rsp)
je     116d <opt_get_int+0x4d>
test   %r14,%r14
je     1172 <opt_get_int+0x52>
mov    %eax,(%r14)
jmp    1172 <opt_get_int+0x52>
xor    %ebp,%ebp
jmp    1172 <opt_get_int+0x52>
mov    $0x3,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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