#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*/ assert(char const *);
int atoi(char const *);
int /*<<< orphan*/ isnumstr(char const *);
int /*<<< orphan*/ perr(char *, char *);
char *strtok(int /*<<< orphan*/, char *);
int intarg(char *op) {
  const char *tok;
  if (!(tok = strtok(0, " ")) || !isnumstr(tok) || strtok(0, " "))
    perr("expected integer argument for '%s'", op);
  assert(tok);
  return atoi(tok);
}


x86 assembly (clang, -O0):
<intarg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
xor    %edi,%edi
lea    0xe9b(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11a2 <intarg+0x52>
mov    -0x10(%rbp),%rdi
call   1050 <isnumstr@plt>
cmp    $0x0,%eax
je     11a2 <intarg+0x52>
xor    %edi,%edi
lea    0xe6d(%rip),%rsi
call   1060 <strtok@plt>
cmp    $0x0,%rax
je     11b2 <intarg+0x62>
mov    -0x8(%rbp),%rsi
lea    0xe55(%rip),%rdi
call   1030 <perr@plt>
mov    -0x10(%rbp),%rdi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1070 <atoi@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<intarg>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xea2(%rip),%rsi
xor    %edi,%edi
call   1060 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
je     118c <intarg+0x3c>
mov    %rbx,%rdi
call   1050 <isnumstr@plt>
test   %eax,%eax
je     118c <intarg+0x3c>
lea    0xe80(%rip),%rsi
xor    %edi,%edi
call   1060 <strtok@plt>
test   %rax,%rax
je     119b <intarg+0x4b>
lea    0xe6f(%rip),%rdi
mov    %r14,%rsi
call   1030 <perr@plt>
mov    %rbx,%rdi
call   1040 <assert@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1070 <atoi@plt>

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [35 x i8] c"expected integer argument for '%s'\00"
define i32 @intarg(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = call i8* @strtok(i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %4, i8** %3
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %13
6: ; preds = %1
%7 = load i8*, i8** %3
%8 = call i32 @isnumstr(i8* %7)
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = call i8* @strtok(i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %16
13: ; preds = %10, %6, %1
%14 = load i8*, i8** %2
%15 = call i32 @perr(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %13, %10
%17 = load i8*, i8** %3
%18 = call i32 @assert(i8* %17)
%19 = load i8*, i8** %3
%20 = call i32 @atoi(i8* %19)
ret i32 %20
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [35 x i8] c"expected integer argument for '%s'\00"
define i32 @intarg(i8* %0) {
%2 = tail call i8* @strtok(i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %10, label %4
4: ; preds = %1
%5 = tail call i32 @isnumstr(i8* %2)
%6 = icmp eq i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = tail call i8* @strtok(i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i8* %8, null
br i1 %9, label %12, label %10
10: ; preds = %7, %4, %1
%11 = tail call i32 @perr(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %12
12: ; preds = %10, %7
%13 = tail call i32 @assert(i8* %2)
%14 = tail call i32 @atoi(i8* %2)
ret i32 %14
}