#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 */
struct tiniparser_dictionary {
  int dummy;
};

/* Variables and functions */
scalar_t__ strtol(char const *, int /*<<< orphan*/ *, int /*<<< orphan*/);
char *tiniparser_getstring(struct tiniparser_dictionary *, char const *,
                           int /*<<< orphan*/ *);
int tiniparser_getint(struct tiniparser_dictionary *d, const char *key,
                      int default_value) {
  const char *value = tiniparser_getstring(d, key, NULL);
  if (value == NULL) {
    return default_value;
  }
  return (int)strtol(value, NULL, 0);
}


x86 assembly (clang, -O0):
<tiniparser_getint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <tiniparser_getstring@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    115e <tiniparser_getint+0x3e>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1170 <tiniparser_getint+0x50>
mov    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tiniparser_getint>:
push   %rbx
mov    %edx,%ebx
xor    %edx,%edx
call   1030 <tiniparser_getstring@plt>
test   %rax,%rax
je     113e <tiniparser_getint+0x1e>
mov    %rax,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %rax,%rbx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.tiniparser_dictionary = type { i32 }
define i32 @tiniparser_getint(%struct.tiniparser_dictionary* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.tiniparser_dictionary*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store %struct.tiniparser_dictionary* %0, %struct.tiniparser_dictionary** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%9 = load %struct.tiniparser_dictionary*, %struct.tiniparser_dictionary** %5
%10 = load i8*, i8** %6
%11 = call i8* @tiniparser_getstring(%struct.tiniparser_dictionary* %9, i8* %10, i32* null)
store i8* %11, i8** %8
%12 = load i8*, i8** %8
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %16
14: ; preds = %3
%15 = load i32, i32* %7
store i32 %15, i32* %4
br label %20
16: ; preds = %3
%17 = load i8*, i8** %8
%18 = call i64 @strtol(i8* %17, i32* null, i32 0)
%19 = trunc i64 %18 to i32
store i32 %19, i32* %4
br label %20
20: ; preds = %16, %14
%21 = load i32, i32* %4
ret i32 %21
}

LLVM IR (-O2):
%struct.tiniparser_dictionary = type { i32 }
define i32 @tiniparser_getint(%struct.tiniparser_dictionary* %0, i8* %1, i32 %2) {
%4 = tail call i8* @tiniparser_getstring(%struct.tiniparser_dictionary* %0, i8* %1, i32* null)
%5 = icmp eq i8* %4, null
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = tail call i64 @strtol(i8* nocapture %4, i32* null, i32 0)
%8 = trunc i64 %7 to i32
br label %9
9: ; preds = %3, %6
%10 = phi i32 [ %8, %6 ], [ %2, %3 ]
ret i32 %10
}