#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*/ cdoAbort(char *, char const *, int);
scalar_t__ strtol(char const *, char **, int);
int parameter2int(const char *string) {
  char *endptr = NULL;
  int ival = (int)strtol(string, &endptr, 10);
  if (*endptr != 0)
    cdoAbort(
        "Integer parameter >%s< contains invalid character at position %d!",
        string, (int)(endptr - string + 1));
  return (ival);
}


x86 assembly (clang, -O0):
<parameter2int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     117a <parameter2int+0x5a>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,%edx
lea    0xe8b(%rip),%rdi
call   1040 <cdoAbort@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parameter2int>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
movq   $0x0,(%rsp)
mov    %rsp,%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %rax,%r14
mov    (%rsp),%rdx
cmpb   $0x0,(%rdx)
je     115c <parameter2int+0x3c>
sub    %ebx,%edx
add    $0x1,%edx
lea    0xeac(%rip),%rdi
mov    %rbx,%rsi
call   1040 <cdoAbort@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [66 x i8] c"Integer parameter >%s< contains invalid character at position %d!\00"
define i32 @parameter2int(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
store i8* null, i8** %3
%5 = load i8*, i8** %2
%6 = call i64 @strtol(i8* %5, i8** %3, i32 10)
%7 = trunc i64 %6 to i32
store i32 %7, i32* %4
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %1
%13 = load i8*, i8** %2
%14 = load i8*, i8** %3
%15 = load i8*, i8** %2
%16 = ptrtoint i8* %14 to i64
%17 = ptrtoint i8* %15 to i64
%18 = sub i64 %16, %17
%19 = add nsw i64 %18, 1
%20 = trunc i64 %19 to i32
%21 = call i32 @cdoAbort(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i8* %13, i32 %20)
br label %22
22: ; preds = %12, %1
%23 = load i32, i32* %4
ret i32 %23
}

LLVM IR (-O2):
@.str = [66 x i8] c"Integer parameter >%s< contains invalid character at position %d!\00"
define i32 @parameter2int(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%4 = call i64 @strtol(i8* %0, i8** %2, i32 10)
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %1
%9 = ptrtoint i8* %5 to i64
%10 = ptrtoint i8* %0 to i64
%11 = sub i64 %9, %10
%12 = trunc i64 %11 to i32
%13 = add i32 %12, 1
%14 = tail call i32 @cdoAbort(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %13)
br label %15
15: ; preds = %8, %1
%16 = trunc i64 %4 to i32
ret i32 %16
}