#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*/ errx(int, char *, char const *, char const *);
int strtol(char const *, char **, int /*<<< orphan*/);
int a_num(const char *s, const char *id_type) {
  int id;
  char *ep;
  id = strtol(s, &ep, 0);
  if (*ep || s == ep || id < 0)
    errx(1, "unknown %s id: %s", id_type, s);
  return id;
}


x86 assembly (clang, -O0):
<a_num>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    116a <a_num+0x4a>
mov    -0x8(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     116a <a_num+0x4a>
cmpl   $0x0,-0x14(%rbp)
jge    1183 <a_num+0x63>
mov    -0x10(%rbp),%rdx
mov    -0x8(%rbp),%rcx
mov    $0x1,%edi
lea    0xe82(%rip),%rsi
call   1030 <errx@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<a_num>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %eax,%ebp
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
je     1168 <a_num+0x48>
lea    0xeb3(%rip),%rsi
mov    $0x1,%edi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1030 <errx@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
cmp    %rbx,%rax
je     1146 <a_num+0x26>
test   %ebp,%ebp
jns    115d <a_num+0x3d>
jmp    1146 <a_num+0x26>

LLVM IR (-O0):
@.str = [18 x i8] c"unknown %s id: %s\00"
define i32 @a_num(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i32 @strtol(i8* %7, i8** %6, i32 0)
store i32 %8, i32* %5
%9 = load i8*, i8** %6
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %2
%14 = load i8*, i8** %3
%15 = load i8*, i8** %6
%16 = icmp eq i8* %14, %15
br i1 %16, label %20, label %17
17: ; preds = %13
%18 = load i32, i32* %5
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %17, %13, %2
%21 = load i8*, i8** %4
%22 = load i8*, i8** %3
%23 = call i32 @errx(i32 1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %21, i8* %22)
br label %24
24: ; preds = %20, %17
%25 = load i32, i32* %5
ret i32 %25
}

LLVM IR (-O2):
@.str = [18 x i8] c"unknown %s id: %s\00"
define i32 @a_num(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = call i32 @strtol(i8* %0, i8** %3, i32 0)
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = icmp eq i8* %6, %0
%11 = icmp slt i32 %5, 0
%12 = select i1 %10, i1 true, i1 %11
br i1 %12, label %13, label %15
13: ; preds = %9, %2
%14 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %0)
br label %15
15: ; preds = %9, %13
ret i32 %5
}