#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 */
struct option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ member_2;
  int /*<<< orphan*/ const member_1;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int getopt_long(int, char **, char *, struct option *, int *);
int /*<<< orphan*/ is_valid_prefix(char *);
#define no_argument 129
char *optarg;
#define required_argument 128
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ update_from_file(char *, char *, char *, char *, int,
                                    char *);
int /*<<< orphan*/ update_from_urls(char *, char *, char *, char *, int,
                                    char *);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  int opt;
  char *path_current = NULL;
  char *path_new = NULL;
  char *path_output = "merged_hosts";
  char *path_conf_file = NULL;
  char *path_whitelist = NULL;
  char *prefix = "0.0.0.0";
  int in_place = 0;
  static struct option long_options[] = {{"current", required_argument, 0, 'c'},
                                         {"file", required_argument, 0, 'f'},
                                         {"new", required_argument, 0, 'n'},
                                         {"prefix", required_argument, 0, 'p'},
                                         {"inplace", no_argument, 0, 'i'},
                                         {"whitelist", no_argument, 0, 'w'},
                                         {0, 0, 0, 0}};
  int long_index = 0;
  while ((opt = getopt_long(argc, argv, "c:f:n:p:iw:", long_options,
                            &long_index)) != -1) {
    switch (opt) {
    case 'c':
      path_current = optarg;
      break;
    case 'f':
      path_conf_file = optarg;
      break;
    case 'n':
      path_new = optarg;
      break;
    case 'p':
      prefix = optarg;
      break;
    case 'i':
      in_place = 1;
      break;
    case 'w':
      path_whitelist = optarg;
      break;
    default:
      usage();
      break;
    }
  }
  if (!is_valid_prefix(prefix)) {
    fprintf(stderr, "Not a valid prefix: %s\n", prefix);
    exit(EXIT_FAILURE);
  }
  if (path_current == NULL) {
    usage();
  } else if (path_conf_file != NULL) {
    update_from_urls(path_current, path_conf_file, path_output, prefix,
                     in_place, path_whitelist);
  } else if (path_new != NULL) {
    update_from_file(path_current, path_new, path_output, prefix, in_place,
                     path_whitelist);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
lea    0xeb7(%rip),%rax
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
lea    0xea9(%rip),%rax
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xebb(%rip),%rdx
lea    0x2e81(%rip),%rcx
lea    -0x50(%rbp),%r8
call   1040 <getopt_long@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1294 <main+0x124>
mov    -0x14(%rbp),%eax
add    $0xffffff9d,%eax
mov    %eax,%ecx
mov    %rcx,-0x58(%rbp)
sub    $0x14,%eax
ja     1288 <main+0x118>
mov    -0x58(%rbp),%rax
lea    0xdec(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2dd4(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    128f <main+0x11f>
mov    0x2dc1(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
jmp    128f <main+0x11f>
mov    0x2dae(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    128f <main+0x11f>
mov    0x2d9b(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
jmp    128f <main+0x11f>
movl   $0x1,-0x4c(%rbp)
jmp    128f <main+0x11f>
mov    0x2d7c(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
jmp    128f <main+0x11f>
mov    $0x0,%al
call   1080 <usage@plt>
jmp    11ca <main+0x5a>
mov    -0x48(%rbp),%rdi
call   1030 <is_valid_prefix@plt>
cmp    $0x0,%eax
jne    12cd <main+0x15d>
mov    0x2d2b(%rip),%rax
mov    (%rax),%edi
mov    -0x48(%rbp),%rdx
lea    0xde5(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2d0a(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
cmpq   $0x0,-0x20(%rbp)
jne    12e4 <main+0x174>
mov    $0x0,%al
call   1080 <usage@plt>
jmp    1343 <main+0x1d3>
cmpq   $0x0,-0x38(%rbp)
je     1311 <main+0x1a1>
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x4c(%rbp),%r8d
mov    -0x40(%rbp),%r9
call   1060 <update_from_urls@plt>
jmp    133e <main+0x1ce>
cmpq   $0x0,-0x28(%rbp)
je     1339 <main+0x1c9>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x4c(%rbp),%r8d
mov    -0x40(%rbp),%r9
call   1070 <update_from_file@plt>
jmp    133e <main+0x1ce>
jmp    1343 <main+0x1d3>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
mov    %edi,%r12d
movl   $0x0,0x14(%rsp)
lea    0xece(%rip),%rax
mov    %rax,0x30(%rsp)
lea    0xef4(%rip),%r15
lea    0x2eba(%rip),%r13
lea    0x14(%rsp),%rbx
lea    0xe4e(%rip),%rbp
xor    %eax,%eax
mov    %rax,0x20(%rsp)
xor    %eax,%eax
mov    %rax,0x28(%rsp)
xor    %eax,%eax
mov    %rax,0x18(%rsp)
xor    %eax,%eax
mov    %rax,0x8(%rsp)
movl   $0x0,0x4(%rsp)
jmp    11f0 <main+0x80>
nopl   0x0(%rax,%rax,1)
cmp    $0xffffffff,%eax
je     1278 <main+0x108>
xor    %eax,%eax
call   1080 <usage@plt>
mov    %r12d,%edi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
call   1040 <getopt_long@plt>
lea    -0x63(%rax),%ecx
cmp    $0x14,%ecx
ja     11e0 <main+0x70>
movslq 0x0(%rbp,%rcx,4),%rax
add    %rbp,%rax
jmp    *%rax
mov    0x2ddb(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x28(%rsp)
jmp    11f0 <main+0x80>
mov    0x2dca(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x18(%rsp)
jmp    11f0 <main+0x80>
movl   $0x1,0x4(%rsp)
jmp    11f0 <main+0x80>
mov    0x2daf(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x20(%rsp)
jmp    11f0 <main+0x80>
mov    0x2d9e(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x30(%rsp)
jmp    11f0 <main+0x80>
mov    0x2d8d(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x8(%rsp)
jmp    11f0 <main+0x80>
mov    0x30(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <is_valid_prefix@plt>
test   %eax,%eax
je     12f8 <main+0x188>
mov    0x28(%rsp),%rdi
test   %rdi,%rdi
mov    0x20(%rsp),%rsi
mov    0x18(%rsp),%rax
je     12c0 <main+0x150>
test   %rax,%rax
je     12c9 <main+0x159>
lea    0xdab(%rip),%rdx
mov    %rax,%rsi
mov    %rbx,%rcx
mov    0x4(%rsp),%r8d
mov    0x8(%rsp),%r9
call   1060 <update_from_urls@plt>
jmp    12e7 <main+0x177>
xor    %eax,%eax
call   1080 <usage@plt>
jmp    12e7 <main+0x177>
test   %rsi,%rsi
je     12e7 <main+0x177>
lea    0xd7f(%rip),%rdx
mov    %rbx,%rcx
mov    0x4(%rsp),%r8d
mov    0x8(%rsp),%r9
call   1070 <update_from_file@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cd9(%rip),%rax
mov    (%rax),%edi
lea    0xd97(%rip),%rsi
mov    %rbx,%rdx
call   1050 <fprintf@plt>
mov    0x2cb9(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32, i32 }
@.str = [13 x i8] c"merged_hosts\00"
@.str.1 = [8 x i8] c"0.0.0.0\00"
@main.long_options = internal global [7 x %struct.option] [%struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8 -128, i32 0, i32 99 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8 -128, i32 0, i32 102 }, %struct.option { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8 -128, i32 0, i32 110 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0), i8 -128, i32 0, i32 112 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i32 0, i32 0), i8 -127, i32 0, i32 105 }, %struct.option { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i32 0, i32 0), i8 -127, i32 0, i32 119 }, %struct.option zeroinitializer]
@.str.2 = [8 x i8] c"current\00"
@.str.3 = [5 x i8] c"file\00"
@.str.4 = [4 x i8] c"new\00"
@.str.5 = [7 x i8] c"prefix\00"
@.str.6 = [8 x i8] c"inplace\00"
@.str.7 = [10 x i8] c"whitelist\00"
@.str.8 = [12 x i8] c"c:f:n:p:iw:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.9 = [24 x i8] c"Not a valid prefix: %s\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
store i8* null, i8** %8
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %9
store i8* null, i8** %10
store i8* null, i8** %11
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %12
store i32 0, i32* %13
store i32 0, i32* %14
br label %15
15: ; preds = %35, %2
%16 = load i32, i32* %4
%17 = load i8**, i8*** %5
%18 = call i32 @getopt_long(i32 %16, i8** %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), %struct.option* getelementptr inbounds ([7 x %struct.option], [7 x %struct.option]* @main.long_options, i64 0, i64 0), i32* %14)
store i32 %18, i32* %6
%19 = icmp ne i32 %18, -1
br i1 %19, label %20, label %36
20: ; preds = %15
%21 = load i32, i32* %6
switch i32 %21, label %33 [
i32 99, label %22
i32 102, label %24
i32 110, label %26
i32 112, label %28
i32 105, label %30
i32 119, label %31
]
22: ; preds = %20
%23 = load i8*, i8** @optarg
store i8* %23, i8** %7
br label %35
24: ; preds = %20
%25 = load i8*, i8** @optarg
store i8* %25, i8** %10
br label %35
26: ; preds = %20
%27 = load i8*, i8** @optarg
store i8* %27, i8** %8
br label %35
28: ; preds = %20
%29 = load i8*, i8** @optarg
store i8* %29, i8** %12
br label %35
30: ; preds = %20
store i32 1, i32* %13
br label %35
31: ; preds = %20
%32 = load i8*, i8** @optarg
store i8* %32, i8** %11
br label %35
33: ; preds = %20
%34 = call i32 (...) @usage()
br label %35
35: ; preds = %33, %31, %30, %28, %26, %24, %22
br label %15
36: ; preds = %15
%37 = load i8*, i8** %12
%38 = call i32 @is_valid_prefix(i8* %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %46, label %40
40: ; preds = %36
%41 = load i32, i32* @stderr
%42 = load i8*, i8** %12
%43 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %42)
%44 = load i32, i32* @EXIT_FAILURE
%45 = call i32 @exit(i32 %44)
unreachable
46: ; preds = %36
%47 = load i8*, i8** %7
%48 = icmp eq i8* %47, null
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = call i32 (...) @usage()
br label %75
51: ; preds = %46
%52 = load i8*, i8** %10
%53 = icmp ne i8* %52, null
br i1 %53, label %54, label %62
54: ; preds = %51
%55 = load i8*, i8** %7
%56 = load i8*, i8** %10
%57 = load i8*, i8** %9
%58 = load i8*, i8** %12
%59 = load i32, i32* %13
%60 = load i8*, i8** %11
%61 = call i32 @update_from_urls(i8* %55, i8* %56, i8* %57, i8* %58, i32 %59, i8* %60)
br label %74
62: ; preds = %51
%63 = load i8*, i8** %8
%64 = icmp ne i8* %63, null
br i1 %64, label %65, label %73
65: ; preds = %62
%66 = load i8*, i8** %7
%67 = load i8*, i8** %8
%68 = load i8*, i8** %9
%69 = load i8*, i8** %12
%70 = load i32, i32* %13
%71 = load i8*, i8** %11
%72 = call i32 @update_from_file(i8* %66, i8* %67, i8* %68, i8* %69, i32 %70, i8* %71)
br label %73
73: ; preds = %65, %62
br label %74
74: ; preds = %73, %54
br label %75
75: ; preds = %74, %49
ret i32 0
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32, i32 }
@.str = [13 x i8] c"merged_hosts\00"
@.str.1 = [8 x i8] c"0.0.0.0\00"
@main.long_options = internal global [7 x %struct.option] [%struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8 -128, i32 0, i32 99 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8 -128, i32 0, i32 102 }, %struct.option { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8 -128, i32 0, i32 110 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0), i8 -128, i32 0, i32 112 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i32 0, i32 0), i8 -127, i32 0, i32 105 }, %struct.option { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i32 0, i32 0), i8 -127, i32 0, i32 119 }, %struct.option zeroinitializer]
@.str.2 = [8 x i8] c"current\00"
@.str.3 = [5 x i8] c"file\00"
@.str.4 = [4 x i8] c"new\00"
@.str.5 = [7 x i8] c"prefix\00"
@.str.6 = [8 x i8] c"inplace\00"
@.str.7 = [10 x i8] c"whitelist\00"
@.str.8 = [12 x i8] c"c:f:n:p:iw:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.9 = [24 x i8] c"Not a valid prefix: %s\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
br label %5
5: ; preds = %38, %2
%6 = phi i8* [ %39, %38 ], [ null, %2 ]
%7 = phi i8* [ %13, %38 ], [ null, %2 ]
%8 = phi i8* [ %19, %38 ], [ null, %2 ]
%9 = phi i8* [ %24, %38 ], [ null, %2 ]
%10 = phi i8* [ %28, %38 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %2 ]
%11 = phi i32 [ %31, %38 ], [ 0, %2 ]
br label %12
12: ; preds = %5, %34
%13 = phi i8* [ %7, %5 ], [ %35, %34 ]
%14 = phi i8* [ %8, %5 ], [ %19, %34 ]
%15 = phi i8* [ %9, %5 ], [ %24, %34 ]
%16 = phi i8* [ %10, %5 ], [ %28, %34 ]
%17 = phi i32 [ %11, %5 ], [ %31, %34 ]
br label %18
18: ; preds = %12, %36
%19 = phi i8* [ %14, %12 ], [ %37, %36 ]
%20 = phi i8* [ %15, %12 ], [ %24, %36 ]
%21 = phi i8* [ %16, %12 ], [ %28, %36 ]
%22 = phi i32 [ %17, %12 ], [ %31, %36 ]
br label %23
23: ; preds = %18, %42
%24 = phi i8* [ %20, %18 ], [ %43, %42 ]
%25 = phi i8* [ %21, %18 ], [ %28, %42 ]
%26 = phi i32 [ %22, %18 ], [ %31, %42 ]
br label %27
27: ; preds = %23, %40
%28 = phi i8* [ %25, %23 ], [ %41, %40 ]
%29 = phi i32 [ %26, %23 ], [ %31, %40 ]
br label %30
30: ; preds = %32, %27
%31 = phi i32 [ %29, %27 ], [ 1, %32 ]
br label %32
32: ; preds = %30, %44
%33 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), %struct.option* getelementptr inbounds ([7 x %struct.option], [7 x %struct.option]* @main.long_options, i64 0, i64 0), i32* %3)
switch i32 %33, label %44 [
i32 -1, label %46
i32 99, label %34
i32 102, label %36
i32 110, label %38
i32 112, label %40
i32 105, label %30
i32 119, label %42
]
34: ; preds = %32
%35 = load i8*, i8** @optarg
br label %12
36: ; preds = %32
%37 = load i8*, i8** @optarg
br label %18
38: ; preds = %32
%39 = load i8*, i8** @optarg
br label %5
40: ; preds = %32
%41 = load i8*, i8** @optarg
br label %27
42: ; preds = %32
%43 = load i8*, i8** @optarg
br label %23
44: ; preds = %32
%45 = call i32 (...) @usage()
br label %32
46: ; preds = %32
%47 = call i32 @is_valid_prefix(i8* %28)
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %54
49: ; preds = %46
%50 = load i32, i32* @stderr
%51 = call i32 @fprintf(i32 %50, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %28)
%52 = load i32, i32* @EXIT_FAILURE
%53 = call i32 @exit(i32 %52)
unreachable
54: ; preds = %46
%55 = icmp eq i8* %13, null
br i1 %55, label %56, label %58
56: ; preds = %54
%57 = call i32 (...) @usage()
br label %66
58: ; preds = %54
%59 = icmp eq i8* %19, null
br i1 %59, label %62, label %60
60: ; preds = %58
%61 = call i32 @update_from_urls(i8* %13, i8* %19, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %28, i32 %31, i8* %24)
br label %66
62: ; preds = %58
%63 = icmp eq i8* %6, null
br i1 %63, label %66, label %64
64: ; preds = %62
%65 = call i32 @update_from_file(i8* %13, i8* %6, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %28, i32 %31, i8* %24)
br label %66
66: ; preds = %60, %64, %62, %56
ret i32 0
}