#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 in_addr {
  int dummy;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_zero;
  struct in_addr sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct servent {
  char *s_name;
};
struct hostent {
  scalar_t__ h_addr;
  int /*<<< orphan*/ h_addrtype;
};
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int atoi(char *);
int /*<<< orphan*/ bzero(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
struct hostent *gethostbyname(char *);
struct servent *getservbyport(int /*<<< orphan*/, char *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ logDebug(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ strcmp(char *, char *);
long time(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int sck;
  int port_start;
  int port_end;
  int current_port;
  struct hostent *he;
  struct sockaddr_in addr;
  struct servent *serv;
  printf("Port Scanner v0.1\n");
  if (argc == 4) {
    logDebug("argc is 4");
    port_start = atoi(argv[2]);
    port_end = atoi(argv[3]);
  }
  if (argc < 4) {
    logDebug("argc is LESS 4");
    if (strcmp(argv[2], "all") == 0) {
      logDebug("all is set");
      port_start = 1;
      port_end = 65535;
    } else {
      printf("Usage: %s IP startport endport\n", argv[0]);
      printf("Usage: %s IP all - to scan all ports\n", argv[0]);
      exit(1);
    }
  }
  logDebug("Initializing done.\n");
  long t = time(0);
  for (current_port = port_start; current_port <= port_end; current_port++) {
    if ((he = gethostbyname(argv[1])) == NULL) {
      printf("Invalid IP!\n");
      exit(1);
    }
    if ((sck = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
      perror("Socket error!\n");
      exit(2);
    }
    addr.sin_family = he->h_addrtype;
    addr.sin_port = htons(current_port);
    addr.sin_addr = *((struct in_addr *)he->h_addr);
    bzero(&(addr.sin_zero), sizeof(struct sockaddr_in) / 2);
    if (connect(sck, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
      close(sck);
    } else {
      serv = getservbyport(htons(current_port), "tcp");
      printf("Port: %d \t State: Open \t Service: %s\n", current_port,
             (serv == NULL) ? "Unknown" : serv->s_name);
    }
    close(sck);
  }
  printf("\nScan completed in %lu seconds.\n", time(0) - t);
  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)
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x4,-0x8(%rbp)
jne    123a <main+0x5a>
lea    0xdfe(%rip),%rdi
call   10f0 <logDebug@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    12c6 <main+0xe6>
lea    0xdd2(%rip),%rdi
call   10f0 <logDebug@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdcd(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    128d <main+0xad>
lea    0xdbb(%rip),%rdi
call   10f0 <logDebug@plt>
movl   $0x1,-0x18(%rbp)
movl   $0xffff,-0x1c(%rbp)
jmp    12c1 <main+0xe1>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
jmp    12c6 <main+0xe6>
lea    0xdb4(%rip),%rdi
call   10f0 <logDebug@plt>
xor    %edi,%edi
call   1080 <time@plt>
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     1425 <main+0x245>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <gethostbyname@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1322 <main+0x142>
lea    0xd84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2cbf(%rip),%rax
mov    (%rax),%edi
mov    0x2ca6(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    135d <main+0x17d>
lea    0xd54(%rip),%rdi
call   1090 <perror@plt>
mov    $0x2,%edi
call   10c0 <exit@plt>
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%edi
call   1030 <htons@plt>
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
lea    -0x38(%rbp),%rdi
mov    $0x8,%esi
call   10a0 <bzero@plt>
mov    -0x14(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x10,%edx
call   10d0 <connect@plt>
cmp    $0x0,%rax
jge    13b4 <main+0x1d4>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
jmp    140f <main+0x22f>
mov    -0x20(%rbp),%edi
call   1030 <htons@plt>
mov    %eax,%edi
lea    0xcec(%rip),%rsi
call   10e0 <getservbyport@plt>
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x4c(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    13ef <main+0x20f>
lea    0xcf5(%rip),%rax
mov    %rax,-0x58(%rbp)
jmp    13fa <main+0x21a>
mov    -0x40(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
mov    -0x4c(%rbp),%esi
mov    -0x58(%rbp),%rdx
lea    0xcad(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12e3 <main+0x103>
xor    %edi,%edi
call   1080 <time@plt>
mov    %rax,%rsi
sub    -0x48(%rbp),%rsi
lea    0xca9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
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    $0x18,%rsp
mov    %rsi,%r14
mov    %edi,%ebx
lea    0xeda(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x4,%ebx
jne    1239 <main+0x49>
lea    0xde5(%rip),%rdi
call   1100 <logDebug@plt>
mov    0x10(%r14),%rdi
call   10c0 <atoi@plt>
mov    %eax,%ebp
mov    0x18(%r14),%rdi
call   10c0 <atoi@plt>
mov    %eax,%r12d
jmp    1277 <main+0x87>
jge    1277 <main+0x87>
lea    0xdc8(%rip),%rdi
call   1100 <logDebug@plt>
mov    0x10(%r14),%rdi
lea    0xdc7(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    13c8 <main+0x1d8>
lea    0xdb6(%rip),%rdi
call   1100 <logDebug@plt>
mov    $0x1,%ebp
mov    $0xffff,%r12d
lea    0xdf0(%rip),%rdi
call   1100 <logDebug@plt>
xor    %edi,%edi
call   1090 <time@plt>
mov    %rax,(%rsp)
cmp    %r12d,%ebp
jle    12c0 <main+0xd0>
xor    %edi,%edi
call   1090 <time@plt>
sub    (%rsp),%rax
lea    0xe1e(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
add    $0x1,%r12d
lea    0x8(%rsp),%rbx
jmp    12e8 <main+0xf8>
nopl   0x0(%rax,%rax,1)
mov    %r13d,%edi
call   1060 <close@plt>
mov    %r13d,%edi
call   1060 <close@plt>
add    $0x1,%ebp
cmp    %ebp,%r12d
je     1293 <main+0xa3>
mov    0x8(%r14),%rdi
call   1080 <gethostbyname@plt>
test   %rax,%rax
je     139c <main+0x1ac>
mov    %rax,%r15
mov    0x2ce4(%rip),%rax
mov    (%rax),%edi
mov    0x2ccb(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
test   %eax,%eax
js     13b2 <main+0x1c2>
mov    %eax,%r13d
mov    0x8(%r15),%eax
mov    %eax,0x14(%rsp)
mov    %ebp,%edi
call   1040 <htons@plt>
mov    %eax,0x10(%rsp)
mov    (%r15),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    %rbx,%rdi
mov    $0x8,%esi
call   10b0 <bzero@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x10,%edx
call   10e0 <connect@plt>
test   %rax,%rax
js     12d0 <main+0xe0>
mov    %ebp,%edi
call   1040 <htons@plt>
mov    %eax,%edi
lea    0xd1e(%rip),%rsi
call   10f0 <getservbyport@plt>
lea    0xd3c(%rip),%rdx
test   %rax,%rax
je     1387 <main+0x197>
mov    (%rax),%rdx
lea    0xd07(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12d8 <main+0xe8>
lea    0xd53(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    0xcc9(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x2,%edi
call   10d0 <exit@plt>
mov    (%r14),%rsi
lea    0xc56(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r14),%rsi
lea    0xc65(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.hostent = type { i64, i32 }
%struct.sockaddr_in = type { i32, %struct.in_addr, i32, i32 }
%struct.in_addr = type { i32 }
%struct.servent = type { i8* }
%struct.sockaddr = type { i32 }
@.str = [19 x i8] c"Port Scanner v0.1\0A\00"
@.str.1 = [10 x i8] c"argc is 4\00"
@.str.2 = [15 x i8] c"argc is LESS 4\00"
@.str.3 = [4 x i8] c"all\00"
@.str.4 = [11 x i8] c"all is set\00"
@.str.5 = [32 x i8] c"Usage: %s IP startport endport\0A\00"
@.str.6 = [38 x i8] c"Usage: %s IP all - to scan all ports\0A\00"
@.str.7 = [20 x i8] c"Initializing done.\0A\00"
@.str.8 = [13 x i8] c"Invalid IP!\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.9 = [15 x i8] c"Socket error!\0A\00"
@.str.10 = [4 x i8] c"tcp\00"
@.str.11 = [38 x i8] c"Port: %d \09 State: Open \09 Service: %s\0A\00"
@.str.12 = [8 x i8] c"Unknown\00"
@.str.13 = [33 x i8] c"\0AScan completed in %lu seconds.\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 %struct.hostent*
%11 = alloca %struct.sockaddr_in
%12 = alloca %struct.servent*
%13 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 4
br i1 %16, label %17, label %27
17: ; preds = %2
%18 = call i32 @logDebug(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %7
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 3
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %8
br label %27
27: ; preds = %17, %2
%28 = load i32, i32* %4
%29 = icmp slt i32 %28, 4
br i1 %29, label %30, label %50
30: ; preds = %27
%31 = call i32 @logDebug(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %30
%38 = call i32 @logDebug(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %7
store i32 65535, i32* %8
br label %49
39: ; preds = %30
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 0
%42 = load i8*, i8** %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* %42)
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 0
%46 = load i8*, i8** %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i8* %46)
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %37
br label %50
50: ; preds = %49, %27
%51 = call i32 @logDebug(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%52 = call i64 @time(i32 0)
store i64 %52, i64* %13
%53 = load i32, i32* %7
store i32 %53, i32* %9
br label %54
54: ; preds = %117, %50
%55 = load i32, i32* %9
%56 = load i32, i32* %8
%57 = icmp sle i32 %55, %56
br i1 %57, label %58, label %120
58: ; preds = %54
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 1
%61 = load i8*, i8** %60
%62 = call %struct.hostent* @gethostbyname(i8* %61)
store %struct.hostent* %62, %struct.hostent** %10
%63 = icmp eq %struct.hostent* %62, null
br i1 %63, label %64, label %67
64: ; preds = %58
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %58
%68 = load i32, i32* @AF_INET
%69 = load i32, i32* @SOCK_STREAM
%70 = call i32 @socket(i32 %68, i32 %69, i32 0)
store i32 %70, i32* %6
%71 = icmp slt i32 %70, 0
br i1 %71, label %72, label %75
72: ; preds = %67
%73 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%74 = call i32 @exit(i32 2)
unreachable
75: ; preds = %67
%76 = load %struct.hostent*, %struct.hostent** %10
%77 = getelementptr inbounds %struct.hostent, %struct.hostent* %76, i32 0, i32 1
%78 = load i32, i32* %77
%79 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 3
store i32 %78, i32* %79
%80 = load i32, i32* %9
%81 = call i32 @htons(i32 %80)
%82 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 2
store i32 %81, i32* %82
%83 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 1
%84 = load %struct.hostent*, %struct.hostent** %10
%85 = getelementptr inbounds %struct.hostent, %struct.hostent* %84, i32 0, i32 0
%86 = load i64, i64* %85
%87 = inttoptr i64 %86 to %struct.in_addr*
%88 = bitcast %struct.in_addr* %83 to i8*
%89 = bitcast %struct.in_addr* %87 to i8*
%90 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
%91 = call i32 @bzero(i32* %90, i32 8)
%92 = load i32, i32* %6
%93 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%94 = call i64 @connect(i32 %92, %struct.sockaddr* %93, i32 16)
%95 = icmp slt i64 %94, 0
br i1 %95, label %96, label %99
96: ; preds = %75
%97 = load i32, i32* %6
%98 = call i32 @close(i32 %97)
br label %114
99: ; preds = %75
%100 = load i32, i32* %9
%101 = call i32 @htons(i32 %100)
%102 = call %struct.servent* @getservbyport(i32 %101, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
store %struct.servent* %102, %struct.servent** %12
%103 = load i32, i32* %9
%104 = load %struct.servent*, %struct.servent** %12
%105 = icmp eq %struct.servent* %104, null
br i1 %105, label %106, label %107
106: ; preds = %99
br label %111
107: ; preds = %99
%108 = load %struct.servent*, %struct.servent** %12
%109 = getelementptr inbounds %struct.servent, %struct.servent* %108, i32 0, i32 0
%110 = load i8*, i8** %109
br label %111
111: ; preds = %107, %106
%112 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0), %106 ], [ %110, %107 ]
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.11, i64 0, i64 0), i32 %103, i8* %112)
br label %114
114: ; preds = %111, %96
%115 = load i32, i32* %6
%116 = call i32 @close(i32 %115)
br label %117
117: ; preds = %114
%118 = load i32, i32* %9
%119 = add nsw i32 %118, 1
store i32 %119, i32* %9
br label %54
120: ; preds = %54
%121 = call i64 @time(i32 0)
%122 = load i64, i64* %13
%123 = sub nsw i64 %121, %122
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.13, i64 0, i64 0), i64 %123)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.in_addr, i32, i32 }
%struct.in_addr = type { i32 }
%struct.sockaddr = type { i32 }
%struct.hostent = type { i64, i32 }
%struct.servent = type { i8* }
@.str.1 = [10 x i8] c"argc is 4\00"
@.str.2 = [15 x i8] c"argc is LESS 4\00"
@.str.3 = [4 x i8] c"all\00"
@.str.4 = [11 x i8] c"all is set\00"
@.str.5 = [32 x i8] c"Usage: %s IP startport endport\0A\00"
@.str.6 = [38 x i8] c"Usage: %s IP all - to scan all ports\0A\00"
@.str.7 = [20 x i8] c"Initializing done.\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.9 = [15 x i8] c"Socket error!\0A\00"
@.str.10 = [4 x i8] c"tcp\00"
@.str.11 = [38 x i8] c"Port: %d \09 State: Open \09 Service: %s\0A\00"
@.str.12 = [8 x i8] c"Unknown\00"
@.str.13 = [33 x i8] c"\0AScan completed in %lu seconds.\0A\00"
@str = [18 x i8] c"Port Scanner v0.1\00"
@str.14 = [12 x i8] c"Invalid IP!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = bitcast %struct.sockaddr_in* %3 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%6 = icmp eq i32 %0, 4
br i1 %6, label %7, label %15
7: ; preds = %2
%8 = tail call i32 @logDebug(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 3
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
br label %31
15: ; preds = %2
%16 = icmp slt i32 %0, 4
br i1 %16, label %17, label %31
17: ; preds = %15
%18 = tail call i32 @logDebug(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = tail call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %17
%24 = tail call i32 @logDebug(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %31
25: ; preds = %17
%26 = load i8*, i8** %1
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* %26)
%28 = load i8*, i8** %1
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i8* %28)
%30 = tail call i32 @exit(i32 1)
unreachable
31: ; preds = %7, %23, %15
%32 = phi i32 [ 65535, %23 ], [ undef, %15 ], [ %14, %7 ]
%33 = phi i32 [ 1, %23 ], [ undef, %15 ], [ %11, %7 ]
%34 = tail call i32 @logDebug(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%35 = tail call i64 @time(i32 0)
%36 = icmp sgt i32 %33, %32
br i1 %36, label %87, label %37
37: ; preds = %31
%38 = getelementptr inbounds i8*, i8** %1, i64 1
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 3
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
%43 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
br label %44
44: ; preds = %37, %83
%45 = phi i32 [ %33, %37 ], [ %85, %83 ]
%46 = load i8*, i8** %38
%47 = call %struct.hostent* @gethostbyname(i8* %46)
%48 = icmp eq %struct.hostent* %47, null
br i1 %48, label %49, label %52
49: ; preds = %44
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.14, i64 0, i64 0))
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %44
%53 = load i32, i32* @AF_INET
%54 = load i32, i32* @SOCK_STREAM
%55 = call i32 @socket(i32 %53, i32 %54, i32 0)
%56 = icmp slt i32 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %52
%58 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%59 = call i32 @exit(i32 2)
unreachable
60: ; preds = %52
%61 = getelementptr inbounds %struct.hostent, %struct.hostent* %47, i64 0, i32 1
%62 = load i32, i32* %61
store i32 %62, i32* %39
%63 = call i32 @htons(i32 %45)
store i32 %63, i32* %40
%64 = getelementptr inbounds %struct.hostent, %struct.hostent* %47, i64 0, i32 0
%65 = load i64, i64* %64
%66 = inttoptr i64 %65 to i32*
%67 = load i32, i32* %66
store i32 %67, i32* %41
%68 = call i32 @bzero(i32* %42, i32 8)
%69 = call i64 @connect(i32 %55, %struct.sockaddr* %43, i32 16)
%70 = icmp slt i64 %69, 0
br i1 %70, label %71, label %73
71: ; preds = %60
%72 = call i32 @close(i32 %55)
br label %83
73: ; preds = %60
%74 = call i32 @htons(i32 %45)
%75 = call %struct.servent* @getservbyport(i32 %74, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%76 = icmp eq %struct.servent* %75, null
br i1 %76, label %80, label %77
77: ; preds = %73
%78 = getelementptr inbounds %struct.servent, %struct.servent* %75, i64 0, i32 0
%79 = load i8*, i8** %78
br label %80
80: ; preds = %73, %77
%81 = phi i8* [ %79, %77 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0), %73 ]
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.11, i64 0, i64 0), i32 %45, i8* %81)
br label %83
83: ; preds = %80, %71
%84 = call i32 @close(i32 %55)
%85 = add i32 %45, 1
%86 = icmp eq i32 %45, %32
br i1 %86, label %87, label %44
87: ; preds = %83, %31
%88 = call i64 @time(i32 0)
%89 = sub nsw i64 %88, %35
%90 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.13, i64 0, i64 0), i64 %89)
ret i32 0
}