#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*/ fatal(char *);
long strtol(char const *, char **, int);
long get_num_param(const char *p, const char **last) {
  char *e;
  long val;
  val = strtol(p, &e, 10);
  if ((*e && last == NULL) || e == p)
    fatal("The parameter should be a number.");
  if (last)
    *last = e;
  return val;
}


x86 assembly (clang, -O0):
<get_num_param>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1161 <get_num_param+0x41>
cmpq   $0x0,-0x10(%rbp)
je     116f <get_num_param+0x4f>
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jne    117b <get_num_param+0x5b>
lea    0xe8a(%rip),%rdi
call   1040 <fatal@plt>
cmpq   $0x0,-0x10(%rbp)
je     1191 <get_num_param+0x71>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_num_param>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rsp,%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %rax,%r14
mov    (%rsp),%r12
cmpb   $0x0,(%r12)
setne  %al
test   %r15,%r15
sete   %cl
cmp    %rbx,%r12
je     1159 <get_num_param+0x39>
and    %al,%cl
je     1165 <get_num_param+0x45>
lea    0xea0(%rip),%rdi
call   1040 <fatal@plt>
test   %r15,%r15
je     116d <get_num_param+0x4d>
mov    %r12,(%r15)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [34 x i8] c"The parameter should be a number.\00"
define i64 @get_num_param(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %3
store i8** %1, i8*** %4
%7 = load i8*, i8** %3
%8 = call i64 @strtol(i8* %7, i8** %5, i32 10)
store i64 %8, i64* %6
%9 = load i8*, i8** %5
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i8**, i8*** %4
%15 = icmp eq i8** %14, null
br i1 %15, label %20, label %16
16: ; preds = %13, %2
%17 = load i8*, i8** %5
%18 = load i8*, i8** %3
%19 = icmp eq i8* %17, %18
br i1 %19, label %20, label %22
20: ; preds = %16, %13
%21 = call i32 @fatal(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20, %16
%23 = load i8**, i8*** %4
%24 = icmp ne i8** %23, null
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load i8*, i8** %5
%27 = load i8**, i8*** %4
store i8* %26, i8** %27
br label %28
28: ; preds = %25, %22
%29 = load i64, i64* %6
ret i64 %29
}

LLVM IR (-O2):
@.str = [34 x i8] c"The parameter should be a number.\00"
define i64 @get_num_param(i8* %0, i8** writeonly %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = call i64 @strtol(i8* %0, i8** %3, i32 10)
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 0
%9 = icmp eq i8** %1, null
%10 = and i1 %9, %8
%11 = icmp eq i8* %6, %0
%12 = or i1 %11, %10
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = tail call i32 @fatal(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %2, %13
br i1 %9, label %17, label %16
16: ; preds = %15
store i8* %6, i8** %1
br label %17
17: ; preds = %16, %15
ret i64 %5
}