#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 *);
int /*<<< orphan*/ errx(int, char *, char *);
int /*<<< orphan*/ isdigit(unsigned char);
char *getnum(int *num, char *p, int strict) {
  char *t = p;
  if (!isdigit((unsigned char)*++t)) {
    if (strict || *t == '-' || *t == '+')
      errx(1, "option %.1s requires an unsigned integer", p);
    *num = 0;
    return (p);
  }
  *num = atoi(t);
  while (*++t)
    if (!isdigit((unsigned char)*t))
      break;
  return (--t);
}


x86 assembly (clang, -O0):
<getnum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movzbl 0x1(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11c2 <getnum+0x92>
cmpl   $0x0,-0x1c(%rbp)
jne    1196 <getnum+0x66>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     1196 <getnum+0x66>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
jne    11ab <getnum+0x7b>
mov    -0x18(%rbp),%rdx
mov    $0x1,%edi
lea    0xe5a(%rip),%rsi
call   1040 <errx@plt>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    121b <getnum+0xeb>
mov    -0x28(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
cmpb   $0x0,0x1(%rax)
je     120b <getnum+0xdb>
mov    -0x28(%rbp),%rax
movzbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    1206 <getnum+0xd6>
jmp    120b <getnum+0xdb>
jmp    11d3 <getnum+0xa3>
mov    -0x28(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getnum>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%r14
lea    0x1(%rsi),%rbx
movzbl 0x1(%rsi),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     117d <getnum+0x4d>
mov    %rbx,%rdi
call   1050 <atoi@plt>
mov    %eax,(%r14)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%r15
movzbl 0x1(%rbx),%eax
test   %al,%al
je     119c <getnum+0x6c>
lea    0x1(%r15),%rbx
movzbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
jne    1160 <getnum+0x30>
jmp    119c <getnum+0x6c>
test   %ebp,%ebp
je     11aa <getnum+0x7a>
lea    0xe78(%rip),%rsi
mov    $0x1,%edi
mov    %r15,%rdx
call   1040 <errx@plt>
movl   $0x0,(%r14)
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rbx),%al
cmp    $0x2d,%al
je     1181 <getnum+0x51>
cmp    $0x2b,%al
je     1181 <getnum+0x51>
jmp    1195 <getnum+0x65>

LLVM IR (-O0):
@.str = [41 x i8] c"option %.1s requires an unsigned integer\00"
define i8* @getnum(i32* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%9 = load i8*, i8** %6
store i8* %9, i8** %8
%10 = load i8*, i8** %8
%11 = getelementptr inbounds i8, i8* %10, i32 1
store i8* %11, i8** %8
%12 = load i8, i8* %11
%13 = call i32 @isdigit(i8 zeroext %12)
%14 = icmp ne i32 %13, 0
br i1 %14, label %34, label %15
15: ; preds = %3
%16 = load i32, i32* %7
%17 = icmp ne i32 %16, 0
br i1 %17, label %28, label %18
18: ; preds = %15
%19 = load i8*, i8** %8
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 45
br i1 %22, label %28, label %23
23: ; preds = %18
%24 = load i8*, i8** %8
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 43
br i1 %27, label %28, label %31
28: ; preds = %23, %18, %15
%29 = load i8*, i8** %6
%30 = call i32 @errx(i32 1, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %28, %23
%32 = load i32*, i32** %5
store i32 0, i32* %32
%33 = load i8*, i8** %6
store i8* %33, i8** %4
br label %53
34: ; preds = %3
%35 = load i8*, i8** %8
%36 = call i32 @atoi(i8* %35)
%37 = load i32*, i32** %5
store i32 %36, i32* %37
br label %38
38: ; preds = %49, %34
%39 = load i8*, i8** %8
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %8
%41 = load i8, i8* %40
%42 = icmp ne i8 %41, 0
br i1 %42, label %43, label %50
43: ; preds = %38
%44 = load i8*, i8** %8
%45 = load i8, i8* %44
%46 = call i32 @isdigit(i8 zeroext %45)
%47 = icmp ne i32 %46, 0
br i1 %47, label %49, label %48
48: ; preds = %43
br label %50
49: ; preds = %43
br label %38
50: ; preds = %48, %38
%51 = load i8*, i8** %8
%52 = getelementptr inbounds i8, i8* %51, i32 -1
store i8* %52, i8** %8
store i8* %52, i8** %4
br label %53
53: ; preds = %50, %31
%54 = load i8*, i8** %4
ret i8* %54
}

LLVM IR (-O2):
@.str = [41 x i8] c"option %.1s requires an unsigned integer\00"
define i8* @getnum(i32* nocapture writeonly %0, i8* %1, i32 %2) {
%4 = getelementptr inbounds i8, i8* %1, i64 1
%5 = load i8, i8* %4
%6 = tail call i32 @isdigit(i8 zeroext %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %3
%9 = icmp eq i32 %2, 0
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = load i8, i8* %4
switch i8 %11, label %14 [
i8 45, label %12
i8 43, label %12
]
12: ; preds = %10, %10, %8
%13 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %14
14: ; preds = %10, %12
store i32 0, i32* %0
br label %25
15: ; preds = %3
%16 = tail call i32 @atoi(i8* %4)
store i32 %16, i32* %0
br label %17
17: ; preds = %22, %15
%18 = phi i8* [ %4, %15 ], [ %19, %22 ]
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %17
%23 = tail call i32 @isdigit(i8 zeroext %20)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %17
25: ; preds = %17, %22, %14
%26 = phi i8* [ %1, %14 ], [ %18, %22 ], [ %18, %17 ]
ret i8* %26
}