#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 */
unsigned long GetASN(char *);
scalar_t__ GetASNName(unsigned long, char *, int);
int /*<<< orphan*/ Usage(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
int optind;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int c;
  int verbose = 1;
  int help = 0;
  unsigned long int asn;
  char *address;
  char asn_name[256];
  while ((c = getopt(argc, argv, "hs")) != -1) {
    switch (c) {
    case 'h':
      help = 1;
      break;
    case 's':
      verbose = 0;
      break;
    default:
      Usage(argv[0]);
    }
  }
  if (help)
    Usage(argv[0]);
  if (optind + 1 != argc) {
    fprintf(stderr, "Missing argument: address\n");
    Usage(argv[0]);
  }
  address = argv[optind];
  asn = GetASN(address);
  if (verbose)
    printf("ASN of %s = %ld (based on asn.cymru.com)\n", address, asn);
  else
    printf("%ld", asn);
  if (GetASNName(asn, asn_name, 256))
    fprintf(stderr, "Cannot get the name of ASN %d.\n", asn);
  else if (verbose)
    printf("\tASN%ld is %s\n", asn, asn_name);
  else
    printf(" (%s)", asn_name);
  return (int)asn;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe6b(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     11fa <main+0x9a>
mov    -0x14(%rbp),%eax
mov    %eax,-0x134(%rbp)
sub    $0x68,%eax
je     11d1 <main+0x71>
jmp    11bd <main+0x5d>
mov    -0x134(%rbp),%eax
sub    $0x73,%eax
je     11dd <main+0x7d>
jmp    11e9 <main+0x89>
movl   $0x1,-0x1c(%rbp)
jmp    11f5 <main+0x95>
movl   $0x0,-0x18(%rbp)
jmp    11f5 <main+0x95>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <Usage@plt>
jmp    1187 <main+0x27>
cmpl   $0x0,-0x1c(%rbp)
je     1210 <main+0xb0>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <Usage@plt>
mov    0x2dd1(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
cmp    -0x8(%rbp),%eax
je     1248 <main+0xe8>
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
lea    0xdce(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <Usage@plt>
mov    -0x10(%rbp),%rax
mov    0x2d95(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <GetASN@plt>
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1290 <main+0x130>
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a2 <main+0x142>
mov    -0x28(%rbp),%rsi
lea    0xdad(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
lea    -0x130(%rbp),%rsi
mov    $0x100,%edx
call   1080 <GetASNName@plt>
cmp    $0x0,%rax
je     12e1 <main+0x181>
mov    0x2d10(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xd77(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1323 <main+0x1c3>
cmpl   $0x0,-0x18(%rbp)
je     1309 <main+0x1a9>
mov    -0x28(%rbp),%rsi
lea    -0x130(%rbp),%rdx
lea    0xd6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    131e <main+0x1be>
lea    -0x130(%rbp),%rsi
lea    0xd64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1323 <main+0x1c3>
mov    -0x28(%rbp),%rax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x1,%r15d
mov    $0x1,%r12b
lea    0xe7c(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1070 <getopt@plt>
cmp    $0xffffffff,%eax
je     11c0 <main+0x60>
cmp    $0x68,%eax
je     11b6 <main+0x56>
cmp    $0x73,%eax
je     11bb <main+0x5b>
mov    (%rbx),%rdi
call   1040 <Usage@plt>
jmp    1190 <main+0x30>
xor    %r12d,%r12d
jmp    1190 <main+0x30>
xor    %r15d,%r15d
jmp    1190 <main+0x30>
test   $0x1,%r12b
jne    11ce <main+0x6e>
mov    (%rbx),%rdi
call   1040 <Usage@plt>
mov    0x2e13(%rip),%r14
mov    (%r14),%eax
lea    0x1(%rax),%ecx
cmp    %ebp,%ecx
je     1201 <main+0xa1>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
lea    0xe14(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%rdi
call   1040 <Usage@plt>
mov    (%r14),%eax
cltq
mov    (%rbx,%rax,8),%rbp
mov    %rbp,%rdi
call   1060 <GetASN@plt>
mov    %rax,%rbx
test   %r15d,%r15d
je     1256 <main+0xf6>
lea    0xe00(%rip),%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0x100,%edx
call   1080 <GetASNName@plt>
test   %rax,%rax
jne    127c <main+0x11c>
lea    0xe25(%rip),%rdi
mov    %rsp,%rdx
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1296 <main+0x136>
lea    0xdeb(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0x100,%edx
call   1080 <GetASNName@plt>
test   %rax,%rax
je     12a8 <main+0x148>
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
lea    0xdc0(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %ebx,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdcc(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1296 <main+0x136>

LLVM IR (-O0):
@.str = [3 x i8] c"hs\00"
@optind = global i32 0
@stderr = global i32 0
@.str.1 = [27 x i8] c"Missing argument: address\0A\00"
@.str.2 = [42 x i8] c"ASN of %s = %ld (based on asn.cymru.com)\0A\00"
@.str.3 = [4 x i8] c"%ld\00"
@.str.4 = [32 x i8] c"Cannot get the name of ASN %d.\0A\00"
@.str.5 = [15 x i8] c"\09ASN%ld is %s\0A\00"
@.str.6 = [6 x i8] c" (%s)\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
%10 = alloca i8*
%11 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %7
store i32 0, i32* %8
br label %12
12: ; preds = %26, %2
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call i32 @getopt(i32 %13, i8** %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %15, i32* %6
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %27
17: ; preds = %12
%18 = load i32, i32* %6
switch i32 %18, label %21 [
i32 104, label %19
i32 115, label %20
]
19: ; preds = %17
store i32 1, i32* %8
br label %26
20: ; preds = %17
store i32 0, i32* %7
br label %26
21: ; preds = %17
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 @Usage(i8* %24)
br label %26
26: ; preds = %21, %20, %19
br label %12
27: ; preds = %12
%28 = load i32, i32* %8
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 0
%33 = load i8*, i8** %32
%34 = call i32 @Usage(i8* %33)
br label %35
35: ; preds = %30, %27
%36 = load i32, i32* @optind
%37 = add nsw i32 %36, 1
%38 = load i32, i32* %4
%39 = icmp ne i32 %37, %38
br i1 %39, label %40, label %47
40: ; preds = %35
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 0
%45 = load i8*, i8** %44
%46 = call i32 @Usage(i8* %45)
br label %47
47: ; preds = %40, %35
%48 = load i8**, i8*** %5
%49 = load i32, i32* @optind
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %48, i64 %50
%52 = load i8*, i8** %51
store i8* %52, i8** %10
%53 = load i8*, i8** %10
%54 = call i64 @GetASN(i8* %53)
store i64 %54, i64* %9
%55 = load i32, i32* %7
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %61
57: ; preds = %47
%58 = load i8*, i8** %10
%59 = load i64, i64* %9
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %58, i64 %59)
br label %64
61: ; preds = %47
%62 = load i64, i64* %9
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %62)
br label %64
64: ; preds = %61, %57
%65 = load i64, i64* %9
%66 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%67 = call i64 @GetASNName(i64 %65, i8* %66, i32 256)
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %73
69: ; preds = %64
%70 = load i32, i32* @stderr
%71 = load i64, i64* %9
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i64 %71)
br label %84
73: ; preds = %64
%74 = load i32, i32* %7
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %80
76: ; preds = %73
%77 = load i64, i64* %9
%78 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i64 %77, i8* %78)
br label %83
80: ; preds = %73
%81 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* %81)
br label %83
83: ; preds = %80, %76
br label %84
84: ; preds = %83, %69
%85 = load i64, i64* %9
%86 = trunc i64 %85 to i32
ret i32 %86
}

LLVM IR (-O2):
@.str = [3 x i8] c"hs\00"
@optind = global i32 0
@stderr = global i32 0
@.str.1 = [27 x i8] c"Missing argument: address\0A\00"
@.str.2 = [42 x i8] c"ASN of %s = %ld (based on asn.cymru.com)\0A\00"
@.str.3 = [4 x i8] c"%ld\00"
@.str.4 = [32 x i8] c"Cannot get the name of ASN %d.\0A\00"
@.str.5 = [15 x i8] c"\09ASN%ld is %s\0A\00"
@.str.6 = [6 x i8] c" (%s)\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
br label %5
5: ; preds = %10, %2
%6 = phi i1 [ true, %2 ], [ false, %10 ]
%7 = phi i32 [ 1, %2 ], [ %9, %10 ]
br label %8
8: ; preds = %10, %5
%9 = phi i32 [ %7, %5 ], [ 0, %10 ]
br label %10
10: ; preds = %8, %12
%11 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %11, label %12 [
i32 -1, label %15
i32 104, label %5
i32 115, label %8
]
12: ; preds = %10
%13 = load i8*, i8** %1
%14 = tail call i32 @Usage(i8* %13)
br label %10
15: ; preds = %10
br i1 %6, label %19, label %16
16: ; preds = %15
%17 = load i8*, i8** %1
%18 = tail call i32 @Usage(i8* %17)
br label %19
19: ; preds = %16, %15
%20 = load i32, i32* @optind
%21 = add nsw i32 %20, 1
%22 = icmp eq i32 %21, %0
br i1 %22, label %29, label %23
23: ; preds = %19
%24 = load i32, i32* @stderr
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%26 = load i8*, i8** %1
%27 = tail call i32 @Usage(i8* %26)
%28 = load i32, i32* @optind
br label %29
29: ; preds = %23, %19
%30 = phi i32 [ %28, %23 ], [ %20, %19 ]
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %1, i64 %31
%33 = load i8*, i8** %32
%34 = tail call i64 @GetASN(i8* %33)
%35 = icmp eq i32 %9, 0
br i1 %35, label %36, label %40
36: ; preds = %29
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %34)
%38 = call i64 @GetASNName(i64 %34, i8* %4, i32 256)
%39 = icmp eq i64 %38, 0
br i1 %39, label %49, label %44
40: ; preds = %29
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %33, i64 %34)
%42 = call i64 @GetASNName(i64 %34, i8* %4, i32 256)
%43 = icmp eq i64 %42, 0
br i1 %43, label %47, label %44
44: ; preds = %40, %36
%45 = load i32, i32* @stderr
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i64 %34)
br label %51
47: ; preds = %40
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i64 %34, i8* %4)
br label %51
49: ; preds = %36
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* %4)
br label %51
51: ; preds = %47, %49, %44
%52 = trunc i64 %34 to i32
ret i32 %52
}