#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*/ Usage(char *);
int /*<<< orphan*/ sprintf(char *, char *, int, char *);
int strtol(char *, char **, int);
int numeric_arg(char **av, int n) {
  char *last = 0;
  int result = strtol(av[n], &last, 10);
  char msg[80];
  if (last == 0 || *last != 0) {
    sprintf(msg, "Expected a number for token %d of %.20s", n, av[0]);
    Usage(msg);
  }
  return result;
}


x86 assembly (clang, -O0):
<numeric_arg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,-0x1c(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     117f <numeric_arg+0x4f>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11a2 <numeric_arg+0x72>
lea    -0x70(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
lea    0xe6c(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x70(%rbp),%rdi
call   1030 <Usage@plt>
mov    -0x1c(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<numeric_arg>:
push   %rbp
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    %esi,%ebx
mov    %rdi,%rbp
movq   $0x0,0x8(%rsp)
movslq %esi,%rax
mov    (%rdi,%rax,8),%rdi
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,%r14d
mov    0x8(%rsp),%rax
test   %rax,%rax
je     116e <numeric_arg+0x3e>
cmpb   $0x0,(%rax)
je     1190 <numeric_arg+0x60>
mov    0x0(%rbp),%rcx
lea    0xe87(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %ebx,%edx
call   1050 <sprintf@plt>
mov    %rbp,%rdi
call   1030 <Usage@plt>
mov    %r14d,%eax
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"Expected a number for token %d of %.20s\00"
define i32 @numeric_arg(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [80 x i8]
store i8** %0, i8*** %3
store i32 %1, i32* %4
store i8* null, i8** %5
%8 = load i8**, i8*** %3
%9 = load i32, i32* %4
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8*, i8** %8, i64 %10
%12 = load i8*, i8** %11
%13 = call i32 @strtol(i8* %12, i8** %5, i32 10)
store i32 %13, i32* %6
%14 = load i8*, i8** %5
%15 = icmp eq i8* %14, null
br i1 %15, label %21, label %16
16: ; preds = %2
%17 = load i8*, i8** %5
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %30
21: ; preds = %16, %2
%22 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%23 = load i32, i32* %4
%24 = load i8**, i8*** %3
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %23, i8* %26)
%28 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%29 = call i32 @Usage(i8* %28)
br label %30
30: ; preds = %21, %16
%31 = load i32, i32* %6
ret i32 %31
}

LLVM IR (-O2):
@.str = [40 x i8] c"Expected a number for token %d of %.20s\00"
define i32 @numeric_arg(i8** nocapture %0, i32 %1) {
%3 = alloca i8*
%4 = alloca [80 x i8]
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%6 = sext i32 %1 to i64
%7 = getelementptr inbounds i8*, i8** %0, i64 %6
%8 = load i8*, i8** %7
%9 = call i32 @strtol(i8* %8, i8** %3, i32 10)
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%11 = load i8*, i8** %3
%12 = icmp eq i8* %11, null
br i1 %12, label %16, label %13
13: ; preds = %2
%14 = load i8, i8* %11
%15 = icmp eq i8 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %13, %2
%17 = load i8*, i8** %0
%18 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %1, i8* %17)
%19 = call i32 @Usage(i8* %10)
br label %20
20: ; preds = %16, %13
ret i32 %9
}