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


x86 assembly (clang, -O0):
<get_opt_int_default>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
xor    %esi,%esi
lea    -0x20(%rbp),%rdx
movsbl -0x5(%rbp),%edi
call   1040 <get_opt_str@plt>
cmp    $0x0,%eax
jne    1175 <get_opt_int_default+0x45>
mov    -0x10(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11b8 <get_opt_int_default+0x88>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <str_to_int@plt>
cmp    $0x0,%eax
jne    11b1 <get_opt_int_default+0x81>
cmpl   $0x0,-0xc(%rbp)
je     11a5 <get_opt_int_default+0x75>
lea    0xe64(%rip),%rdi
movsbl -0x5(%rbp),%esi
call   1050 <msg@plt>
movl   $0x0,-0x4(%rbp)
jmp    11b8 <get_opt_int_default+0x88>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_opt_int_default>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%rbp
mov    %edx,%r15d
mov    %esi,%r14d
mov    %edi,%ebx
mov    %rsp,%rdx
xor    %esi,%esi
call   1040 <get_opt_str@plt>
test   %eax,%eax
je     117d <get_opt_int_default+0x4d>
mov    (%rsp),%rdi
mov    %rbp,%rsi
call   1030 <str_to_int@plt>
mov    $0x1,%ebp
test   %eax,%eax
jne    1186 <get_opt_int_default+0x56>
xor    %ebp,%ebp
test   %r14d,%r14d
je     1186 <get_opt_int_default+0x56>
movsbl %bl,%esi
lea    0xe8a(%rip),%rdi
call   1050 <msg@plt>
jmp    1186 <get_opt_int_default+0x56>
mov    %r15d,0x0(%rbp)
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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