#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  long s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
};
struct sockaddr {
  int dummy;
};
struct in_addr {
  long s_addr;
};
typedef int /*<<< orphan*/ msg;

/* Variables and functions */
long INADDR_ANY;
int IPPROTO_UDP;
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ LOG_INFO;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ closelog();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getopt(int, char **, char *);
int inSocket(long, short, int);
long inet_addr(char *);
char *inet_ntoa(struct in_addr);
int /*<<< orphan*/ openlog(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ optarg;
int outSocket(long, short, long, short, int);
int /*<<< orphan*/ parseIp(int /*<<< orphan*/, long *, short *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int recvfrom(int, unsigned char *, int, int /*<<< orphan*/, struct sockaddr *,
             int *);
int send(int, unsigned char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  char value[128];
  int socket_in;
  int socket_out;
  struct in_addr ina_tmp;
  struct sockaddr_in sin_from;
  int int_from;
  int len = 255;
  int out = 0;
  int ourpacket = 0;
  int rc, flag;
  unsigned char msg[255];
  int protocol = IPPROTO_UDP;
  long listen_addr = INADDR_ANY;
  short listen_port = 0xaa;
  long send_addr = inet_addr("192.168.0.255");
  short send_port = 55;
  long send_from_addr = INADDR_ANY;
  short send_from_port = 0;
  long ignore_addr = INADDR_ANY;
  short ignore_port = 0;
  while ((rc = getopt(argc, argv, "vho?l:s:f:i:")) > 0) {
    switch (rc) {
    case 'v':
      printf("NETtel IP-Redirection (v%s)\n", "0.2.2");
      exit(0);
      break;
    case 'l':
      parseIp(optarg, &listen_addr, &listen_port);
      break;
    case 's':
      parseIp(optarg, &send_addr, &send_port);
      break;
    case 'f':
      parseIp(optarg, &send_from_addr, &send_from_port);
      break;
    case 'i':
      parseIp(optarg, &ignore_addr, &ignore_port);
      break;
    case 'o':
      out = 1;
      break;
    case '?':
      usage();
      exit(0);
      break;
    case 'h':
      usage();
      exit(0);
      break;
    }
  }
  openlog("ipredirect", 0, 0);
  syslog(LOG_INFO, "NETtel IP-Redirection (v%s) started", "0.2.2");
  printf("NETtel IP-Redirection (v%s) started\n", "0.2.2");
  socket_out =
      outSocket(send_from_addr, send_from_port, send_addr, send_port, protocol);
  if (!out) {
    socket_in = inSocket(listen_addr, listen_port, protocol);
  }
  while (1) {
    if (!out) {
      printf("Waiting for packet...\n");
      if ((len = recvfrom(socket_in, msg, sizeof(msg), 0,
                          (struct sockaddr *)&sin_from, &int_from)) == -1) {
        syslog(LOG_ERR, "couldnt recv packet");
        perror("couldnt recv packet\n");
      }
      printf("recieved\n");
      ina_tmp.s_addr = sin_from.sin_addr.s_addr;
      printf("packet from %s\n", inet_ntoa(ina_tmp));
    }
    if (ignore_addr != sin_from.sin_addr.s_addr) {
      printf("Packet accepted!!!!\n");
      printf("Sending..len = %d\n", len);
      if (send(socket_out, msg, len, 0) == -1) {
        perror("couldnt send packet");
      }
      printf("Sent\n");
    } else {
      printf("Packet ignored\n");
    }
  }
  close(socket_out);
  if (!out) {
    close(socket_in);
  }
  closelog();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xff,-0xb0(%rbp)
movl   $0x0,-0xb4(%rbp)
movl   $0x0,-0xb8(%rbp)
mov    0x2d9a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c4(%rbp)
mov    0x2db3(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x1d0(%rbp)
movw   $0xaa,-0x1d2(%rbp)
lea    0xe99(%rip),%rdi
call   1070 <inet_addr@plt>
mov    %rax,-0x1e0(%rbp)
movw   $0x37,-0x1e2(%rbp)
mov    0x2d7d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x1f0(%rbp)
movw   $0x0,-0x1f2(%rbp)
mov    0x2d63(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x200(%rbp)
movw   $0x0,-0x202(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe50(%rip),%rdx
call   10c0 <getopt@plt>
mov    %eax,-0xbc(%rbp)
cmp    $0x0,%eax
jle    13b4 <main+0x1d4>
mov    -0xbc(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x210(%rbp)
sub    $0x37,%eax
ja     13af <main+0x1cf>
mov    -0x210(%rbp),%rax
lea    0xd25(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe10(%rip),%rdi
lea    0xe26(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
mov    0x2cf1(%rip),%rax
mov    (%rax),%edi
lea    -0x1d0(%rbp),%rsi
lea    -0x1d2(%rbp),%rdx
call   10f0 <parseIp@plt>
jmp    13af <main+0x1cf>
mov    0x2cd0(%rip),%rax
mov    (%rax),%edi
lea    -0x1e0(%rbp),%rsi
lea    -0x1e2(%rbp),%rdx
call   10f0 <parseIp@plt>
jmp    13af <main+0x1cf>
mov    0x2caf(%rip),%rax
mov    (%rax),%edi
lea    -0x1f0(%rbp),%rsi
lea    -0x1f2(%rbp),%rdx
call   10f0 <parseIp@plt>
jmp    13af <main+0x1cf>
mov    0x2c8e(%rip),%rax
mov    (%rax),%edi
lea    -0x200(%rbp),%rsi
lea    -0x202(%rbp),%rdx
call   10f0 <parseIp@plt>
jmp    13af <main+0x1cf>
movl   $0x1,-0xb4(%rbp)
jmp    13af <main+0x1cf>
mov    $0x0,%al
call   10a0 <usage@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
mov    $0x0,%al
call   10a0 <usage@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
jmp    1290 <main+0xb0>
lea    0xd63(%rip),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   10d0 <openlog@plt>
mov    0x2c05(%rip),%rax
mov    (%rax),%edi
lea    0xd55(%rip),%rsi
lea    0xd3d(%rip),%rdx
mov    $0x0,%al
call   1080 <syslog@plt>
lea    0xd64(%rip),%rdi
lea    0xd28(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1f0(%rbp),%rdi
mov    -0x1f2(%rbp),%cx
mov    -0x1e0(%rbp),%rdx
mov    -0x1e2(%rbp),%ax
mov    -0x1c4(%rbp),%r8d
movswl %cx,%esi
movswl %ax,%ecx
call   1100 <outSocket@plt>
mov    %eax,-0x98(%rbp)
cmpl   $0x0,-0xb4(%rbp)
jne    145a <main+0x27a>
mov    -0x1d0(%rbp),%rdi
mov    -0x1d2(%rbp),%ax
mov    -0x1c4(%rbp),%edx
movswl %ax,%esi
call   1030 <inSocket@plt>
mov    %eax,-0x94(%rbp)
jmp    145f <main+0x27f>
cmpl   $0x0,-0xb4(%rbp)
jne    150c <main+0x32c>
lea    0xcff(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x94(%rbp),%edi
lea    -0x1c0(%rbp),%rsi
lea    -0xa8(%rbp),%r8
mov    $0xff,%edx
xor    %ecx,%ecx
lea    -0xac(%rbp),%r9
call   1090 <recvfrom@plt>
mov    %eax,-0xb0(%rbp)
cmp    $0xffffffff,%eax
jne    14d3 <main+0x2f3>
mov    0x2b09(%rip),%rax
mov    (%rax),%edi
lea    0xcc9(%rip),%rsi
mov    $0x0,%al
call   1080 <syslog@plt>
lea    0xccf(%rip),%rdi
call   10b0 <perror@plt>
lea    0xcd8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0xa8(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0xa0(%rbp),%rdi
call   1040 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xcb7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x200(%rbp),%rax
cmp    -0xa8(%rbp),%rax
je     1584 <main+0x3a4>
lea    0xca5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0xb0(%rbp),%esi
lea    0xca6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x98(%rbp),%edi
lea    -0x1c0(%rbp),%rsi
mov    -0xb0(%rbp),%edx
xor    %ecx,%ecx
call   1050 <send@plt>
cmp    $0xffffffff,%eax
jne    1571 <main+0x391>
lea    0xc88(%rip),%rdi
call   10b0 <perror@plt>
lea    0xc90(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1592 <main+0x3b2>
lea    0xc83(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    145f <main+0x27f>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x148,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2dab(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    0x2dc6(%rip),%r14
mov    (%r14),%rax
mov    %rax,0x28(%rsp)
movw   $0xaa,0x8(%rsp)
lea    0xeb0(%rip),%rdi
call   1080 <inet_addr@plt>
mov    %rax,0x20(%rsp)
movw   $0x37,0x6(%rsp)
mov    (%r14),%rax
mov    %rax,0x18(%rsp)
movw   $0x0,0x4(%rsp)
mov    %rax,0x10(%rsp)
movw   $0x0,0xa(%rsp)
lea    0xe8b(%rip),%rdx
mov    %ebp,%edi
mov    %rbx,%rsi
call   10d0 <getopt@plt>
xor    %r13d,%r13d
test   %eax,%eax
jle    12f8 <main+0x108>
lea    0xe6f(%rip),%r15
lea    0xd7a(%rip),%r12
mov    0x2d6b(%rip),%r14
jmp    12b2 <main+0xc2>
mov    (%r14),%edi
lea    0x28(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1100 <parseIp@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   10d0 <getopt@plt>
test   %eax,%eax
jle    12f8 <main+0x108>
add    $0xffffffc1,%eax
cmp    $0x37,%eax
ja     12a1 <main+0xb1>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
mov    (%r14),%edi
lea    0x18(%rsp),%rsi
lea    0x4(%rsp),%rdx
jmp    129c <main+0xac>
mov    (%r14),%edi
lea    0x10(%rsp),%rsi
lea    0xa(%rsp),%rdx
jmp    129c <main+0xac>
mov    $0x1,%r13d
jmp    12a1 <main+0xb1>
mov    (%r14),%edi
lea    0x20(%rsp),%rsi
lea    0x6(%rsp),%rdx
jmp    129c <main+0xac>
lea    0xe1f(%rip),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10e0 <openlog@plt>
mov    0x2cc1(%rip),%rax
mov    (%rax),%edi
lea    0xe11(%rip),%rsi
lea    0xdf9(%rip),%rbx
mov    %rbx,%rdx
xor    %eax,%eax
call   1090 <syslog@plt>
lea    0xe1d(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x18(%rsp),%rdi
movswl 0x4(%rsp),%esi
mov    0x20(%rsp),%rdx
movswl 0x6(%rsp),%ecx
mov    0xc(%rsp),%ebp
mov    %ebp,%r8d
call   1110 <outSocket@plt>
mov    %eax,%r15d
test   %r13d,%r13d
jne    1375 <main+0x185>
mov    0x28(%rsp),%rdi
movswl 0x8(%rsp),%esi
mov    %ebp,%edx
call   1030 <inSocket@plt>
mov    %eax,%ebx
mov    $0xff,%r12d
lea    0x40(%rsp),%rbp
lea    0xe6a(%rip),%r14
jmp    1395 <main+0x1a5>
nopl   0x0(%rax)
call   1040 <puts@plt>
test   %r13d,%r13d
jne    1413 <main+0x223>
lea    0xe31(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0xff,%edx
xor    %ecx,%ecx
lea    0x30(%rsp),%r8
lea    0x3c(%rsp),%r9
call   10a0 <recvfrom@plt>
mov    %eax,%r12d
cmp    $0xffffffff,%eax
jne    13ec <main+0x1fc>
mov    0x2bf0(%rip),%rax
mov    (%rax),%edi
lea    0xd99(%rip),%rsi
xor    %eax,%eax
call   1090 <syslog@plt>
lea    0xd9f(%rip),%rdi
call   10c0 <perror@plt>
lea    0xdf5(%rip),%rdi
call   1040 <puts@plt>
mov    0x30(%rsp),%rdi
call   1050 <inet_ntoa@plt>
lea    0xd92(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x10(%rsp),%rax
mov    %r14,%rdi
cmp    0x30(%rsp),%rax
je     1390 <main+0x1a0>
lea    0xdd3(%rip),%rdi
call   1040 <puts@plt>
lea    0xd72(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15d,%edi
mov    %rbp,%rsi
mov    %r12d,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
lea    0xdba(%rip),%rdi
cmp    $0xffffffff,%eax
jne    1390 <main+0x1a0>
lea    0xd54(%rip),%rdi
call   10c0 <perror@plt>
lea    0xd9e(%rip),%rdi
jmp    1390 <main+0x1a0>
xor    %eax,%eax
call   10b0 <usage@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
lea    0xc6b(%rip),%rdi
lea    0xc81(%rip),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %edi,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.in_addr = type { i64 }
%struct.sockaddr_in = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i64 }
%struct.sockaddr = type { i32 }
@IPPROTO_UDP = global i32 0
@INADDR_ANY = global i64 0
@.str = [14 x i8] c"192.168.0.255\00"
@.str.1 = [13 x i8] c"vho?l:s:f:i:\00"
@.str.2 = [29 x i8] c"NETtel IP-Redirection (v%s)\0A\00"
@.str.3 = [6 x i8] c"0.2.2\00"
@optarg = global i32 0
@.str.4 = [11 x i8] c"ipredirect\00"
@LOG_INFO = global i32 0
@.str.5 = [36 x i8] c"NETtel IP-Redirection (v%s) started\00"
@.str.6 = [37 x i8] c"NETtel IP-Redirection (v%s) started\0A\00"
@.str.7 = [23 x i8] c"Waiting for packet...\0A\00"
@LOG_ERR = global i32 0
@.str.8 = [20 x i8] c"couldnt recv packet\00"
@.str.9 = [21 x i8] c"couldnt recv packet\0A\00"
@.str.10 = [10 x i8] c"recieved\0A\00"
@.str.11 = [16 x i8] c"packet from %s\0A\00"
@.str.12 = [21 x i8] c"Packet accepted!!!!\0A\00"
@.str.13 = [19 x i8] c"Sending..len = %d\0A\00"
@.str.14 = [20 x i8] c"couldnt send packet\00"
@.str.15 = [6 x i8] c"Sent\0A\00"
@.str.16 = [16 x i8] c"Packet ignored\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [128 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.in_addr
%10 = alloca %struct.sockaddr_in
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca [255 x i8]
%18 = alloca i32
%19 = alloca i64
%20 = alloca i16
%21 = alloca i64
%22 = alloca i16
%23 = alloca i64
%24 = alloca i16
%25 = alloca i64
%26 = alloca i16
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 255, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
%27 = load i32, i32* @IPPROTO_UDP
store i32 %27, i32* %18
%28 = load i64, i64* @INADDR_ANY
store i64 %28, i64* %19
store i16 170, i16* %20
%29 = call i64 @inet_addr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i64 %29, i64* %21
store i16 55, i16* %22
%30 = load i64, i64* @INADDR_ANY
store i64 %30, i64* %23
store i16 0, i16* %24
%31 = load i64, i64* @INADDR_ANY
store i64 %31, i64* %25
store i16 0, i16* %26
br label %32
32: ; preds = %61, %2
%33 = load i32, i32* %4
%34 = load i8**, i8*** %5
%35 = call i32 @getopt(i32 %33, i8** %34, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
store i32 %35, i32* %15
%36 = icmp sgt i32 %35, 0
br i1 %36, label %37, label %62
37: ; preds = %32
%38 = load i32, i32* %15
switch i32 %38, label %61 [
i32 118, label %39
i32 108, label %42
i32 115, label %45
i32 102, label %48
i32 105, label %51
i32 111, label %54
i32 63, label %55
i32 104, label %58
]
39: ; preds = %37
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%41 = call i32 @exit(i32 0)
unreachable
42: ; preds = %37
%43 = load i32, i32* @optarg
%44 = call i32 @parseIp(i32 %43, i64* %19, i16* %20)
br label %61
45: ; preds = %37
%46 = load i32, i32* @optarg
%47 = call i32 @parseIp(i32 %46, i64* %21, i16* %22)
br label %61
48: ; preds = %37
%49 = load i32, i32* @optarg
%50 = call i32 @parseIp(i32 %49, i64* %23, i16* %24)
br label %61
51: ; preds = %37
%52 = load i32, i32* @optarg
%53 = call i32 @parseIp(i32 %52, i64* %25, i16* %26)
br label %61
54: ; preds = %37
store i32 1, i32* %13
br label %61
55: ; preds = %37
%56 = call i32 (...) @usage()
%57 = call i32 @exit(i32 0)
unreachable
58: ; preds = %37
%59 = call i32 (...) @usage()
%60 = call i32 @exit(i32 0)
unreachable
61: ; preds = %37, %54, %51, %48, %45, %42
br label %32
62: ; preds = %32
%63 = call i32 @openlog(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 0, i32 0)
%64 = load i32, i32* @LOG_INFO
%65 = call i32 (i32, i8*, ...) @syslog(i32 %64, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%67 = load i64, i64* %23
%68 = load i16, i16* %24
%69 = load i64, i64* %21
%70 = load i16, i16* %22
%71 = load i32, i32* %18
%72 = call i32 @outSocket(i64 %67, i16 signext %68, i64 %69, i16 signext %70, i32 %71)
store i32 %72, i32* %8
%73 = load i32, i32* %13
%74 = icmp ne i32 %73, 0
br i1 %74, label %80, label %75
75: ; preds = %62
%76 = load i64, i64* %19
%77 = load i16, i16* %20
%78 = load i32, i32* %18
%79 = call i32 @inSocket(i64 %76, i16 signext %77, i32 %78)
store i32 %79, i32* %7
br label %80
80: ; preds = %75, %62
br label %81
81: ; preds = %80, %126
%82 = load i32, i32* %13
%83 = icmp ne i32 %82, 0
br i1 %83, label %105, label %84
84: ; preds = %81
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
%86 = load i32, i32* %7
%87 = getelementptr inbounds [255 x i8], [255 x i8]* %17, i64 0, i64 0
%88 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%89 = call i32 @recvfrom(i32 %86, i8* %87, i32 255, i32 0, %struct.sockaddr* %88, i32* %11)
store i32 %89, i32* %12
%90 = icmp eq i32 %89, -1
br i1 %90, label %91, label %95
91: ; preds = %84
%92 = load i32, i32* @LOG_ERR
%93 = call i32 (i32, i8*, ...) @syslog(i32 %92, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
%94 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
br label %95
95: ; preds = %91, %84
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%97 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%98 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %97, i32 0, i32 0
%99 = load i64, i64* %98
%100 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %9, i32 0, i32 0
store i64 %99, i64* %100
%101 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %9, i32 0, i32 0
%102 = load i64, i64* %101
%103 = call i8* @inet_ntoa(i64 %102)
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8* %103)
br label %105
105: ; preds = %95, %81
%106 = load i64, i64* %25
%107 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%108 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %107, i32 0, i32 0
%109 = load i64, i64* %108
%110 = icmp ne i64 %106, %109
br i1 %110, label %111, label %124
111: ; preds = %105
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0))
%113 = load i32, i32* %12
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0), i32 %113)
%115 = load i32, i32* %8
%116 = getelementptr inbounds [255 x i8], [255 x i8]* %17, i64 0, i64 0
%117 = load i32, i32* %12
%118 = call i32 @send(i32 %115, i8* %116, i32 %117, i32 0)
%119 = icmp eq i32 %118, -1
br i1 %119, label %120, label %122
120: ; preds = %111
%121 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0))
br label %122
122: ; preds = %120, %111
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0))
br label %126
124: ; preds = %105
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.16, i64 0, i64 0))
br label %126
126: ; preds = %124, %122
br label %81
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i64 }
%struct.sockaddr = type { i32 }
@IPPROTO_UDP = global i32 0
@INADDR_ANY = global i64 0
@.str = [14 x i8] c"192.168.0.255\00"
@.str.1 = [13 x i8] c"vho?l:s:f:i:\00"
@.str.2 = [29 x i8] c"NETtel IP-Redirection (v%s)\0A\00"
@.str.3 = [6 x i8] c"0.2.2\00"
@optarg = global i32 0
@.str.4 = [11 x i8] c"ipredirect\00"
@LOG_INFO = global i32 0
@.str.5 = [36 x i8] c"NETtel IP-Redirection (v%s) started\00"
@.str.6 = [37 x i8] c"NETtel IP-Redirection (v%s) started\0A\00"
@LOG_ERR = global i32 0
@.str.8 = [20 x i8] c"couldnt recv packet\00"
@.str.9 = [21 x i8] c"couldnt recv packet\0A\00"
@.str.11 = [16 x i8] c"packet from %s\0A\00"
@.str.13 = [19 x i8] c"Sending..len = %d\0A\00"
@.str.14 = [20 x i8] c"couldnt send packet\00"
@str = [22 x i8] c"Waiting for packet...\00"
@str.17 = [9 x i8] c"recieved\00"
@str.18 = [15 x i8] c"Packet ignored\00"
@str.19 = [20 x i8] c"Packet accepted!!!!\00"
@str.20 = [5 x i8] c"Sent\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = alloca [255 x i8]
%6 = alloca i64
%7 = alloca i16
%8 = alloca i64
%9 = alloca i16
%10 = alloca i64
%11 = alloca i16
%12 = alloca i64
%13 = alloca i16
%14 = bitcast %struct.sockaddr_in* %3 to i8*
%15 = bitcast i32* %4 to i8*
%16 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%17 = load i32, i32* @IPPROTO_UDP
%18 = bitcast i64* %6 to i8*
%19 = load i64, i64* @INADDR_ANY
store i64 %19, i64* %6
%20 = bitcast i16* %7 to i8*
store i16 170, i16* %7
%21 = bitcast i64* %8 to i8*
%22 = tail call i64 @inet_addr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i64 %22, i64* %8
%23 = bitcast i16* %9 to i8*
store i16 55, i16* %9
%24 = bitcast i64* %10 to i8*
%25 = load i64, i64* @INADDR_ANY
store i64 %25, i64* %10
%26 = bitcast i16* %11 to i8*
store i16 0, i16* %11
%27 = bitcast i64* %12 to i8*
store i64 %25, i64* %12
%28 = bitcast i16* %13 to i8*
store i16 0, i16* %13
%29 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp sgt i32 %29, 0
br i1 %30, label %31, label %60
31: ; preds = %2, %56
%32 = phi i32 [ %58, %56 ], [ %29, %2 ]
%33 = phi i32 [ %57, %56 ], [ 0, %2 ]
switch i32 %32, label %56 [
i32 118, label %34
i32 108, label %37
i32 115, label %40
i32 102, label %43
i32 105, label %46
i32 111, label %49
i32 63, label %50
i32 104, label %53
]
34: ; preds = %31
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%36 = call i32 @exit(i32 0)
unreachable
37: ; preds = %31
%38 = load i32, i32* @optarg
%39 = call i32 @parseIp(i32 %38, i64* %6, i16* %7)
br label %56
40: ; preds = %31
%41 = load i32, i32* @optarg
%42 = call i32 @parseIp(i32 %41, i64* %8, i16* %9)
br label %56
43: ; preds = %31
%44 = load i32, i32* @optarg
%45 = call i32 @parseIp(i32 %44, i64* %10, i16* %11)
br label %56
46: ; preds = %31
%47 = load i32, i32* @optarg
%48 = call i32 @parseIp(i32 %47, i64* %12, i16* %13)
br label %56
49: ; preds = %31
br label %56
50: ; preds = %31
%51 = call i32 (...) @usage()
%52 = call i32 @exit(i32 0)
unreachable
53: ; preds = %31
%54 = call i32 (...) @usage()
%55 = call i32 @exit(i32 0)
unreachable
56: ; preds = %31, %49, %46, %43, %40, %37
%57 = phi i32 [ %33, %31 ], [ 1, %49 ], [ %33, %46 ], [ %33, %43 ], [ %33, %40 ], [ %33, %37 ]
%58 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%59 = icmp sgt i32 %58, 0
br i1 %59, label %31, label %60
60: ; preds = %56, %2
%61 = phi i32 [ 0, %2 ], [ %57, %56 ]
%62 = call i32 @openlog(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 0, i32 0)
%63 = load i32, i32* @LOG_INFO
%64 = call i32 (i32, i8*, ...) @syslog(i32 %63, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%66 = load i64, i64* %10
%67 = load i16, i16* %11
%68 = load i64, i64* %8
%69 = load i16, i16* %9
%70 = call i32 @outSocket(i64 %66, i16 signext %67, i64 %68, i16 signext %69, i32 %17)
%71 = icmp eq i32 %61, 0
br i1 %71, label %72, label %76
72: ; preds = %60
%73 = load i64, i64* %6
%74 = load i16, i16* %7
%75 = call i32 @inSocket(i64 %73, i16 signext %74, i32 %17)
br label %76
76: ; preds = %72, %60
%77 = phi i32 [ undef, %60 ], [ %75, %72 ]
%78 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%79 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0, i32 0
br label %80
80: ; preds = %107, %76
%81 = phi i32 [ 255, %76 ], [ %96, %107 ]
br i1 %71, label %82, label %95
82: ; preds = %80
%83 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%84 = call i32 @recvfrom(i32 %77, i8* %16, i32 255, i32 0, %struct.sockaddr* %78, i32* %4)
%85 = icmp eq i32 %84, -1
br i1 %85, label %86, label %90
86: ; preds = %82
%87 = load i32, i32* @LOG_ERR
%88 = call i32 (i32, i8*, ...) @syslog(i32 %87, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
%89 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
br label %90
90: ; preds = %86, %82
%91 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.17, i64 0, i64 0))
%92 = load i64, i64* %79
%93 = call i8* @inet_ntoa(i64 %92)
%94 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8* %93)
br label %95
95: ; preds = %90, %80
%96 = phi i32 [ %81, %80 ], [ %84, %90 ]
%97 = load i64, i64* %12
%98 = load i64, i64* %79
%99 = icmp eq i64 %97, %98
br i1 %99, label %107, label %100
100: ; preds = %95
%101 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.19, i64 0, i64 0))
%102 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0), i32 %96)
%103 = call i32 @send(i32 %70, i8* %16, i32 %96, i32 0)
%104 = icmp eq i32 %103, -1
br i1 %104, label %105, label %107
105: ; preds = %100
%106 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0))
br label %107
107: ; preds = %95, %100, %105
%108 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @str.20, i64 0, i64 0), %105 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @str.20, i64 0, i64 0), %100 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.18, i64 0, i64 0), %95 ]
%109 = call i32 @puts(i8* dereferenceable(1) %108)
br label %80
}