#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 scripting_GetIntegerResult(int *);
int /*<<< orphan*/ scripting_GetValue(char const *);
int /*<<< orphan*/ scripting_IsNil();
int /*<<< orphan*/ scripting_Pop();
int scripting_GetOptional_Int(const char *name, int *i, int iValue) {
  int retValue = 0;
  scripting_GetValue(name);
  if (!scripting_IsNil()) {
    retValue = scripting_GetIntegerResult(i);
  } else {
    *i = iValue;
    scripting_Pop();
  }
  return retValue;
}


x86 assembly (clang, -O0):
<scripting_GetOptional_Int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <scripting_GetValue@plt>
mov    $0x0,%al
call   1030 <scripting_IsNil@plt>
cmp    $0x0,%eax
jne    1184 <scripting_GetOptional_Int+0x44>
mov    -0x10(%rbp),%rdi
call   1050 <scripting_GetIntegerResult@plt>
mov    %eax,-0x18(%rbp)
jmp    1194 <scripting_GetOptional_Int+0x54>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    $0x0,%al
call   1040 <scripting_Pop@plt>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scripting_GetOptional_Int>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%rbx
call   1060 <scripting_GetValue@plt>
xor    %eax,%eax
call   1030 <scripting_IsNil@plt>
test   %eax,%eax
je     116a <scripting_GetOptional_Int+0x2a>
mov    %ebp,(%rbx)
xor    %eax,%eax
call   1040 <scripting_Pop@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <scripting_GetIntegerResult@plt>

LLVM IR (-O0):
define i32 @scripting_GetOptional_Int(i8* %0, i32* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
store i32 0, i32* %7
%8 = load i8*, i8** %4
%9 = call i32 @scripting_GetValue(i8* %8)
%10 = call i32 (...) @scripting_IsNil()
%11 = icmp ne i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %3
%13 = load i32*, i32** %5
%14 = call i32 @scripting_GetIntegerResult(i32* %13)
store i32 %14, i32* %7
br label %19
15: ; preds = %3
%16 = load i32, i32* %6
%17 = load i32*, i32** %5
store i32 %16, i32* %17
%18 = call i32 (...) @scripting_Pop()
br label %19
19: ; preds = %15, %12
%20 = load i32, i32* %7
ret i32 %20
}

LLVM IR (-O2):
define i32 @scripting_GetOptional_Int(i8* %0, i32* %1, i32 %2) {
%4 = tail call i32 @scripting_GetValue(i8* %0)
%5 = tail call i32 (...) @scripting_IsNil()
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @scripting_GetIntegerResult(i32* %1)
br label %11
9: ; preds = %3
store i32 %2, i32* %1
%10 = tail call i32 (...) @scripting_Pop()
br label %11
11: ; preds = %9, %7
%12 = phi i32 [ 0, %9 ], [ %8, %7 ]
ret i32 %12
}