#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 */
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
int EOF;
int getopt(int, char **, char *);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ inet_addr(char *);
int load(char *);
char *lookup(int /*<<< orphan*/ const);
char *optarg;
int optind;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sync(char *);
int main(int argc, char *argv[]) {
  bool opt_sync = false;
  bool opt_verbose = false;
  int opt;
  int i;
  int n;
  char *cache = "ipv4.records";
  while ((opt = getopt(argc, argv, "c:hsv")) != EOF) {
    switch (opt) {
    case 'c':
      cache = optarg;
      break;
    case 'h':
      break;
    case 's':
      opt_sync = true;
      break;
    case 'v':
      opt_verbose = true;
      break;
    case '?':
    default:
      printf("Try 'stuzi -h' for more information.");
      return 1;
    }
  }
  if (opt_sync) {
    sync(cache);
  }
  n = load(cache);
  if (opt_verbose) {
    printf("%d records loaded\n", n);
  }
  for (i = optind; i < argc; ++i) {
    const uint32_t addr = htonl(inet_addr(argv[i]));
    const char *country = lookup(addr);
    if (opt_verbose) {
      printf("%s: ", argv[i]);
    }
    printf("%s\n", country);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xe65(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe60(%rip),%rdx
call   1080 <getopt@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e24(%rip),%rcx
cmp    (%rcx),%eax
je     1270 <main+0x100>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x44(%rbp)
sub    $0x3f,%eax
je     124c <main+0xdc>
jmp    11d8 <main+0x68>
mov    -0x44(%rbp),%eax
sub    $0x63,%eax
je     121c <main+0xac>
jmp    11e9 <main+0x79>
mov    -0x44(%rbp),%eax
sub    $0x68,%eax
je     122f <main+0xbf>
jmp    11fa <main+0x8a>
mov    -0x44(%rbp),%eax
sub    $0x73,%eax
je     1234 <main+0xc4>
jmp    120b <main+0x9b>
mov    -0x44(%rbp),%eax
sub    $0x76,%eax
je     1240 <main+0xd0>
jmp    1251 <main+0xe1>
mov    0x2dd5(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    126b <main+0xfb>
jmp    126b <main+0xfb>
movl   $0x1,-0x14(%rbp)
jmp    126b <main+0xfb>
movl   $0x1,-0x18(%rbp)
jmp    126b <main+0xfb>
jmp    1251 <main+0xe1>
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1334 <main+0x1c4>
jmp    119f <main+0x2f>
cmpl   $0x0,-0x14(%rbp)
je     1283 <main+0x113>
mov    -0x30(%rbp),%rdi
call   1070 <sync@plt>
mov    -0x30(%rbp),%rdi
call   1090 <load@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     12aa <main+0x13a>
mov    -0x24(%rbp),%esi
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d27(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    132d <main+0x1bd>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <inet_addr@plt>
mov    %eax,%edi
call   1040 <htonl@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edi
call   1060 <lookup@plt>
mov    %rax,-0x40(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     130d <main+0x19d>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%rsi
lea    0xd38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12b6 <main+0x146>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %edi,%r13d
lea    0xec2(%rip),%rdx
call   1090 <getopt@plt>
mov    0x2e39(%rip),%rbx
cmp    (%rbx),%eax
jne    11bc <main+0x3c>
lea    0xe9e(%rip),%rdi
call   10a0 <load@plt>
jmp    126f <main+0xef>
lea    0xe8d(%rip),%rcx
mov    %rcx,0x10(%rsp)
xor    %ebp,%ebp
lea    0xe2f(%rip),%r15
lea    0xe85(%rip),%r12
movl   $0x0,0xc(%rsp)
jmp    1211 <main+0x91>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x2e01(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x10(%rsp)
mov    %r13d,%edi
mov    %r14,%rsi
mov    %r12,%rdx
call   1090 <getopt@plt>
cmp    (%rbx),%eax
je     123a <main+0xba>
add    $0xffffff9d,%eax
cmp    $0x13,%eax
ja     12f1 <main+0x171>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
mov    $0x1,%ebp
jmp    11ff <main+0x7f>
nopl   (%rax)
movl   $0x1,0xc(%rsp)
jmp    11ff <main+0x7f>
test   %ebp,%ebp
mov    0x10(%rsp),%rbx
je     124b <main+0xcb>
mov    %rbx,%rdi
call   1080 <sync@plt>
mov    %rbx,%rdi
call   10a0 <load@plt>
cmpl   $0x0,0xc(%rsp)
je     126f <main+0xef>
lea    0xe27(%rip),%rdi
xor    %r15d,%r15d
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1272 <main+0xf2>
mov    $0x1,%r15b
mov    0x2d5f(%rip),%rax
movslq (%rax),%rcx
xor    %eax,%eax
cmp    %r13d,%ecx
jge    12e2 <main+0x162>
lea    (%r14,%rcx,8),%r12
sub    %ecx,%r13d
lea    0xe0a(%rip),%r14
xor    %ebp,%ebp
jmp    12b1 <main+0x131>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1030 <puts@plt>
add    $0x1,%rbp
cmp    %ebp,%r13d
je     12e0 <main+0x160>
mov    (%r12,%rbp,8),%rdi
call   1060 <inet_addr@plt>
mov    %eax,%edi
call   1050 <htonl@plt>
mov    %eax,%edi
call   1070 <lookup@plt>
mov    %rax,%rbx
test   %r15b,%r15b
jne    12a0 <main+0x120>
mov    (%r12,%rbp,8),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12a0 <main+0x120>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd6b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
jmp    12e2 <main+0x162>

LLVM IR (-O0):
@.str = [13 x i8] c"ipv4.records\00"
@.str.1 = [6 x i8] c"c:hsv\00"
@EOF = global i32 0
@optarg = global i8* null
@.str.2 = [37 x i8] c"Try 'stuzi -h' for more information.\00"
@.str.3 = [19 x i8] c"%d records loaded\0A\00"
@optind = global i32 0
@.str.4 = [5 x i8] c"%s: \00"
@.str.5 = [4 x i8] c"%s\0A\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 i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %11
br label %14
14: ; preds = %30, %2
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = call i32 @getopt(i32 %15, i8** %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 %17, i32* %8
%18 = load i32, i32* @EOF
%19 = icmp ne i32 %17, %18
br i1 %19, label %20, label %31
20: ; preds = %14
%21 = load i32, i32* %8
switch i32 %21, label %28 [
i32 99, label %22
i32 104, label %24
i32 115, label %25
i32 118, label %26
i32 63, label %27
]
22: ; preds = %20
%23 = load i8*, i8** @optarg
store i8* %23, i8** %11
br label %30
24: ; preds = %20
br label %30
25: ; preds = %20
store i32 1, i32* %6
br label %30
26: ; preds = %20
store i32 1, i32* %7
br label %30
27: ; preds = %20
br label %28
28: ; preds = %20, %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %77
30: ; preds = %26, %25, %24, %22
br label %14
31: ; preds = %14
%32 = load i32, i32* %6
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i8*, i8** %11
%36 = call i32 @sync(i8* %35)
br label %37
37: ; preds = %34, %31
%38 = load i8*, i8** %11
%39 = call i32 @load(i8* %38)
store i32 %39, i32* %10
%40 = load i32, i32* %7
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %37
%43 = load i32, i32* %10
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %42, %37
%46 = load i32, i32* @optind
store i32 %46, i32* %9
br label %47
47: ; preds = %73, %45
%48 = load i32, i32* %9
%49 = load i32, i32* %4
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %76
51: ; preds = %47
%52 = load i8**, i8*** %5
%53 = load i32, i32* %9
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8*, i8** %52, i64 %54
%56 = load i8*, i8** %55
%57 = call i32 @inet_addr(i8* %56)
%58 = call i32 @htonl(i32 %57)
store i32 %58, i32* %12
%59 = load i32, i32* %12
%60 = call i8* @lookup(i32 %59)
store i8* %60, i8** %13
%61 = load i32, i32* %7
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %70
63: ; preds = %51
%64 = load i8**, i8*** %5
%65 = load i32, i32* %9
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8*, i8** %64, i64 %66
%68 = load i8*, i8** %67
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %68)
br label %70
70: ; preds = %63, %51
%71 = load i8*, i8** %13
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %71)
br label %73
73: ; preds = %70
%74 = load i32, i32* %9
%75 = add nsw i32 %74, 1
store i32 %75, i32* %9
br label %47
76: ; preds = %47
store i32 0, i32* %3
br label %77
77: ; preds = %76, %28
%78 = load i32, i32* %3
ret i32 %78
}

LLVM IR (-O2):
@.str = [13 x i8] c"ipv4.records\00"
@.str.1 = [6 x i8] c"c:hsv\00"
@EOF = global i32 0
@optarg = global i8* null
@.str.2 = [37 x i8] c"Try 'stuzi -h' for more information.\00"
@.str.3 = [19 x i8] c"%d records loaded\0A\00"
@optind = global i32 0
@.str.4 = [5 x i8] c"%s: \00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @load(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %35
8: ; preds = %2, %19
%9 = phi i32 [ %23, %19 ], [ %3, %2 ]
%10 = phi i32 [ %22, %19 ], [ 0, %2 ]
%11 = phi i8* [ %21, %19 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %2 ]
%12 = phi i32 [ %20, %19 ], [ 0, %2 ]
switch i32 %9, label %17 [
i32 99, label %13
i32 104, label %19
i32 115, label %15
i32 118, label %16
]
13: ; preds = %8
%14 = load i8*, i8** @optarg
br label %19
15: ; preds = %8
br label %19
16: ; preds = %8
br label %19
17: ; preds = %8
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
br label %56
19: ; preds = %16, %15, %8, %13
%20 = phi i32 [ 1, %16 ], [ %12, %15 ], [ %12, %8 ], [ %12, %13 ]
%21 = phi i8* [ %11, %16 ], [ %11, %15 ], [ %11, %8 ], [ %14, %13 ]
%22 = phi i32 [ %10, %16 ], [ 1, %15 ], [ %10, %8 ], [ %10, %13 ]
%23 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%24 = load i32, i32* @EOF
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %8
26: ; preds = %19
%27 = icmp eq i32 %22, 0
br i1 %27, label %30, label %28
28: ; preds = %26
%29 = tail call i32 @sync(i8* %21)
br label %30
30: ; preds = %28, %26
%31 = tail call i32 @load(i8* %21)
%32 = icmp eq i32 %20, 0
br i1 %32, label %35, label %33
33: ; preds = %30
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %31)
br label %35
35: ; preds = %6, %33, %30
%36 = phi i1 [ true, %6 ], [ false, %33 ], [ true, %30 ]
%37 = load i32, i32* @optind
%38 = icmp slt i32 %37, %0
br i1 %38, label %39, label %56
39: ; preds = %35
%40 = sext i32 %37 to i64
br label %41
41: ; preds = %39, %51
%42 = phi i64 [ %40, %39 ], [ %53, %51 ]
%43 = getelementptr inbounds i8*, i8** %1, i64 %42
%44 = load i8*, i8** %43
%45 = tail call i32 @inet_addr(i8* %44)
%46 = tail call i32 @htonl(i32 %45)
%47 = tail call i8* @lookup(i32 %46)
br i1 %36, label %51, label %48
48: ; preds = %41
%49 = load i8*, i8** %43
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %49)
br label %51
51: ; preds = %48, %41
%52 = tail call i32 @puts(i8* dereferenceable(1) %47)
%53 = add nsw i64 %42, 1
%54 = trunc i64 %53 to i32
%55 = icmp eq i32 %54, %0
br i1 %55, label %56, label %41
56: ; preds = %51, %35, %17
%57 = phi i32 [ 1, %17 ], [ 0, %35 ], [ 0, %51 ]
ret i32 %57
}