#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 /*<<< orphan*/ get_opt_str(char, int /*<<< orphan*/, char **);
int /*<<< orphan*/ msg(char *, char);
int /*<<< orphan*/ str_to_int(char *, int *);
int get_opt_int(char key, int withErrorMsg, int *intAddr) {
  char *str;
  if (!get_opt_str(key, 0, &str) || !str_to_int(str, intAddr)) {
    if (withErrorMsg)
      msg("ERROR: "
          "Value of option '-%c' was not found or not a valide integer.",
          key);
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<get_opt_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
xor    %esi,%esi
lea    -0x20(%rbp),%rdx
movsbl -0x5(%rbp),%edi
call   1040 <get_opt_str@plt>
cmp    $0x0,%eax
je     1173 <get_opt_int+0x43>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <str_to_int@plt>
cmp    $0x0,%eax
jne    1199 <get_opt_int+0x69>
cmpl   $0x0,-0xc(%rbp)
je     118d <get_opt_int+0x5d>
lea    0xe7c(%rip),%rdi
movsbl -0x5(%rbp),%esi
call   1050 <msg@plt>
movl   $0x0,-0x4(%rbp)
jmp    11a0 <get_opt_int+0x70>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_opt_int>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbp
mov    %esi,%r14d
mov    %edi,%ebx
lea    0x8(%rsp),%rdx
xor    %esi,%esi
call   1040 <get_opt_str@plt>
test   %eax,%eax
je     1168 <get_opt_int+0x38>
mov    0x8(%rsp),%rdi
mov    %rbp,%rsi
call   1030 <str_to_int@plt>
mov    %eax,%ecx
mov    $0x1,%eax
test   %ecx,%ecx
jne    117e <get_opt_int+0x4e>
test   %r14d,%r14d
je     117c <get_opt_int+0x4c>
movsbl %bl,%esi
lea    0xe89(%rip),%rdi
call   1050 <msg@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [68 x i8] c"ERROR: Value of option '-%c' was not found or not a valide integer.\00"
define i32 @get_opt_int(i8 signext %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i8*
store i8 %0, i8* %5
store i32 %1, i32* %6
store i32* %2, i32** %7
%9 = load i8, i8* %5
%10 = call i32 @get_opt_str(i8 signext %9, i32 0, i8** %8)
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %3
%13 = load i8*, i8** %8
%14 = load i32*, i32** %7
%15 = call i32 @str_to_int(i8* %13, i32* %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %24, label %17
17: ; preds = %12, %3
%18 = load i32, i32* %6
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i8, i8* %5
%22 = call i32 @msg(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0), i8 signext %21)
br label %23
23: ; preds = %20, %17
store i32 0, i32* %4
br label %25
24: ; preds = %12
store i32 1, i32* %4
br label %25
25: ; preds = %24, %23
%26 = load i32, i32* %4
ret i32 %26
}

LLVM IR (-O2):
@.str = [68 x i8] c"ERROR: Value of option '-%c' was not found or not a valide integer.\00"
define i32 @get_opt_int(i8 signext %0, i32 %1, i32* %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = call i32 @get_opt_str(i8 signext %0, i32 0, i8** %4)
%7 = icmp eq i32 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %3
%9 = load i8*, i8** %4
%10 = call i32 @str_to_int(i8* %9, i32* %2)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %8, %3
%13 = icmp eq i32 %1, 0
br i1 %13, label %16, label %14
14: ; preds = %12
%15 = call i32 @msg(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0), i8 signext %0)
br label %16
16: ; preds = %8, %12, %14
%17 = phi i32 [ 0, %14 ], [ 0, %12 ], [ 1, %8 ]
ret i32 %17
}