#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 utsname {
  int /*<<< orphan*/ sysname;
};
struct TYPE_2__ {
  void *s_addr;
};
struct sockaddr_in {
  void *sin_family;
  TYPE_1__ sin_addr;
  void *sin_port;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ socklen_t;
typedef int /*<<< orphan*/ s_in;
typedef int /*<<< orphan*/ len;
typedef int /*<<< orphan*/ dude_sin;

/* Variables and functions */
void *INADDR_ANY;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ IPPROTO_UDP;
void *PF_INET;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int accept(int, struct sockaddr *, int /*<<< orphan*/ *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ drop_privs();
int /*<<< orphan*/ err(int, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getopt(int, char **, char *);
int /*<<< orphan*/ handle_dude(int, int);
void *htons(int);
char *inet_ntoa(TYPE_1__);
int listen(int, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int socket(void *, int /*<<< orphan*/, int /*<<< orphan*/);
int strncasecmp(int /*<<< orphan*/, char *, int);
scalar_t__ uname(struct utsname *);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  struct utsname utsName;
  struct sockaddr_in s_in;
  struct sockaddr_in dude_sin;
  int len, udp, ch, dude, s;
  int port = 6969;
  int drop;
  while ((ch = getopt(argc, argv, "ph")) != -1) {
    switch (ch) {
    case 'p':
      drop = 0;
      break;
    default:
    case 'h':
      usage();
      break;
    }
  }
  memset(&s_in, 0, sizeof(s_in));
  s_in.sin_family = PF_INET;
  s_in.sin_addr.s_addr = INADDR_ANY;
  s_in.sin_port = htons(6969);
  udp = socket(s_in.sin_family, SOCK_DGRAM, IPPROTO_UDP);
  if (udp == -1)
    err(1, "socket(UDP)");
  if (bind(udp, (struct sockaddr *)&s_in, sizeof(s_in)) == -1)
    err(1, "bind()");
  s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
  if (s == -1)
    err(1, "socket(TCP)");
  drop = 1;
  if (uname(&utsName) == 0) {
    drop = strncasecmp(utsName.sysname, "cygwin", 6);
  }
  if (drop)
    drop_privs();
  memset(&s_in, 0, sizeof(s_in));
  s_in.sin_family = PF_INET;
  s_in.sin_port = htons(port);
  s_in.sin_addr.s_addr = INADDR_ANY;
  len = 1;
  if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &len, sizeof(len)) == -1)
    err(1, "setsockopt(SO_REUSEADDR)");
  if (bind(s, (struct sockaddr *)&s_in, sizeof(s_in)) == -1)
    err(1, "bind()");
  if (listen(s, 5) == -1)
    err(1, "listen()");
  while (1) {
    len = sizeof(dude_sin);
    printf("Waiting for connexion\n");
    dude = accept(s, (struct sockaddr *)&dude_sin, (socklen_t *)&len);
    if (dude == -1)
      err(1, "accept()");
    printf("Got connection from %s\n", inet_ntoa(dude_sin.sin_addr));
    handle_dude(dude, udp);
    printf("That was it\n");
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1b39,-0x60(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdd5(%rip),%rdx
call   1100 <getopt@plt>
mov    %eax,-0x54(%rbp)
cmp    $0xffffffff,%eax
je     127e <main+0x7e>
mov    -0x54(%rbp),%eax
mov    %eax,-0x68(%rbp)
sub    $0x68,%eax
je     1272 <main+0x72>
jmp    1250 <main+0x50>
mov    -0x68(%rbp),%eax
sub    $0x70,%eax
jne    126d <main+0x6d>
jmp    1261 <main+0x61>
movl   $0x0,-0x64(%rbp)
jmp    1279 <main+0x79>
jmp    1272 <main+0x72>
mov    $0x0,%al
call   10d0 <usage@plt>
jmp    121d <main+0x1d>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1090 <memset@plt>
mov    0x2d23(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    0x2d3d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    $0x1b39,%edi
call   1060 <htons@plt>
mov    %rax,-0x20(%rbp)
mov    -0x30(%rbp),%rdi
mov    0x2d0d(%rip),%rax
mov    (%rax),%esi
mov    0x2cd4(%rip),%rax
mov    (%rax),%edx
call   1120 <socket@plt>
mov    %eax,-0x50(%rbp)
cmpl   $0xffffffff,-0x50(%rbp)
jne    12f1 <main+0xf1>
mov    $0x1,%edi
lea    0xd17(%rip),%rsi
call   10a0 <err@plt>
mov    -0x50(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x18,%edx
call   10e0 <bind@plt>
cmp    $0xffffffff,%eax
jne    131c <main+0x11c>
mov    $0x1,%edi
lea    0xcf8(%rip),%rsi
call   10a0 <err@plt>
mov    0x2c95(%rip),%rax
mov    (%rax),%rdi
mov    0x2c93(%rip),%rax
mov    (%rax),%esi
mov    0x2ca2(%rip),%rax
mov    (%rax),%edx
call   1120 <socket@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0xffffffff,-0x5c(%rbp)
jne    135b <main+0x15b>
mov    $0x1,%edi
lea    0xcc0(%rip),%rsi
call   10a0 <err@plt>
movl   $0x1,-0x64(%rbp)
lea    -0x18(%rbp),%rdi
call   1080 <uname@plt>
cmp    $0x0,%rax
jne    138c <main+0x18c>
mov    -0x18(%rbp),%edi
lea    0xca3(%rip),%rsi
mov    $0x6,%edx
call   10b0 <strncasecmp@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
je     139d <main+0x19d>
mov    $0x0,%al
call   1040 <drop_privs@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1090 <memset@plt>
mov    0x2c04(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x60(%rbp),%edi
call   1060 <htons@plt>
mov    %rax,-0x20(%rbp)
mov    0x2c12(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x4c(%rbp)
mov    -0x5c(%rbp),%edi
mov    0x2c02(%rip),%rax
mov    (%rax),%esi
mov    0x2bc1(%rip),%rax
mov    (%rax),%edx
lea    -0x4c(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
jne    141a <main+0x21a>
mov    $0x1,%edi
lea    0xc14(%rip),%rsi
call   10a0 <err@plt>
mov    -0x5c(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x18,%edx
call   10e0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1445 <main+0x245>
mov    $0x1,%edi
lea    0xbcf(%rip),%rsi
call   10a0 <err@plt>
mov    -0x5c(%rbp),%edi
mov    $0x5,%esi
call   10c0 <listen@plt>
cmp    $0xffffffff,%eax
jne    146c <main+0x26c>
mov    $0x1,%edi
lea    0xbdb(%rip),%rsi
call   10a0 <err@plt>
jmp    1471 <main+0x271>
movl   $0x18,-0x4c(%rbp)
lea    0xbcc(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x5c(%rbp),%edi
lea    -0x48(%rbp),%rsi
lea    -0x4c(%rbp),%rdx
call   1110 <accept@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0xffffffff,-0x58(%rbp)
jne    14b4 <main+0x2b4>
mov    $0x1,%edi
lea    0xbb3(%rip),%rsi
call   10a0 <err@plt>
mov    -0x40(%rbp),%rdi
call   1050 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xba4(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x58(%rbp),%edi
mov    -0x50(%rbp),%esi
call   10f0 <handle_dude@plt>
lea    0xba3(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1471 <main+0x271>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xdd6(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1110 <getopt@plt>
cmp    $0x70,%eax
je     1230 <main+0x20>
cmp    $0xffffffff,%eax
je     1250 <main+0x40>
xor    %eax,%eax
call   10e0 <usage@plt>
jmp    1230 <main+0x20>
lea    0x18(%rsp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   10a0 <memset@plt>
mov    0x2d50(%rip),%rbx
mov    (%rbx),%rax
mov    %rax,0x18(%rsp)
mov    0x2d69(%rip),%r14
mov    (%r14),%rax
mov    %rax,0x20(%rsp)
mov    $0x1b39,%edi
call   1070 <htons@plt>
mov    %rax,0x28(%rsp)
mov    0x18(%rsp),%rdi
mov    0x2d36(%rip),%rax
mov    (%rax),%esi
mov    0x2cfd(%rip),%rax
mov    (%rax),%edx
call   1130 <socket@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    12c2 <main+0xb2>
lea    0xd4b(%rip),%rsi
mov    $0x1,%edi
call   10b0 <err@plt>
lea    0x18(%rsp),%rsi
mov    %ebp,%edi
mov    $0x18,%edx
call   10f0 <bind@plt>
cmp    $0xffffffff,%eax
jne    12e9 <main+0xd9>
lea    0xd30(%rip),%rsi
mov    $0x1,%edi
call   10b0 <err@plt>
mov    (%rbx),%rdi
mov    0x2ccd(%rip),%rax
mov    (%rax),%esi
mov    0x2cdc(%rip),%rax
mov    (%rax),%edx
call   1130 <socket@plt>
mov    %eax,%r15d
cmp    $0xffffffff,%eax
jne    131c <main+0x10c>
lea    0xd04(%rip),%rsi
mov    $0x1,%edi
call   10b0 <err@plt>
lea    0x10(%rsp),%rdi
call   1090 <uname@plt>
test   %rax,%rax
jne    1344 <main+0x134>
mov    0x10(%rsp),%edi
lea    0xcec(%rip),%rsi
mov    $0x6,%edx
call   10c0 <strncasecmp@plt>
test   %eax,%eax
je     134b <main+0x13b>
xor    %eax,%eax
call   1050 <drop_privs@plt>
lea    0x18(%rsp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   10a0 <memset@plt>
mov    (%rbx),%rax
mov    %rax,0x18(%rsp)
mov    $0x1b39,%edi
call   1070 <htons@plt>
mov    %rax,0x28(%rsp)
mov    (%r14),%rax
mov    %rax,0x20(%rsp)
movl   $0x1,0xc(%rsp)
mov    0x2c5e(%rip),%rax
mov    (%rax),%esi
mov    0x2c1d(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rcx
mov    %r15d,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
cmp    $0xffffffff,%eax
jne    13be <main+0x1ae>
lea    0xc75(%rip),%rsi
mov    $0x1,%edi
call   10b0 <err@plt>
lea    0x18(%rsp),%rsi
mov    %r15d,%edi
mov    $0x18,%edx
call   10f0 <bind@plt>
cmp    $0xffffffff,%eax
jne    13e6 <main+0x1d6>
lea    0xc33(%rip),%rsi
mov    $0x1,%edi
call   10b0 <err@plt>
mov    %r15d,%edi
mov    $0x5,%esi
call   10d0 <listen@plt>
cmp    $0xffffffff,%eax
jne    1409 <main+0x1f9>
lea    0xc43(%rip),%rsi
mov    $0x1,%edi
call   10b0 <err@plt>
lea    0xc(%rsp),%r12
lea    0xc3f(%rip),%r13
lea    0xc66(%rip),%r14
jmp    144c <main+0x23c>
xchg   %ax,%ax
mov    0x38(%rsp),%rdi
call   1060 <inet_ntoa@plt>
mov    %r13,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r15d,%edi
mov    %ebp,%esi
call   1100 <handle_dude@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %ebx,%r15d
movl   $0x18,0xc(%rsp)
lea    0xc11(%rip),%rdi
call   1030 <puts@plt>
mov    %r15d,%ebx
mov    %r15d,%edi
lea    0x30(%rsp),%rsi
mov    %r12,%rdx
call   1120 <accept@plt>
mov    %eax,%r15d
cmp    $0xffffffff,%eax
jne    1420 <main+0x210>
mov    $0x1,%edi
lea    0xbc4(%rip),%rsi
call   10b0 <err@plt>
jmp    1420 <main+0x210>

LLVM IR (-O0):
%struct.utsname = type { i32 }
%struct.sockaddr_in = type { i8*, %struct.TYPE_2__, i8* }
%struct.TYPE_2__ = type { i8* }
%struct.sockaddr = type { i32 }
@.str = [3 x i8] c"ph\00"
@PF_INET = global i8* null
@INADDR_ANY = global i8* null
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@.str.1 = [12 x i8] c"socket(UDP)\00"
@.str.2 = [7 x i8] c"bind()\00"
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str.3 = [12 x i8] c"socket(TCP)\00"
@.str.4 = [7 x i8] c"cygwin\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.5 = [25 x i8] c"setsockopt(SO_REUSEADDR)\00"
@.str.6 = [9 x i8] c"listen()\00"
@.str.7 = [23 x i8] c"Waiting for connexion\0A\00"
@.str.8 = [9 x i8] c"accept()\00"
@.str.9 = [24 x i8] c"Got connection from %s\0A\00"
@.str.10 = [13 x i8] c"That was it\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.utsname
%7 = alloca %struct.sockaddr_in
%8 = alloca %struct.sockaddr_in
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 6969, i32* %14
br label %16
16: ; preds = %27, %2
%17 = load i32, i32* %4
%18 = load i8**, i8*** %5
%19 = call i32 @getopt(i32 %17, i8** %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %19, i32* %11
%20 = icmp ne i32 %19, -1
br i1 %20, label %21, label %28
21: ; preds = %16
%22 = load i32, i32* %11
switch i32 %22, label %24 [
i32 112, label %23
i32 104, label %25
]
23: ; preds = %21
store i32 0, i32* %15
br label %27
24: ; preds = %21
br label %25
25: ; preds = %21, %24
%26 = call i32 (...) @usage()
br label %27
27: ; preds = %25, %23
br label %16
28: ; preds = %16
%29 = call i32 @memset(%struct.sockaddr_in* %7, i32 0, i32 24)
%30 = load i8*, i8** @PF_INET
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
store i8* %30, i8** %31
%32 = load i8*, i8** @INADDR_ANY
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
%34 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %33, i32 0, i32 0
store i8* %32, i8** %34
%35 = call i8* @htons(i32 6969)
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 2
store i8* %35, i8** %36
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
%38 = load i8*, i8** %37
%39 = load i32, i32* @SOCK_DGRAM
%40 = load i32, i32* @IPPROTO_UDP
%41 = call i32 @socket(i8* %38, i32 %39, i32 %40)
store i32 %41, i32* %10
%42 = load i32, i32* %10
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %46
44: ; preds = %28
%45 = call i32 @err(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %46
46: ; preds = %44, %28
%47 = load i32, i32* %10
%48 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%49 = call i32 @bind(i32 %47, %struct.sockaddr* %48, i32 24)
%50 = icmp eq i32 %49, -1
br i1 %50, label %51, label %53
51: ; preds = %46
%52 = call i32 @err(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %53
53: ; preds = %51, %46
%54 = load i8*, i8** @PF_INET
%55 = load i32, i32* @SOCK_STREAM
%56 = load i32, i32* @IPPROTO_TCP
%57 = call i32 @socket(i8* %54, i32 %55, i32 %56)
store i32 %57, i32* %13
%58 = load i32, i32* %13
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %62
60: ; preds = %53
%61 = call i32 @err(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %62
62: ; preds = %60, %53
store i32 1, i32* %15
%63 = call i64 @uname(%struct.utsname* %6)
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %69
65: ; preds = %62
%66 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i32 0, i32 0
%67 = load i32, i32* %66
%68 = call i32 @strncasecmp(i32 %67, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 6)
store i32 %68, i32* %15
br label %69
69: ; preds = %65, %62
%70 = load i32, i32* %15
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %69
%73 = call i32 (...) @drop_privs()
br label %74
74: ; preds = %72, %69
%75 = call i32 @memset(%struct.sockaddr_in* %7, i32 0, i32 24)
%76 = load i8*, i8** @PF_INET
%77 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
store i8* %76, i8** %77
%78 = load i32, i32* %14
%79 = call i8* @htons(i32 %78)
%80 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 2
store i8* %79, i8** %80
%81 = load i8*, i8** @INADDR_ANY
%82 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
%83 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %82, i32 0, i32 0
store i8* %81, i8** %83
store i32 1, i32* %9
%84 = load i32, i32* %13
%85 = load i32, i32* @SOL_SOCKET
%86 = load i32, i32* @SO_REUSEADDR
%87 = call i32 @setsockopt(i32 %84, i32 %85, i32 %86, i32* %9, i32 4)
%88 = icmp eq i32 %87, -1
br i1 %88, label %89, label %91
89: ; preds = %74
%90 = call i32 @err(i32 1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
br label %91
91: ; preds = %89, %74
%92 = load i32, i32* %13
%93 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%94 = call i32 @bind(i32 %92, %struct.sockaddr* %93, i32 24)
%95 = icmp eq i32 %94, -1
br i1 %95, label %96, label %98
96: ; preds = %91
%97 = call i32 @err(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %98
98: ; preds = %96, %91
%99 = load i32, i32* %13
%100 = call i32 @listen(i32 %99, i32 5)
%101 = icmp eq i32 %100, -1
br i1 %101, label %102, label %104
102: ; preds = %98
%103 = call i32 @err(i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
br label %104
104: ; preds = %102, %98
br label %105
105: ; preds = %104, %114
store i32 24, i32* %9
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
%107 = load i32, i32* %13
%108 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%109 = call i32 @accept(i32 %107, %struct.sockaddr* %108, i32* %9)
store i32 %109, i32* %12
%110 = load i32, i32* %12
%111 = icmp eq i32 %110, -1
br i1 %111, label %112, label %114
112: ; preds = %105
%113 = call i32 @err(i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
br label %114
114: ; preds = %112, %105
%115 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
%116 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %115, i32 0, i32 0
%117 = load i8*, i8** %116
%118 = call i8* @inet_ntoa(i8* %117)
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %118)
%120 = load i32, i32* %12
%121 = load i32, i32* %10
%122 = call i32 @handle_dude(i32 %120, i32 %121)
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
br label %105
}

LLVM IR (-O2):
%struct.utsname = type { i32 }
%struct.sockaddr_in = type { i8*, %struct.TYPE_2__, i8* }
%struct.TYPE_2__ = type { i8* }
%struct.sockaddr = type { i32 }
@.str = [3 x i8] c"ph\00"
@PF_INET = global i8* null
@INADDR_ANY = global i8* null
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@.str.1 = [12 x i8] c"socket(UDP)\00"
@.str.2 = [7 x i8] c"bind()\00"
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str.3 = [12 x i8] c"socket(TCP)\00"
@.str.4 = [7 x i8] c"cygwin\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.5 = [25 x i8] c"setsockopt(SO_REUSEADDR)\00"
@.str.6 = [9 x i8] c"listen()\00"
@.str.8 = [9 x i8] c"accept()\00"
@.str.9 = [24 x i8] c"Got connection from %s\0A\00"
@str = [22 x i8] c"Waiting for connexion\00"
@str.11 = [12 x i8] c"That was it\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.utsname
%4 = alloca %struct.sockaddr_in
%5 = alloca %struct.sockaddr_in
%6 = alloca i32
%7 = bitcast %struct.utsname* %3 to i8*
%8 = bitcast %struct.sockaddr_in* %4 to i8*
%9 = bitcast %struct.sockaddr_in* %5 to i8*
%10 = bitcast i32* %6 to i8*
br label %11
11: ; preds = %13, %2
%12 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %12, label %14 [
i32 -1, label %16
i32 112, label %13
]
13: ; preds = %11, %14
br label %11
14: ; preds = %11
%15 = tail call i32 (...) @usage()
br label %13
16: ; preds = %11
%17 = call i32 @memset(%struct.sockaddr_in* %4, i32 0, i32 24)
%18 = load i8*, i8** @PF_INET
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
store i8* %18, i8** %19
%20 = load i8*, i8** @INADDR_ANY
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1, i32 0
store i8* %20, i8** %21
%22 = call i8* @htons(i32 6969)
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i8* %22, i8** %23
%24 = load i8*, i8** %19
%25 = load i32, i32* @SOCK_DGRAM
%26 = load i32, i32* @IPPROTO_UDP
%27 = call i32 @socket(i8* %24, i32 %25, i32 %26)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %31
29: ; preds = %16
%30 = call i32 @err(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %31
31: ; preds = %29, %16
%32 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%33 = call i32 @bind(i32 %27, %struct.sockaddr* %32, i32 24)
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = call i32 @err(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %37
37: ; preds = %35, %31
%38 = load i8*, i8** @PF_INET
%39 = load i32, i32* @SOCK_STREAM
%40 = load i32, i32* @IPPROTO_TCP
%41 = call i32 @socket(i8* %38, i32 %39, i32 %40)
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %45
43: ; preds = %37
%44 = call i32 @err(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %45
45: ; preds = %43, %37
%46 = call i64 @uname(%struct.utsname* %3)
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %53
48: ; preds = %45
%49 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 0
%50 = load i32, i32* %49
%51 = call i32 @strncasecmp(i32 %50, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 6)
%52 = icmp eq i32 %51, 0
br i1 %52, label %55, label %53
53: ; preds = %45, %48
%54 = call i32 (...) @drop_privs()
br label %55
55: ; preds = %53, %48
%56 = call i32 @memset(%struct.sockaddr_in* %4, i32 0, i32 24)
%57 = load i8*, i8** @PF_INET
store i8* %57, i8** %19
%58 = call i8* @htons(i32 6969)
store i8* %58, i8** %23
%59 = load i8*, i8** @INADDR_ANY
store i8* %59, i8** %21
store i32 1, i32* %6
%60 = load i32, i32* @SOL_SOCKET
%61 = load i32, i32* @SO_REUSEADDR
%62 = call i32 @setsockopt(i32 %41, i32 %60, i32 %61, i32* %6, i32 4)
%63 = icmp eq i32 %62, -1
br i1 %63, label %64, label %66
64: ; preds = %55
%65 = call i32 @err(i32 1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
br label %66
66: ; preds = %64, %55
%67 = call i32 @bind(i32 %41, %struct.sockaddr* %32, i32 24)
%68 = icmp eq i32 %67, -1
br i1 %68, label %69, label %71
69: ; preds = %66
%70 = call i32 @err(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %71
71: ; preds = %69, %66
%72 = call i32 @listen(i32 %41, i32 5)
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %76
74: ; preds = %71
%75 = call i32 @err(i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
br label %76
76: ; preds = %74, %71
%77 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%78 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 1, i32 0
br label %79
79: ; preds = %85, %76
store i32 24, i32* %6
%80 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%81 = call i32 @accept(i32 %41, %struct.sockaddr* %77, i32* %6)
%82 = icmp eq i32 %81, -1
br i1 %82, label %83, label %85
83: ; preds = %79
%84 = call i32 @err(i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
br label %85
85: ; preds = %83, %79
%86 = load i8*, i8** %78
%87 = call i8* @inet_ntoa(i8* %86)
%88 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %87)
%89 = call i32 @handle_dude(i32 %81, i32 %27)
%90 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.11, i64 0, i64 0))
br label %79
}