#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 atoi(char const *);
int /*<<< orphan*/ exit(int);
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);
    exit(1);
  }
  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   1050 <strtok@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11a2 <intarg+0x52>
mov    -0x10(%rbp),%rdi
call   1040 <isnumstr@plt>
cmp    $0x0,%eax
je     11a2 <intarg+0x52>
xor    %edi,%edi
lea    0xe6d(%rip),%rsi
call   1050 <strtok@plt>
cmp    $0x0,%rax
je     11bc <intarg+0x6c>
mov    -0x8(%rbp),%rsi
lea    0xe55(%rip),%rdi
call   1030 <perr@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1060 <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   1050 <strtok@plt>
test   %rax,%rax
je     119b <intarg+0x4b>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <isnumstr@plt>
test   %eax,%eax
je     119b <intarg+0x4b>
lea    0xe80(%rip),%rsi
xor    %edi,%edi
call   1050 <strtok@plt>
test   %rax,%rax
jne    119b <intarg+0x4b>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <atoi@plt>
lea    0xe60(%rip),%rdi
mov    %r14,%rsi
call   1030 <perr@plt>
mov    $0x1,%edi
call   1070 <exit@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 %17
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)
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %10
%18 = load i8*, i8** %3
%19 = call i32 @atoi(i8* %18)
ret i32 %19
}

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 %13, 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)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %7
%14 = tail call i32 @atoi(i8* %2)
ret i32 %14
}