#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 /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  scalar_t__ sin_family;
  void *sin_port;
  struct in_addr sin_addr;
};
struct sockaddr {
  int dummy;
};
struct hostent {
  scalar_t__ h_addrtype;
  int h_length;
  scalar_t__ h_addr;
};
typedef int /*<<< orphan*/ sin;

/* Variables and functions */
scalar_t__ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_DGRAM;
int atoi(char *);
scalar_t__ bind(int, struct sockaddr *, int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ herror(char *);
void *htons(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ run_airhook(int, struct sockaddr_in);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  struct hostent *host;
  int sock, local, remote;
  struct sockaddr_in sin;
  if (4 != argc) {
    fputs(
        "Airhook connect-and-test utility version 1, copyright 2001 Dan "
        "Egnor.\n"
        "\n"
        "usage: aircat lport rhost rport\n"
        "Uses port <lport> and attempts to connect to a peer running on host\n"
        "<rhost> and port <rport>.  Lines of text from standard input are "
        "sent\n"
        "as Airhook messages.  Incoming messages are written to standard "
        "output.\n"
        "\n"
        "This software comes with ABSOLUTELY NO WARRANTY.  You may "
        "redistribute it\n"
        "under the terms of the GNU General Public License, Version 2.\n",
        stderr);
    return 3;
  }
  local = atoi(argv[1]);
  if (local <= 0 || local >= 65536) {
    fprintf(stderr, "%s: invalid local port\n", argv[1]);
    return 3;
  }
  remote = atoi(argv[3]);
  if (remote <= 0 || remote >= 65536) {
    fprintf(stderr, "%s: invalid remote port\n", argv[3]);
    return 3;
  }
  host = gethostbyname(argv[2]);
  if (NULL == host) {
    herror(argv[2]);
    return 2;
  }
  sin.sin_family = AF_INET;
  if (sin.sin_family != host->h_addrtype ||
      sizeof(sin.sin_addr) != host->h_length) {
    fprintf(stderr, "%s: wrong address type\n", argv[2]);
    return 2;
  }
  sock = socket(PF_INET, SOCK_DGRAM, 0);
  if (sock < 0) {
    perror("socket");
    return 1;
  }
  sin.sin_addr.s_addr = INADDR_ANY;
  sin.sin_port = htons(local);
  if (bind(sock, (struct sockaddr *)&sin, sizeof(sin))) {
    perror("bind");
    return 1;
  }
  sin.sin_addr = *(struct in_addr *)host->h_addr;
  sin.sin_port = htons(remote);
  if (connect(sock, (struct sockaddr *)&sin, sizeof(sin))) {
    perror("connect");
    return 1;
  }
  run_airhook(sock, sin);
  return 1;
}


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)
mov    $0x4,%eax
cmp    -0x8(%rbp),%eax
je     11f5 <main+0x45>
mov    0x2ded(%rip),%rax
mov    (%rax),%esi
lea    0xe1c(%rip),%rdi
call   1040 <fputs@plt>
movl   $0x3,-0x4(%rbp)
jmp    142a <main+0x27a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jle    121c <main+0x6c>
cmpl   $0x10000,-0x20(%rbp)
jl     1245 <main+0x95>
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xf8f(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x3,-0x4(%rbp)
jmp    142a <main+0x27a>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    126c <main+0xbc>
cmpl   $0x10000,-0x24(%rbp)
jl     1295 <main+0xe5>
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0xf57(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x3,-0x4(%rbp)
jmp    142a <main+0x27a>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <gethostbyname@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    12cb <main+0x11b>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <herror@plt>
movl   $0x2,-0x4(%rbp)
jmp    142a <main+0x27a>
mov    0x2d16(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%rax
jne    1300 <main+0x150>
mov    -0x18(%rbp),%rax
movslq 0x8(%rax),%rcx
mov    $0x4,%eax
cmp    %rcx,%rax
je     1329 <main+0x179>
mov    0x2cc1(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xedc(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    142a <main+0x27a>
mov    0x2c90(%rip),%rax
mov    (%rax),%edi
mov    0x2c9f(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10d0 <socket@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1367 <main+0x1b7>
lea    0xeb6(%rip),%rdi
call   10a0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    142a <main+0x27a>
mov    0x2c72(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x20(%rbp),%edi
call   1030 <htons@plt>
mov    %rax,-0x38(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0x18,%edx
call   1090 <bind@plt>
cmp    $0x0,%rax
je     13b2 <main+0x202>
lea    0xe72(%rip),%rdi
call   10a0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    142a <main+0x27a>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x24(%rbp),%edi
call   1030 <htons@plt>
mov    %rax,-0x38(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0x18,%edx
call   10c0 <connect@plt>
cmp    $0x0,%rax
je     13fe <main+0x24e>
lea    0xe2b(%rip),%rdi
call   10a0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    142a <main+0x27a>
mov    -0x1c(%rbp),%edi
lea    -0x40(%rbp),%rax
mov    (%rax),%rcx
mov    %rcx,(%rsp)
mov    0x8(%rax),%rcx
mov    %rcx,0x8(%rsp)
mov    0x10(%rax),%rax
mov    %rax,0x10(%rsp)
call   1070 <run_airhook@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
cmp    $0x4,%edi
jne    11f4 <main+0x44>
mov    %rsi,%rbp
mov    0x8(%rsi),%rbx
mov    %rbx,%rdi
call   10b0 <atoi@plt>
mov    %eax,%r12d
lea    -0x10000(%r12),%eax
ff
cmp    $0xffff0000,%eax
ja     120b <main+0x5b>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
lea    0xfd1(%rip),%rsi
jmp    1238 <main+0x88>
mov    0x2dcd(%rip),%rax
mov    (%rax),%esi
lea    0xdfc(%rip),%rdi
call   1040 <fputs@plt>
jmp    1240 <main+0x90>
mov    0x18(%rbp),%rbx
mov    %rbx,%rdi
call   10b0 <atoi@plt>
mov    %eax,%r14d
lea    -0x10000(%r14),%eax
cmp    $0xffff0000,%eax
ja     1252 <main+0xa2>
mov    0x2d99(%rip),%rax
mov    (%rax),%edi
lea    0xfa3(%rip),%rsi
mov    %rbx,%rdx
call   1060 <fprintf@plt>
mov    $0x3,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x10(%rbp),%rdi
call   1050 <gethostbyname@plt>
test   %rax,%rax
je     1355 <main+0x1a5>
mov    %rax,%r15
mov    0x2d7a(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x18(%rsp)
cmp    (%r15),%rax
jne    1332 <main+0x182>
cmpl   $0x4,0x8(%r15)
jne    1332 <main+0x182>
mov    0x2d2f(%rip),%rax
mov    (%rax),%edi
mov    0x2d3e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10d0 <socket@plt>
test   %eax,%eax
js     1368 <main+0x1b8>
mov    %eax,%ebp
mov    0x2d2c(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x28(%rsp)
mov    %r12d,%edi
call   1030 <htons@plt>
mov    %rax,0x20(%rsp)
lea    0x18(%rsp),%rsi
mov    %ebp,%edi
mov    $0x18,%edx
call   1090 <bind@plt>
test   %rax,%rax
jne    1376 <main+0x1c6>
mov    0x10(%r15),%rax
mov    (%rax),%eax
mov    %eax,0x28(%rsp)
mov    %r14d,%edi
call   1030 <htons@plt>
mov    %rax,0x20(%rsp)
lea    0x18(%rsp),%rsi
mov    %ebp,%edi
mov    $0x18,%edx
call   10c0 <connect@plt>
test   %rax,%rax
jne    1384 <main+0x1d4>
mov    0x28(%rsp),%rax
mov    %rax,0x10(%rsp)
movups 0x18(%rsp),%xmm0
movups %xmm0,(%rsp)
mov    %ebp,%edi
call   1070 <run_airhook@plt>
mov    $0x1,%eax
jmp    1245 <main+0x95>
mov    0x2c8f(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbp),%rdx
lea    0xeae(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x2,%eax
jmp    1245 <main+0x95>
mov    0x10(%rbp),%rdi
call   1080 <herror@plt>
mov    $0x2,%eax
jmp    1245 <main+0x95>
lea    0xe9d(%rip),%rdi
call   10a0 <perror@plt>
jmp    1328 <main+0x178>
lea    0xe96(%rip),%rdi
call   10a0 <perror@plt>
jmp    1328 <main+0x178>
lea    0xe8d(%rip),%rdi
call   10a0 <perror@plt>
jmp    1328 <main+0x178>

LLVM IR (-O0):
%struct.hostent = type { i64, i32, i64 }
%struct.sockaddr_in = type { i64, i8*, %struct.in_addr }
%struct.in_addr = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [451 x i8] c"Airhook connect-and-test utility version 1, copyright 2001 Dan Egnor.\0A\0Ausage: aircat lport rhost rport\0AUses port <lport> and attempts to connect to a peer running on host\0A<rhost> and port <rport>. Lines of text from standard input are sent\0Aas Airhook messages. Incoming messages are written to standard output.\0A\0AThis software comes with ABSOLUTELY NO WARRANTY. You may redistribute it\0Aunder the terms of the GNU General Public License, Version 2.\0A\00"
@stderr = global i32 0
@.str.1 = [24 x i8] c"%s: invalid local port\0A\00"
@.str.2 = [25 x i8] c"%s: invalid remote port\0A\00"
@AF_INET = global i64 0
@.str.3 = [24 x i8] c"%s: wrong address type\0A\00"
@PF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.4 = [7 x i8] c"socket\00"
@INADDR_ANY = global i32 0
@.str.5 = [5 x i8] c"bind\00"
@.str.6 = [8 x i8] c"connect\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.hostent*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.sockaddr_in
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 4, %11
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 @fputs(i8* getelementptr inbounds ([451 x i8], [451 x i8]* @.str, i64 0, i64 0), i32 %14)
store i32 3, i32* %3
br label %122
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %8
%21 = load i32, i32* %8
%22 = icmp sle i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %16
%24 = load i32, i32* %8
%25 = icmp sge i32 %24, 65536
br i1 %25, label %26, label %32
26: ; preds = %23, %16
%27 = load i32, i32* @stderr
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %30)
store i32 3, i32* %3
br label %122
32: ; preds = %23
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 3
%35 = load i8*, i8** %34
%36 = call i32 @atoi(i8* %35)
store i32 %36, i32* %9
%37 = load i32, i32* %9
%38 = icmp sle i32 %37, 0
br i1 %38, label %42, label %39
39: ; preds = %32
%40 = load i32, i32* %9
%41 = icmp sge i32 %40, 65536
br i1 %41, label %42, label %48
42: ; preds = %39, %32
%43 = load i32, i32* @stderr
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 3
%46 = load i8*, i8** %45
%47 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %46)
store i32 3, i32* %3
br label %122
48: ; preds = %39
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 2
%51 = load i8*, i8** %50
%52 = call %struct.hostent* @gethostbyname(i8* %51)
store %struct.hostent* %52, %struct.hostent** %6
%53 = load %struct.hostent*, %struct.hostent** %6
%54 = icmp eq %struct.hostent* null, %53
br i1 %54, label %55, label %60
55: ; preds = %48
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 2
%58 = load i8*, i8** %57
%59 = call i32 @herror(i8* %58)
store i32 2, i32* %3
br label %122
60: ; preds = %48
%61 = load i64, i64* @AF_INET
%62 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
store i64 %61, i64* %62
%63 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%64 = load i64, i64* %63
%65 = load %struct.hostent*, %struct.hostent** %6
%66 = getelementptr inbounds %struct.hostent, %struct.hostent* %65, i32 0, i32 0
%67 = load i64, i64* %66
%68 = icmp ne i64 %64, %67
br i1 %68, label %75, label %69
69: ; preds = %60
%70 = load %struct.hostent*, %struct.hostent** %6
%71 = getelementptr inbounds %struct.hostent, %struct.hostent* %70, i32 0, i32 1
%72 = load i32, i32* %71
%73 = sext i32 %72 to i64
%74 = icmp ne i64 4, %73
br i1 %74, label %75, label %81
75: ; preds = %69, %60
%76 = load i32, i32* @stderr
%77 = load i8**, i8*** %5
%78 = getelementptr inbounds i8*, i8** %77, i64 2
%79 = load i8*, i8** %78
%80 = call i32 @fprintf(i32 %76, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %79)
store i32 2, i32* %3
br label %122
81: ; preds = %69
%82 = load i32, i32* @PF_INET
%83 = load i32, i32* @SOCK_DGRAM
%84 = call i32 @socket(i32 %82, i32 %83, i32 0)
store i32 %84, i32* %7
%85 = load i32, i32* %7
%86 = icmp slt i32 %85, 0
br i1 %86, label %87, label %89
87: ; preds = %81
%88 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %122
89: ; preds = %81
%90 = load i32, i32* @INADDR_ANY
%91 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 2
%92 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %91, i32 0, i32 0
store i32 %90, i32* %92
%93 = load i32, i32* %8
%94 = call i8* @htons(i32 %93)
%95 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
store i8* %94, i8** %95
%96 = load i32, i32* %7
%97 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%98 = call i64 @bind(i32 %96, %struct.sockaddr* %97, i32 24)
%99 = icmp ne i64 %98, 0
br i1 %99, label %100, label %102
100: ; preds = %89
%101 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %122
102: ; preds = %89
%103 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 2
%104 = load %struct.hostent*, %struct.hostent** %6
%105 = getelementptr inbounds %struct.hostent, %struct.hostent* %104, i32 0, i32 2
%106 = load i64, i64* %105
%107 = inttoptr i64 %106 to %struct.in_addr*
%108 = bitcast %struct.in_addr* %103 to i8*
%109 = bitcast %struct.in_addr* %107 to i8*
%110 = load i32, i32* %9
%111 = call i8* @htons(i32 %110)
%112 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
store i8* %111, i8** %112
%113 = load i32, i32* %7
%114 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%115 = call i64 @connect(i32 %113, %struct.sockaddr* %114, i32 24)
%116 = icmp ne i64 %115, 0
br i1 %116, label %117, label %119
117: ; preds = %102
%118 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %122
119: ; preds = %102
%120 = load i32, i32* %7
%121 = call i32 @run_airhook(i32 %120, %struct.sockaddr_in* byval(%struct.sockaddr_in) align 8 %10)
store i32 1, i32* %3
br label %122
122: ; preds = %119, %117, %100, %87, %75, %55, %42, %26, %13
%123 = load i32, i32* %3
ret i32 %123
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i64, i8*, %struct.in_addr }
%struct.in_addr = type { i32 }
%struct.hostent = type { i64, i32, i64 }
%struct.sockaddr = type { i32 }
@.str = [451 x i8] c"Airhook connect-and-test utility version 1, copyright 2001 Dan Egnor.\0A\0Ausage: aircat lport rhost rport\0AUses port <lport> and attempts to connect to a peer running on host\0A<rhost> and port <rport>. Lines of text from standard input are sent\0Aas Airhook messages. Incoming messages are written to standard output.\0A\0AThis software comes with ABSOLUTELY NO WARRANTY. You may redistribute it\0Aunder the terms of the GNU General Public License, Version 2.\0A\00"
@stderr = global i32 0
@.str.1 = [24 x i8] c"%s: invalid local port\0A\00"
@.str.2 = [25 x i8] c"%s: invalid remote port\0A\00"
@AF_INET = global i64 0
@.str.3 = [24 x i8] c"%s: wrong address type\0A\00"
@PF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.4 = [7 x i8] c"socket\00"
@INADDR_ANY = global i32 0
@.str.5 = [5 x i8] c"bind\00"
@.str.6 = [8 x i8] c"connect\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = bitcast %struct.sockaddr_in* %3 to i8*
%5 = icmp eq i32 %0, 4
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fputs(i8* getelementptr inbounds ([451 x i8], [451 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %78
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = add i32 %12, -65536
%14 = icmp ult i32 %13, -65535
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %11)
br label %78
18: ; preds = %9
%19 = getelementptr inbounds i8*, i8** %1, i64 3
%20 = load i8*, i8** %19
%21 = tail call i32 @atoi(i8* %20)
%22 = add i32 %21, -65536
%23 = icmp ult i32 %22, -65535
br i1 %23, label %24, label %27
24: ; preds = %18
%25 = load i32, i32* @stderr
%26 = tail call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %20)
br label %78
27: ; preds = %18
%28 = getelementptr inbounds i8*, i8** %1, i64 2
%29 = load i8*, i8** %28
%30 = tail call %struct.hostent* @gethostbyname(i8* %29)
%31 = icmp eq %struct.hostent* %30, null
br i1 %31, label %32, label %35
32: ; preds = %27
%33 = load i8*, i8** %28
%34 = tail call i32 @herror(i8* %33)
br label %78
35: ; preds = %27
%36 = load i64, i64* @AF_INET
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i64 %36, i64* %37
%38 = getelementptr inbounds %struct.hostent, %struct.hostent* %30, i64 0, i32 0
%39 = load i64, i64* %38
%40 = icmp eq i64 %36, %39
br i1 %40, label %41, label %45
41: ; preds = %35
%42 = getelementptr inbounds %struct.hostent, %struct.hostent* %30, i64 0, i32 1
%43 = load i32, i32* %42
%44 = icmp eq i32 %43, 4
br i1 %44, label %49, label %45
45: ; preds = %41, %35
%46 = load i32, i32* @stderr
%47 = load i8*, i8** %28
%48 = tail call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %47)
br label %78
49: ; preds = %41
%50 = load i32, i32* @PF_INET
%51 = load i32, i32* @SOCK_DGRAM
%52 = tail call i32 @socket(i32 %50, i32 %51, i32 0)
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %49
%55 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %78
56: ; preds = %49
%57 = load i32, i32* @INADDR_ANY
%58 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2, i32 0
store i32 %57, i32* %58
%59 = tail call i8* @htons(i32 %12)
%60 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i8* %59, i8** %60
%61 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%62 = call i64 @bind(i32 %52, %struct.sockaddr* %61, i32 24)
%63 = icmp eq i64 %62, 0
br i1 %63, label %66, label %64
64: ; preds = %56
%65 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %78
66: ; preds = %56
%67 = getelementptr inbounds %struct.hostent, %struct.hostent* %30, i64 0, i32 2
%68 = load i64, i64* %67
%69 = inttoptr i64 %68 to i32*
%70 = load i32, i32* %69
store i32 %70, i32* %58
%71 = call i8* @htons(i32 %21)
store i8* %71, i8** %60
%72 = call i64 @connect(i32 %52, %struct.sockaddr* %61, i32 24)
%73 = icmp eq i64 %72, 0
br i1 %73, label %76, label %74
74: ; preds = %66
%75 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
br label %78
76: ; preds = %66
%77 = call i32 @run_airhook(i32 %52, %struct.sockaddr_in* byval(%struct.sockaddr_in) align 8 %3)
br label %78
78: ; preds = %76, %74, %64, %54, %45, %32, %24, %15, %6
%79 = phi i32 [ 3, %6 ], [ 3, %15 ], [ 3, %24 ], [ 2, %32 ], [ 2, %45 ], [ 1, %54 ], [ 1, %64 ], [ 1, %74 ], [ 1, %76 ]
ret i32 %79
}