#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ gt_abort(int /*<<< orphan*/ *);
int longvalue(char **, long *);
int /*<<< orphan*/ stderr;
void arg_range(char **ps, long *val1, long *val2, char *id) {
  int code;
  char *s;
  s = *ps;
  code = longvalue(&s, val1);
  if (code != 1) {
    if (code == 3) {
      fprintf(stderr, ">E %s: bad range\n", id);
      gt_abort(NULL);
    } else if (code == 2) {
      fprintf(stderr, ">E %s: value too big\n", id);
      gt_abort(NULL);
    }
  } else if (*s != ':' && *s != '-') {
    fprintf(stderr, ">E %s: missing value\n", id);
    gt_abort(NULL);
  } else
    *val1 = -(2000000000L + 1L);
  if (*s == ':' || *s == '-') {
    ++s;
    code = longvalue(&s, val2);
    if (code == 1)
      *val2 = (2000000000L + 1L);
    else if (code == 2) {
      fprintf(stderr, ">E %s: value too big\n", id);
      gt_abort(NULL);
    } else if (code == 3) {
      fprintf(stderr, ">E %s: illegal range\n", id);
      gt_abort(NULL);
    }
  } else
    *val2 = *val1;
  *ps = s;
}


x86 assembly (clang, -O0):
<arg_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rsi
lea    -0x30(%rbp),%rdi
call   1050 <longvalue@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
je     11d4 <arg_range+0xa4>
cmpl   $0x3,-0x24(%rbp)
jne    119e <arg_range+0x6e>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe75(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1030 <gt_abort@plt>
jmp    11cf <arg_range+0x9f>
cmpl   $0x2,-0x24(%rbp)
jne    11ca <arg_range+0x9a>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe56(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1030 <gt_abort@plt>
jmp    11cf <arg_range+0x9f>
jmp    122b <arg_range+0xfb>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
je     121b <arg_range+0xeb>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     121b <arg_range+0xeb>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe20(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1030 <gt_abort@plt>
jmp    1226 <arg_range+0xf6>
mov    -0x10(%rbp),%rax
movq   $0xffffffff88ca6bff,(%rax)
jmp    122b <arg_range+0xfb>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
je     124b <arg_range+0x11b>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    12ed <arg_range+0x1bd>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rsi
lea    -0x30(%rbp),%rdi
call   1050 <longvalue@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jne    1281 <arg_range+0x151>
mov    -0x18(%rbp),%rax
movq   $0x77359401,(%rax)
jmp    12e8 <arg_range+0x1b8>
cmpl   $0x2,-0x24(%rbp)
jne    12b2 <arg_range+0x182>
mov    0x2d4e(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xd73(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1030 <gt_abort@plt>
jmp    12e3 <arg_range+0x1b3>
cmpl   $0x3,-0x24(%rbp)
jne    12de <arg_range+0x1ae>
mov    0x2d1d(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xd6e(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1030 <gt_abort@plt>
jmp    12e3 <arg_range+0x1b3>
jmp    12e8 <arg_range+0x1b8>
jmp    12fb <arg_range+0x1cb>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arg_range>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r12
mov    (%rdi),%rax
mov    %rax,(%rsp)
mov    %rsp,%rdi
call   1050 <longvalue@plt>
cmp    $0x1,%eax
je     1174 <arg_range+0x44>
cmp    $0x2,%eax
je     118b <arg_range+0x5b>
cmp    $0x3,%eax
jne    11bc <arg_range+0x8c>
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
lea    0xe8e(%rip),%rsi
jmp    11ad <arg_range+0x7d>
mov    (%rsp),%rax
mov    (%rax),%al
cmp    $0x2d,%al
je     1182 <arg_range+0x52>
cmp    $0x3a,%al
jne    119d <arg_range+0x6d>
movq   $0xffffffff88ca6bff,(%rbx)
jmp    11bc <arg_range+0x8c>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
lea    0xe77(%rip),%rsi
jmp    11ad <arg_range+0x7d>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1030 <gt_abort@plt>
mov    (%rsp),%rax
mov    (%rax),%cl
cmp    $0x3a,%cl
je     11cc <arg_range+0x9c>
cmp    $0x2d,%cl
jne    11f7 <arg_range+0xc7>
add    $0x1,%rax
mov    %rax,(%rsp)
mov    %rsp,%rdi
mov    %r15,%rsi
call   1050 <longvalue@plt>
cmp    $0x3,%eax
je     11ff <arg_range+0xcf>
cmp    $0x2,%eax
je     1211 <arg_range+0xe1>
cmp    $0x1,%eax
jne    1230 <arg_range+0x100>
movq   $0x77359401,(%r15)
jmp    1230 <arg_range+0x100>
mov    (%rbx),%rax
mov    %rax,(%r15)
jmp    1230 <arg_range+0x100>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
lea    0xe2f(%rip),%rsi
jmp    1221 <arg_range+0xf1>
mov    0x2dc8(%rip),%rax
mov    (%rax),%edi
lea    0xdf1(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1030 <gt_abort@plt>
mov    (%rsp),%rax
mov    %rax,(%r12)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [18 x i8] c">E %s: bad range\0A\00"
@.str.1 = [22 x i8] c">E %s: value too big\0A\00"
@.str.2 = [22 x i8] c">E %s: missing value\0A\00"
@.str.3 = [22 x i8] c">E %s: illegal range\0A\00"
define void @arg_range(i8** %0, i64* %1, i64* %2, i8* %3) {
%5 = alloca i8**
%6 = alloca i64*
%7 = alloca i64*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
store i8** %0, i8*** %5
store i64* %1, i64** %6
store i64* %2, i64** %7
store i8* %3, i8** %8
%11 = load i8**, i8*** %5
%12 = load i8*, i8** %11
store i8* %12, i8** %10
%13 = load i64*, i64** %6
%14 = call i32 @longvalue(i8** %10, i64* %13)
store i32 %14, i32* %9
%15 = load i32, i32* %9
%16 = icmp ne i32 %15, 1
br i1 %16, label %17, label %35
17: ; preds = %4
%18 = load i32, i32* %9
%19 = icmp eq i32 %18, 3
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %8
%23 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = call i32 @gt_abort(i32* null)
br label %34
25: ; preds = %17
%26 = load i32, i32* %9
%27 = icmp eq i32 %26, 2
br i1 %27, label %28, label %33
28: ; preds = %25
%29 = load i32, i32* @stderr
%30 = load i8*, i8** %8
%31 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = call i32 @gt_abort(i32* null)
br label %33
33: ; preds = %28, %25
br label %34
34: ; preds = %33, %20
br label %53
35: ; preds = %4
%36 = load i8*, i8** %10
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 58
br i1 %39, label %40, label %50
40: ; preds = %35
%41 = load i8*, i8** %10
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp ne i32 %43, 45
br i1 %44, label %45, label %50
45: ; preds = %40
%46 = load i32, i32* @stderr
%47 = load i8*, i8** %8
%48 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %47)
%49 = call i32 @gt_abort(i32* null)
br label %52
50: ; preds = %40, %35
%51 = load i64*, i64** %6
store i64 -2000000001, i64* %51
br label %52
52: ; preds = %50, %45
br label %53
53: ; preds = %52, %34
%54 = load i8*, i8** %10
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 58
br i1 %57, label %63, label %58
58: ; preds = %53
%59 = load i8*, i8** %10
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 45
br i1 %62, label %63, label %91
63: ; preds = %58, %53
%64 = load i8*, i8** %10
%65 = getelementptr inbounds i8, i8* %64, i32 1
store i8* %65, i8** %10
%66 = load i64*, i64** %7
%67 = call i32 @longvalue(i8** %10, i64* %66)
store i32 %67, i32* %9
%68 = load i32, i32* %9
%69 = icmp eq i32 %68, 1
br i1 %69, label %70, label %72
70: ; preds = %63
%71 = load i64*, i64** %7
store i64 2000000001, i64* %71
br label %90
72: ; preds = %63
%73 = load i32, i32* %9
%74 = icmp eq i32 %73, 2
br i1 %74, label %75, label %80
75: ; preds = %72
%76 = load i32, i32* @stderr
%77 = load i8*, i8** %8
%78 = call i32 @fprintf(i32 %76, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %77)
%79 = call i32 @gt_abort(i32* null)
br label %89
80: ; preds = %72
%81 = load i32, i32* %9
%82 = icmp eq i32 %81, 3
br i1 %82, label %83, label %88
83: ; preds = %80
%84 = load i32, i32* @stderr
%85 = load i8*, i8** %8
%86 = call i32 @fprintf(i32 %84, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %85)
%87 = call i32 @gt_abort(i32* null)
br label %88
88: ; preds = %83, %80
br label %89
89: ; preds = %88, %75
br label %90
90: ; preds = %89, %70
br label %95
91: ; preds = %58
%92 = load i64*, i64** %6
%93 = load i64, i64* %92
%94 = load i64*, i64** %7
store i64 %93, i64* %94
br label %95
95: ; preds = %91, %90
%96 = load i8*, i8** %10
%97 = load i8**, i8*** %5
store i8* %96, i8** %97
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [18 x i8] c">E %s: bad range\0A\00"
@.str.1 = [22 x i8] c">E %s: value too big\0A\00"
@.str.2 = [22 x i8] c">E %s: missing value\0A\00"
@.str.3 = [22 x i8] c">E %s: illegal range\0A\00"
define void @arg_range(i8** nocapture %0, i64* %1, i64* %2, i8* %3) {
%5 = alloca i8*
%6 = bitcast i8** %5 to i8*
%7 = load i8*, i8** %0
store i8* %7, i8** %5
%8 = call i32 @longvalue(i8** %5, i64* %1)
switch i32 %8, label %25 [
i32 1, label %17
i32 3, label %9
i32 2, label %13
]
9: ; preds = %4
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %3)
%12 = call i32 @gt_abort(i32* null)
br label %25
13: ; preds = %4
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%16 = call i32 @gt_abort(i32* null)
br label %25
17: ; preds = %4
%18 = load i8*, i8** %5
%19 = load i8, i8* %18
switch i8 %19, label %20 [
i8 58, label %24
i8 45, label %24
]
20: ; preds = %17
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%23 = call i32 @gt_abort(i32* null)
br label %25
24: ; preds = %17, %17
store i64 -2000000001, i64* %1
br label %25
25: ; preds = %4, %20, %24, %9, %13
%26 = load i8*, i8** %5
%27 = load i8, i8* %26
switch i8 %27, label %40 [
i8 58, label %28
i8 45, label %28
]
28: ; preds = %25, %25
%29 = getelementptr inbounds i8, i8* %26, i64 1
store i8* %29, i8** %5
%30 = call i32 @longvalue(i8** %5, i64* %2)
switch i32 %30, label %42 [
i32 1, label %31
i32 2, label %32
i32 3, label %36
]
31: ; preds = %28
store i64 2000000001, i64* %2
br label %42
32: ; preds = %28
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%35 = call i32 @gt_abort(i32* null)
br label %42
36: ; preds = %28
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%39 = call i32 @gt_abort(i32* null)
br label %42
40: ; preds = %25
%41 = load i64, i64* %1
store i64 %41, i64* %2
br label %42
42: ; preds = %28, %31, %36, %32, %40
%43 = load i8*, i8** %5
store i8* %43, i8** %0
ret void
}