#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*/ printf(char *);
int /*<<< orphan*/ ptg_gen_phtsk(char const *, char const *, char const *);
int main(int argc, char *argv[]) {
  static const char def_ipfile[] = "ipranges.txt";
  static const char def_portfile[] = "ports.txt";
  static const char def_outfile[] = "iptask.tsk";
  const char *ipfile = def_ipfile, *portfile = def_portfile;
  const char *outfile = def_outfile;
  if (argc >= 2)
    ipfile = argv[1];
  if (argc >= 3)
    portfile = argv[2];
  if (argc >= 4)
    outfile = argv[3];
  ptg_gen_phtsk(ipfile, portfile, outfile);
  printf("OK!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xec5(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xec4(%rip),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     116d <main+0x4d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
jl     1183 <main+0x63>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x4,-0x8(%rbp)
jl     1199 <main+0x79>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <ptg_gen_phtsk@plt>
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    %rsi,%rax
lea    0xeec(%rip),%rdx
lea    0xedb(%rip),%rsi
cmp    $0x2,%edi
jl     114e <main+0x2e>
mov    %edi,%ecx
mov    0x8(%rax),%rdi
je     1155 <main+0x35>
mov    0x10(%rax),%rsi
cmp    $0x4,%ecx
jb     1155 <main+0x35>
mov    0x18(%rax),%rdx
jmp    1155 <main+0x35>
lea    0xeab(%rip),%rdi
call   1040 <ptg_gen_phtsk@plt>
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@main.def_ipfile = internal constant [13 x i8] c"ipranges.txt\00"
@main.def_portfile = internal constant [10 x i8] c"ports.txt\00"
@main.def_outfile = internal constant [11 x i8] c"iptask.tsk\00"
@.str = [5 x i8] c"OK!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @main.def_ipfile, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @main.def_portfile, i64 0, i64 0), i8** %7
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @main.def_outfile, i64 0, i64 0), i8** %8
%9 = load i32, i32* %4
%10 = icmp sge i32 %9, 2
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
store i8* %14, i8** %6
br label %15
15: ; preds = %11, %2
%16 = load i32, i32* %4
%17 = icmp sge i32 %16, 3
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
store i8* %21, i8** %7
br label %22
22: ; preds = %18, %15
%23 = load i32, i32* %4
%24 = icmp sge i32 %23, 4
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 3
%28 = load i8*, i8** %27
store i8* %28, i8** %8
br label %29
29: ; preds = %25, %22
%30 = load i8*, i8** %6
%31 = load i8*, i8** %7
%32 = load i8*, i8** %8
%33 = call i32 @ptg_gen_phtsk(i8* %30, i8* %31, i8* %32)
%34 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@main.def_ipfile = internal constant [13 x i8] c"ipranges.txt\00"
@main.def_portfile = internal constant [10 x i8] c"ports.txt\00"
@main.def_outfile = internal constant [11 x i8] c"iptask.tsk\00"
@str = [4 x i8] c"OK!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %15
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = icmp eq i32 %0, 2
br i1 %7, label %15, label %8
8: ; preds = %4
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = icmp ugt i32 %0, 3
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = getelementptr inbounds i8*, i8** %1, i64 3
%14 = load i8*, i8** %13
br label %15
15: ; preds = %2, %4, %12, %8
%16 = phi i8* [ %10, %12 ], [ %10, %8 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @main.def_portfile, i64 0, i64 0), %4 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @main.def_portfile, i64 0, i64 0), %2 ]
%17 = phi i8* [ %6, %12 ], [ %6, %8 ], [ %6, %4 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @main.def_ipfile, i64 0, i64 0), %2 ]
%18 = phi i8* [ %14, %12 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @main.def_outfile, i64 0, i64 0), %8 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @main.def_outfile, i64 0, i64 0), %4 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @main.def_outfile, i64 0, i64 0), %2 ]
%19 = tail call i32 @ptg_gen_phtsk(i8* %17, i8* %16, i8* %18)
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
ret i32 0
}