#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 */
char *config_get_str_param(char const *);
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
long strtol(char *, int /*<<< orphan*/ *, int);
long int config_get_lint_param(const char *param) {
  long int val = 0;
  char *str_val = NULL;
  str_val = config_get_str_param(param);
  if (!str_val) {
    return 0;
  }
  errno = 0;
  val = strtol(str_val, NULL, 10);
  if (errno != 0) {
    fprintf(stderr,
            "%s: "
            "configloader: strtol()"
            ": %s\n",
            "configloader", strerror(errno));
    ;
  }
  return val;
}


x86 assembly (clang, -O0):
<config_get_lint_param>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <config_get_str_param@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1181 <config_get_lint_param+0x41>
movq   $0x0,-0x8(%rbp)
jmp    11f2 <config_get_lint_param+0xb2>
mov    0x2e50(%rip),%rax
movq   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,-0x18(%rbp)
mov    0x2e2c(%rip),%rax
cmpq   $0x0,(%rax)
je     11ea <config_get_lint_param+0xaa>
mov    0x2e23(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2e0f(%rip),%rax
mov    (%rax),%rdi
call   1050 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    %rax,%rcx
lea    0xe22(%rip),%rsi
lea    0xe3b(%rip),%rdx
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_get_lint_param>:
push   %rbp
push   %rbx
push   %rax
call   1060 <config_get_str_param@plt>
test   %rax,%rax
je     119f <config_get_lint_param+0x5f>
mov    0x2e84(%rip),%rbp
movq   $0x0,0x0(%rbp)
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,%rbx
mov    0x0(%rbp),%rdi
test   %rdi,%rdi
je     11a1 <config_get_lint_param+0x61>
mov    0x2e62(%rip),%rax
mov    (%rax),%ebp
call   1050 <strerror@plt>
lea    0xe74(%rip),%rsi
lea    0xe8d(%rip),%rdx
mov    %ebp,%edi
mov    %rax,%rcx
call   1030 <fprintf@plt>
jmp    11a1 <config_get_lint_param+0x61>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i64 0
@stderr = global i32 0
@.str = [32 x i8] c"%s: configloader: strtol(): %s\0A\00"
@.str.1 = [13 x i8] c"configloader\00"
define i64 @config_get_lint_param(i8* %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
store i8* %0, i8** %3
store i64 0, i64* %4
store i8* null, i8** %5
%6 = load i8*, i8** %3
%7 = call i8* @config_get_str_param(i8* %6)
store i8* %7, i8** %5
%8 = load i8*, i8** %5
%9 = icmp ne i8* %8, null
br i1 %9, label %11, label %10
10: ; preds = %1
store i64 0, i64* %2
br label %23
11: ; preds = %1
store i64 0, i64* @errno
%12 = load i8*, i8** %5
%13 = call i64 @strtol(i8* %12, i32* null, i32 10)
store i64 %13, i64* %4
%14 = load i64, i64* @errno
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = load i64, i64* @errno
%19 = call i8* @strerror(i64 %18)
%20 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %16, %11
%22 = load i64, i64* %4
store i64 %22, i64* %2
br label %23
23: ; preds = %21, %10
%24 = load i64, i64* %2
ret i64 %24
}

LLVM IR (-O2):
@errno = global i64 0
@stderr = global i32 0
@.str = [32 x i8] c"%s: configloader: strtol(): %s\0A\00"
@.str.1 = [13 x i8] c"configloader\00"
define i64 @config_get_lint_param(i8* %0) {
%2 = tail call i8* @config_get_str_param(i8* %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %12, label %4
4: ; preds = %1
store i64 0, i64* @errno
%5 = tail call i64 @strtol(i8* nocapture %2, i32* null, i32 10)
%6 = load i64, i64* @errno
%7 = icmp eq i64 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %4
%9 = load i32, i32* @stderr
%10 = tail call i8* @strerror(i64 %6)
%11 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %4, %8, %1
%13 = phi i64 [ 0, %1 ], [ %5, %8 ], [ %5, %4 ]
ret i64 %13
}