#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*/ fatal(char *, char *);
int strtol(char *, char **, int);
int arg_pgno(char *p, int *subno) {
  char *end;
  int pgno;
  *subno = 0x3f7f;
  if (*p) {
    pgno = strtol(p, &end, 16);
    if ((*end == ':' || *end == '/' || *end == '.') && end[1])
      *subno = strtol(end + 1, &end, 16);
    if (*end == 0)
      if (pgno >= 0x100 && pgno <= 0x999)
        if (*subno == 0x3f7f || (*subno >= 0x00 && *subno <= 0x3f7f))
          return pgno;
  }
  fatal("%s: invalid page number", p);
}


x86 assembly (clang, -O0):
<arg_pgno>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x3f7f,(%rax)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     122c <arg_pgno+0x10c>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x10,%edx
call   1030 <strtol@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
je     118c <arg_pgno+0x6c>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     118c <arg_pgno+0x6c>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11bb <arg_pgno+0x9b>
mov    -0x20(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     11bb <arg_pgno+0x9b>
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
lea    -0x20(%rbp),%rsi
mov    $0x10,%edx
call   1030 <strtol@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1227 <arg_pgno+0x107>
cmpl   $0x100,-0x24(%rbp)
jl     1222 <arg_pgno+0x102>
cmpl   $0x999,-0x24(%rbp)
jg     1222 <arg_pgno+0x102>
mov    -0x18(%rbp),%rax
cmpl   $0x3f7f,(%rax)
je     1212 <arg_pgno+0xf2>
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jl     121d <arg_pgno+0xfd>
mov    -0x18(%rbp),%rax
cmpl   $0x3f7f,(%rax)
jg     121d <arg_pgno+0xfd>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    123c <arg_pgno+0x11c>
jmp    1222 <arg_pgno+0x102>
jmp    1227 <arg_pgno+0x107>
jmp    122c <arg_pgno+0x10c>
mov    -0x10(%rbp),%rsi
lea    0xdc9(%rip),%rdi
call   1040 <fatal@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arg_pgno>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movl   $0x3f7f,(%rsi)
cmpb   $0x0,(%rdi)
je     11ab <arg_pgno+0x8b>
mov    %rsi,%r14
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x10,%edx
call   1030 <strtol@plt>
mov    %eax,%r15d
mov    0x8(%rsp),%rdi
movzbl (%rdi),%eax
cmp    $0x3a,%rax
ja     1190 <arg_pgno+0x70>
movabs $0x400c00000000000,%rcx
bt     %rax,%rcx
jae    1190 <arg_pgno+0x70>
cmpb   $0x0,0x1(%rdi)
je     11ab <arg_pgno+0x8b>
add    $0x1,%rdi
lea    0x8(%rsp),%rsi
mov    $0x10,%edx
call   1030 <strtol@plt>
mov    %eax,(%r14)
mov    0x8(%rsp),%rax
mov    (%rax),%al
test   %al,%al
jne    11ab <arg_pgno+0x8b>
lea    -0x100(%r15),%eax
cmp    $0x899,%eax
ja     11ab <arg_pgno+0x8b>
cmpl   $0x3f80,(%r14)
jb     11ba <arg_pgno+0x9a>
lea    0xe4e(%rip),%rdi
mov    %rbx,%rsi
call   1040 <fatal@plt>
mov    %r15d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [24 x i8] c"%s: invalid page number\00"
define i32 @arg_pgno(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
%8 = load i32*, i32** %5
store i32 16255, i32* %8
%9 = load i8*, i8** %4
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %68
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i32 @strtol(i8* %13, i8** %6, i32 16)
store i32 %14, i32* %7
%15 = load i8*, i8** %6
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 58
br i1 %18, label %29, label %19
19: ; preds = %12
%20 = load i8*, i8** %6
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 47
br i1 %23, label %29, label %24
24: ; preds = %19
%25 = load i8*, i8** %6
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 46
br i1 %28, label %29, label %40
29: ; preds = %24, %19, %12
%30 = load i8*, i8** %6
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %29
%36 = load i8*, i8** %6
%37 = getelementptr inbounds i8, i8* %36, i64 1
%38 = call i32 @strtol(i8* %37, i8** %6, i32 16)
%39 = load i32*, i32** %5
store i32 %38, i32* %39
br label %40
40: ; preds = %35, %29, %24
%41 = load i8*, i8** %6
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %67
45: ; preds = %40
%46 = load i32, i32* %7
%47 = icmp sge i32 %46, 256
br i1 %47, label %48, label %66
48: ; preds = %45
%49 = load i32, i32* %7
%50 = icmp sle i32 %49, 2457
br i1 %50, label %51, label %66
51: ; preds = %48
%52 = load i32*, i32** %5
%53 = load i32, i32* %52
%54 = icmp eq i32 %53, 16255
br i1 %54, label %63, label %55
55: ; preds = %51
%56 = load i32*, i32** %5
%57 = load i32, i32* %56
%58 = icmp sge i32 %57, 0
br i1 %58, label %59, label %65
59: ; preds = %55
%60 = load i32*, i32** %5
%61 = load i32, i32* %60
%62 = icmp sle i32 %61, 16255
br i1 %62, label %63, label %65
63: ; preds = %59, %51
%64 = load i32, i32* %7
store i32 %64, i32* %3
br label %71
65: ; preds = %59, %55
br label %66
66: ; preds = %65, %48, %45
br label %67
67: ; preds = %66, %40
br label %68
68: ; preds = %67, %2
%69 = load i8*, i8** %4
%70 = call i32 @fatal(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %69)
br label %71
71: ; preds = %68, %63
%72 = load i32, i32* %3
ret i32 %72
}

LLVM IR (-O2):
@.str = [24 x i8] c"%s: invalid page number\00"
define i32 @arg_pgno(i8* %0, i32* nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i32 16255, i32* %1
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %28, label %7
7: ; preds = %2
%8 = call i32 @strtol(i8* %0, i8** %3, i32 16)
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
switch i8 %10, label %19 [
i8 58, label %11
i8 47, label %11
i8 46, label %11
]
11: ; preds = %7, %7, %7
%12 = getelementptr inbounds i8, i8* %9, i64 1
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %28, label %15
15: ; preds = %11
%16 = call i32 @strtol(i8* %12, i8** %3, i32 16)
store i32 %16, i32* %1
%17 = load i8*, i8** %3
%18 = load i8, i8* %17
br label %19
19: ; preds = %7, %15
%20 = phi i8 [ %10, %7 ], [ %18, %15 ]
%21 = icmp eq i8 %20, 0
%22 = add i32 %8, -256
%23 = icmp ult i32 %22, 2202
%24 = select i1 %21, i1 %23, i1 false
br i1 %24, label %25, label %28
25: ; preds = %19
%26 = load i32, i32* %1
%27 = icmp ult i32 %26, 16256
br i1 %27, label %30, label %28
28: ; preds = %11, %25, %19, %2
%29 = tail call i32 @fatal(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %30
30: ; preds = %25, %28
%31 = phi i32 [ undef, %28 ], [ %8, %25 ]
ret i32 %31
}