#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*/ error(char *, char const *, char const *);
scalar_t__ strcmp(char *, char *);
long strtol(char const *, char **, int /*<<< orphan*/);
long safe_atol(const char *name, const char *expr) {
  long d;
  char *suffix;
  d = strtol(expr, &suffix, 0);
  if (strcmp(suffix, "") != 0)
    error("PARAM: Unable to convert value \"%s\" for ddname \"%s\"", expr,
          name);
  return d;
}


x86 assembly (clang, -O0):
<safe_atol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xed5(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1181 <safe_atol+0x51>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xe84(%rip),%rdi
call   1050 <error@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<safe_atol>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %rax,%r15
mov    0x8(%rsp),%rdi
lea    0xed6(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1179 <safe_atol+0x49>
lea    0xe92(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <error@plt>
mov    %r15,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [52 x i8] c"PARAM: Unable to convert value \22%s\22 for ddname \22%s\22\00"
define i64 @safe_atol(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call i64 @strtol(i8* %7, i8** %6, i32 0)
store i64 %8, i64* %5
%9 = load i8*, i8** %6
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = load i8*, i8** %3
%15 = call i32 @error(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i8* %13, i8* %14)
br label %16
16: ; preds = %12, %2
%17 = load i64, i64* %5
ret i64 %17
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [52 x i8] c"PARAM: Unable to convert value \22%s\22 for ddname \22%s\22\00"
define i64 @safe_atol(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = call i64 @strtol(i8* %1, i8** %3, i32 0)
%6 = load i8*, i8** %3
%7 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = tail call i32 @error(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %0)
br label %11
11: ; preds = %9, %2
ret i64 %5
}