#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*/ para_parse_str(char const *, char const *, char *);
int strtol(char *, char **, int);
int para_parse_int(const char *src, const char *key, int *val,
                   int default_val) {
  char str[1024] = {0};
  para_parse_str(src, key, str);
  if (str[0] == '\0') {
    *val = default_val;
    return *val;
  }
  *val = strtol(str, (char **)NULL, 10);
  return *val;
}


x86 assembly (clang, -O0):
<para_parse_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
lea    -0x430(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x430(%rbp),%rdx
call   1050 <para_parse_str@plt>
movsbl -0x430(%rbp),%eax
cmp    $0x0,%eax
jne    1198 <para_parse_int+0x68>
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11be <para_parse_int+0x8e>
lea    -0x430(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<para_parse_int>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x400,%rsp
mov    %ecx,%ebp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rsp,%r12
mov    $0x400,%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <para_parse_str@plt>
cmpb   $0x0,(%rsp)
je     1181 <para_parse_int+0x51>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,%ebp
mov    %ebp,(%r14)
mov    %ebp,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @para_parse_int(i8* %0, i8* %1, i32* nocapture writeonly %2, i32 %3) {
%5 = alloca [1024 x i8]
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%7 = call i32 @para_parse_str(i8* %0, i8* %1, i8* %6)
%8 = load i8, i8* %6
%9 = icmp eq i8 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %4
%11 = call i32 @strtol(i8* nocapture %6, i8** null, i32 10)
br label %12
12: ; preds = %4, %10
%13 = phi i32 [ %11, %10 ], [ %3, %4 ]
store i32 %13, i32* %2
ret i32 %13
}