#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 */
typedef int /*<<< orphan*/ u_short;
struct TYPE_2__ {
  void *s_addr;
};
struct sockaddr_in {
  void *sin_port;
  TYPE_1__ sin_addr;
  void *sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ name;
typedef int /*<<< orphan*/ i;

/* Variables and functions */
void *AF_INET;
scalar_t__ EADDRINUSE;
void *INADDR_ANY;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_RCVBUF;
int /*<<< orphan*/ SO_REUSEADDR;
int /*<<< orphan*/ SO_SNDBUF;
scalar_t__ bind(int, struct sockaddr *, int);
scalar_t__ errno;
scalar_t__ getsockname(int, struct sockaddr *, int *);
void *htons(int /*<<< orphan*/);
int /*<<< orphan*/ info(char *, int);
scalar_t__ listen(int, int);
int ntohs(void *);
int /*<<< orphan*/ pfatal(char *);
int /*<<< orphan*/ pwarning(char *, ...);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, ...);
int socket(void *, int /*<<< orphan*/, int /*<<< orphan*/);
int makesockets(int *portnum, int *udpsockp, int *tcpsockp) {
  struct sockaddr_in name;
  socklen_t length;
  int i, udpsock, tcpsock;
  tcpsock = socket(AF_INET, SOCK_STREAM, 0);
  if (tcpsock < 0) {
    pfatal("opening stream socket");
  }
  i = 1;
  if (setsockopt(tcpsock, SOL_SOCKET, SO_REUSEADDR, (char *)&i, sizeof(i)) < 0)
    pwarning("setsockopt(SO_REUSEADDR)");
  ;
  name.sin_family = AF_INET;
  name.sin_addr.s_addr = INADDR_ANY;
  if (*portnum == 0) {
    name.sin_port = htons((u_short)16534);
    if (!bind(tcpsock, (struct sockaddr *)&name, sizeof(name))) {
      goto bound;
    }
    if (errno != EADDRINUSE)
      pfatal("binding stream socket");
  }
  name.sin_port = htons((u_short)*portnum);
  if (bind(tcpsock, (struct sockaddr *)&name, sizeof(name))) {
    pfatal("binding stream socket");
  }
bound:
  length = sizeof(name);
  if (getsockname(tcpsock, (struct sockaddr *)&name, &length)) {
    pfatal("getsockname");
  }
  if (listen(tcpsock, 128) < 0) {
    pfatal("listen");
  }
  *portnum = ntohs(name.sin_port);
  info("listening on TCP port %d\n", *portnum);
  udpsock = socket(AF_INET, SOCK_DGRAM, 0);
  if (udpsock < 0) {
    pfatal("opening dgram socket");
  }
  i = 1;
  if (setsockopt(udpsock, SOL_SOCKET, SO_REUSEADDR, (char *)&i, sizeof(i)) < 0)
    pwarning("setsockopt(SO_REUSEADDR)");
  ;
  i = (1024 * 128);
  if (setsockopt(udpsock, SOL_SOCKET, SO_SNDBUF, &i, sizeof(i)) < 0)
    pwarning("Could not increase send socket buffer size to %d", (1024 * 128));
  i = (1024 * 128);
  if (setsockopt(udpsock, SOL_SOCKET, SO_RCVBUF, &i, sizeof(i)) < 0)
    pwarning("Could not increase recv socket buffer size to %d", (1024 * 128));
  name.sin_family = AF_INET;
  name.sin_addr.s_addr = INADDR_ANY;
  name.sin_port = htons((u_short)*portnum);
  if (bind(udpsock, (struct sockaddr *)&name, sizeof(name))) {
    pfatal("binding dgram socket");
  }
  length = sizeof(name);
  if (getsockname(udpsock, (struct sockaddr *)&name, &length)) {
    pfatal("getsockname");
  }
  info("listening on UDP port %d\n", ntohs(name.sin_port));
  *tcpsockp = tcpsock;
  *udpsockp = udpsock;
  return 0;
}


x86 assembly (clang, -O0):
<makesockets>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2e25(%rip),%rax
mov    (%rax),%rdi
mov    0x2deb(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
jge    11e7 <makesockets+0x47>
lea    0xe1e(%rip),%rdi
call   1050 <pfatal@plt>
movl   $0x1,-0x38(%rbp)
mov    -0x40(%rbp),%edi
mov    0x2df0(%rip),%rax
mov    (%rax),%esi
mov    0x2d97(%rip),%rax
mov    (%rax),%edx
lea    -0x38(%rbp),%rcx
mov    $0x4,%r8d
mov    $0x0,%al
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    122c <makesockets+0x8c>
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1060 <pwarning@plt>
mov    0x2dad(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    0x2d8f(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
cmpl   $0x0,(%rax)
jne    12ae <makesockets+0x10e>
mov    $0x4096,%edi
call   1040 <htons@plt>
mov    %rax,-0x30(%rbp)
mov    -0x40(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x18,%edx
call   1090 <bind@plt>
cmp    $0x0,%rax
jne    1283 <makesockets+0xe3>
jmp    12e9 <makesockets+0x149>
mov    0x2d16(%rip),%rax
mov    (%rax),%rax
mov    0x2d14(%rip),%rcx
cmp    (%rcx),%rax
je     12a9 <makesockets+0x109>
lea    0xd8b(%rip),%rdi
call   1050 <pfatal@plt>
jmp    12ae <makesockets+0x10e>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1040 <htons@plt>
mov    %rax,-0x30(%rbp)
mov    -0x40(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x18,%edx
call   1090 <bind@plt>
cmp    $0x0,%rax
je     12e4 <makesockets+0x144>
lea    0xd50(%rip),%rdi
call   1050 <pfatal@plt>
jmp    12e9 <makesockets+0x149>
movl   $0x18,-0x34(%rbp)
mov    -0x40(%rbp),%edi
lea    -0x30(%rbp),%rsi
lea    -0x34(%rbp),%rdx
call   10a0 <getsockname@plt>
cmp    $0x0,%rax
je     1316 <makesockets+0x176>
lea    0xd34(%rip),%rdi
call   1050 <pfatal@plt>
mov    -0x40(%rbp),%edi
mov    $0x80,%esi
call   1070 <listen@plt>
cmp    $0x0,%rax
jge    1339 <makesockets+0x199>
lea    0xd1d(%rip),%rdi
call   1050 <pfatal@plt>
mov    -0x30(%rbp),%rdi
call   1080 <ntohs@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xd01(%rip),%rdi
call   10b0 <info@plt>
mov    0x2c7d(%rip),%rax
mov    (%rax),%rdi
mov    0x2c5b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    138f <makesockets+0x1ef>
lea    0xce8(%rip),%rdi
call   1050 <pfatal@plt>
movl   $0x1,-0x38(%rbp)
mov    -0x3c(%rbp),%edi
mov    0x2c48(%rip),%rax
mov    (%rax),%esi
mov    0x2bef(%rip),%rax
mov    (%rax),%edx
lea    -0x38(%rbp),%rcx
mov    $0x4,%r8d
mov    $0x0,%al
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    13d4 <makesockets+0x234>
lea    0xc49(%rip),%rdi
mov    $0x0,%al
call   1060 <pwarning@plt>
movl   $0x20000,-0x38(%rbp)
mov    -0x3c(%rbp),%edi
mov    0x2c03(%rip),%rax
mov    (%rax),%esi
mov    0x2bea(%rip),%rax
mov    (%rax),%edx
lea    -0x38(%rbp),%rcx
mov    $0x4,%r8d
mov    $0x0,%al
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    141e <makesockets+0x27e>
lea    0xc75(%rip),%rdi
mov    $0x20000,%esi
mov    $0x0,%al
call   1060 <pwarning@plt>
movl   $0x20000,-0x38(%rbp)
mov    -0x3c(%rbp),%edi
mov    0x2bb9(%rip),%rax
mov    (%rax),%esi
mov    0x2b80(%rip),%rax
mov    (%rax),%edx
lea    -0x38(%rbp),%rcx
mov    $0x4,%r8d
mov    $0x0,%al
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    1468 <makesockets+0x2c8>
lea    0xc5c(%rip),%rdi
mov    $0x20000,%esi
mov    $0x0,%al
call   1060 <pwarning@plt>
mov    0x2b71(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    0x2b53(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1040 <htons@plt>
mov    %rax,-0x30(%rbp)
mov    -0x3c(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x18,%edx
call   1090 <bind@plt>
cmp    $0x0,%rax
je     14ba <makesockets+0x31a>
lea    0xc34(%rip),%rdi
call   1050 <pfatal@plt>
movl   $0x18,-0x34(%rbp)
mov    -0x3c(%rbp),%edi
lea    -0x30(%rbp),%rsi
lea    -0x34(%rbp),%rdx
call   10a0 <getsockname@plt>
cmp    $0x0,%rax
je     14e7 <makesockets+0x347>
lea    0xb63(%rip),%rdi
call   1050 <pfatal@plt>
mov    -0x30(%rbp),%rdi
call   1080 <ntohs@plt>
mov    %eax,%esi
lea    0xc05(%rip),%rdi
call   10b0 <info@plt>
mov    -0x40(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x3c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makesockets>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,0x28(%rsp)
mov    %rsi,0x30(%rsp)
mov    %rdi,%r12
mov    0x2e1e(%rip),%r13
mov    0x0(%r13),%rdi
mov    0x2de3(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    11e8 <makesockets+0x48>
lea    0xe1d(%rip),%rdi
call   1050 <pfatal@plt>
movl   $0x1,0x8(%rsp)
mov    0x2df1(%rip),%r15
mov    (%r15),%esi
mov    0x2d97(%rip),%r14
mov    (%r14),%edx
lea    0x8(%rsp),%rcx
mov    $0x4,%r8d
mov    %ebp,%edi
xor    %eax,%eax
call   1030 <setsockopt@plt>
test   %rax,%rax
jns    122b <makesockets+0x8b>
lea    0xdf2(%rip),%rdi
xor    %eax,%eax
call   1060 <pwarning@plt>
mov    0x0(%r13),%rax
mov    %rax,0x20(%rsp)
mov    0x2d95(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x18(%rsp)
cmpl   $0x0,(%r12)
je     127c <makesockets+0xdc>
mov    (%r12),%edi
call   1040 <htons@plt>
mov    %rax,0x10(%rsp)
lea    0x10(%rsp),%rsi
mov    %ebp,%edi
mov    $0x18,%edx
call   1090 <bind@plt>
test   %rax,%rax
je     12c5 <makesockets+0x125>
lea    0xdba(%rip),%rdi
call   1050 <pfatal@plt>
jmp    12c5 <makesockets+0x125>
mov    $0x4096,%edi
call   1040 <htons@plt>
mov    %rax,0x10(%rsp)
lea    0x10(%rsp),%rsi
mov    %ebp,%edi
mov    $0x18,%edx
call   1090 <bind@plt>
test   %rax,%rax
je     12c5 <makesockets+0x125>
mov    0x2cf8(%rip),%rax
mov    (%rax),%rax
mov    0x2cf6(%rip),%rcx
cmp    (%rcx),%rax
je     124a <makesockets+0xaa>
lea    0xd71(%rip),%rdi
call   1050 <pfatal@plt>
jmp    124a <makesockets+0xaa>
movl   $0x18,0xc(%rsp)
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %ebp,%edi
call   10a0 <getsockname@plt>
test   %rax,%rax
je     12ef <makesockets+0x14f>
lea    0xd5b(%rip),%rdi
call   1050 <pfatal@plt>
mov    %ebp,%edi
mov    $0x80,%esi
call   1070 <listen@plt>
test   %rax,%rax
jns    130c <makesockets+0x16c>
lea    0xd4a(%rip),%rdi
call   1050 <pfatal@plt>
mov    0x10(%rsp),%rdi
call   1080 <ntohs@plt>
mov    %eax,(%r12)
lea    0xd37(%rip),%rdi
mov    %eax,%esi
call   10b0 <info@plt>
mov    0x0(%r13),%rdi
mov    0x2c95(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    134e <makesockets+0x1ae>
lea    0xd29(%rip),%rdi
call   1050 <pfatal@plt>
movl   $0x1,0x8(%rsp)
mov    (%r15),%esi
mov    (%r14),%edx
lea    0x8(%rsp),%rcx
mov    $0x4,%r8d
mov    %ebx,%edi
xor    %eax,%eax
call   1030 <setsockopt@plt>
test   %rax,%rax
jns    1383 <makesockets+0x1e3>
lea    0xc9a(%rip),%rdi
xor    %eax,%eax
call   1060 <pwarning@plt>
movl   $0x20000,0x8(%rsp)
mov    (%r15),%esi
mov    0x2c43(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rcx
mov    $0x4,%r8d
mov    %ebx,%edi
xor    %eax,%eax
call   1030 <setsockopt@plt>
test   %rax,%rax
jns    13c3 <makesockets+0x223>
lea    0xcd0(%rip),%rdi
mov    $0x20000,%esi
xor    %eax,%eax
call   1060 <pwarning@plt>
movl   $0x20000,0x8(%rsp)
mov    (%r15),%esi
mov    0x2be3(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rcx
mov    $0x4,%r8d
mov    %ebx,%edi
xor    %eax,%eax
call   1030 <setsockopt@plt>
test   %rax,%rax
jns    1403 <makesockets+0x263>
lea    0xcc1(%rip),%rdi
mov    $0x20000,%esi
xor    %eax,%eax
call   1060 <pwarning@plt>
mov    0x0(%r13),%rax
mov    %rax,0x20(%rsp)
mov    0x2bbd(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x18(%rsp)
mov    (%r12),%edi
call   1040 <htons@plt>
mov    %rax,0x10(%rsp)
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
mov    $0x18,%edx
call   1090 <bind@plt>
test   %rax,%rax
je     144b <makesockets+0x2ab>
lea    0xca3(%rip),%rdi
call   1050 <pfatal@plt>
movl   $0x18,0xc(%rsp)
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %ebx,%edi
call   10a0 <getsockname@plt>
test   %rax,%rax
je     1475 <makesockets+0x2d5>
lea    0xbd5(%rip),%rdi
call   1050 <pfatal@plt>
mov    0x10(%rsp),%rdi
call   1080 <ntohs@plt>
lea    0xc78(%rip),%rdi
mov    %eax,%esi
call   10b0 <info@plt>
mov    0x28(%rsp),%rax
mov    %ebp,(%rax)
mov    0x30(%rsp),%rax
mov    %ebx,(%rax)
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i8*, %struct.TYPE_2__, i8* }
%struct.TYPE_2__ = type { i8* }
%struct.sockaddr = type { i32 }
@AF_INET = global i8* null
@SOCK_STREAM = global i32 0
@.str = [22 x i8] c"opening stream socket\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.1 = [25 x i8] c"setsockopt(SO_REUSEADDR)\00"
@INADDR_ANY = global i8* null
@errno = global i64 0
@EADDRINUSE = global i64 0
@.str.2 = [22 x i8] c"binding stream socket\00"
@.str.3 = [12 x i8] c"getsockname\00"
@.str.4 = [7 x i8] c"listen\00"
@.str.5 = [26 x i8] c"listening on TCP port %d\0A\00"
@SOCK_DGRAM = global i32 0
@.str.6 = [21 x i8] c"opening dgram socket\00"
@SO_SNDBUF = global i32 0
@.str.7 = [49 x i8] c"Could not increase send socket buffer size to %d\00"
@SO_RCVBUF = global i32 0
@.str.8 = [49 x i8] c"Could not increase recv socket buffer size to %d\00"
@.str.9 = [21 x i8] c"binding dgram socket\00"
@.str.10 = [26 x i8] c"listening on UDP port %d\0A\00"
define i32 @makesockets(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca %struct.sockaddr_in
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%12 = load i8*, i8** @AF_INET
%13 = load i32, i32* @SOCK_STREAM
%14 = call i32 @socket(i8* %12, i32 %13, i32 0)
store i32 %14, i32* %11
%15 = load i32, i32* %11
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %3
%18 = call i32 @pfatal(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %3
store i32 1, i32* %9
%20 = load i32, i32* %11
%21 = load i32, i32* @SOL_SOCKET
%22 = load i32, i32* @SO_REUSEADDR
%23 = bitcast i32* %9 to i8*
%24 = call i64 (i32, i32, i32, ...) @setsockopt(i32 %20, i32 %21, i32 %22, i8* %23, i64 4)
%25 = icmp slt i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %19
%27 = call i32 (i8*, ...) @pwarning(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %28
28: ; preds = %26, %19
%29 = load i8*, i8** @AF_INET
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 2
store i8* %29, i8** %30
%31 = load i8*, i8** @INADDR_ANY
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
%33 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %32, i32 0, i32 0
store i8* %31, i8** %33
%34 = load i32*, i32** %4
%35 = load i32, i32* %34
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %52
37: ; preds = %28
%38 = call i8* @htons(i32 16534)
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
store i8* %38, i8** %39
%40 = load i32, i32* %11
%41 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%42 = call i64 @bind(i32 %40, %struct.sockaddr* %41, i32 24)
%43 = icmp ne i64 %42, 0
br i1 %43, label %45, label %44
44: ; preds = %37
br label %64
45: ; preds = %37
%46 = load i64, i64* @errno
%47 = load i64, i64* @EADDRINUSE
%48 = icmp ne i64 %46, %47
br i1 %48, label %49, label %51
49: ; preds = %45
%50 = call i32 @pfatal(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %51
51: ; preds = %49, %45
br label %52
52: ; preds = %51, %28
%53 = load i32*, i32** %4
%54 = load i32, i32* %53
%55 = call i8* @htons(i32 %54)
%56 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
store i8* %55, i8** %56
%57 = load i32, i32* %11
%58 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%59 = call i64 @bind(i32 %57, %struct.sockaddr* %58, i32 24)
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %52
%62 = call i32 @pfatal(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %63
63: ; preds = %61, %52
br label %64
64: ; preds = %63, %44
store i32 24, i32* %8
%65 = load i32, i32* %11
%66 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%67 = call i64 @getsockname(i32 %65, %struct.sockaddr* %66, i32* %8)
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %71
69: ; preds = %64
%70 = call i32 @pfatal(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %71
71: ; preds = %69, %64
%72 = load i32, i32* %11
%73 = call i64 @listen(i32 %72, i32 128)
%74 = icmp slt i64 %73, 0
br i1 %74, label %75, label %77
75: ; preds = %71
%76 = call i32 @pfatal(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %77
77: ; preds = %75, %71
%78 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
%79 = load i8*, i8** %78
%80 = call i32 @ntohs(i8* %79)
%81 = load i32*, i32** %4
store i32 %80, i32* %81
%82 = load i32*, i32** %4
%83 = load i32, i32* %82
%84 = call i32 @info(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i32 %83)
%85 = load i8*, i8** @AF_INET
%86 = load i32, i32* @SOCK_DGRAM
%87 = call i32 @socket(i8* %85, i32 %86, i32 0)
store i32 %87, i32* %10
%88 = load i32, i32* %10
%89 = icmp slt i32 %88, 0
br i1 %89, label %90, label %92
90: ; preds = %77
%91 = call i32 @pfatal(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
br label %92
92: ; preds = %90, %77
store i32 1, i32* %9
%93 = load i32, i32* %10
%94 = load i32, i32* @SOL_SOCKET
%95 = load i32, i32* @SO_REUSEADDR
%96 = bitcast i32* %9 to i8*
%97 = call i64 (i32, i32, i32, ...) @setsockopt(i32 %93, i32 %94, i32 %95, i8* %96, i64 4)
%98 = icmp slt i64 %97, 0
br i1 %98, label %99, label %101
99: ; preds = %92
%100 = call i32 (i8*, ...) @pwarning(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %101
101: ; preds = %99, %92
store i32 131072, i32* %9
%102 = load i32, i32* %10
%103 = load i32, i32* @SOL_SOCKET
%104 = load i32, i32* @SO_SNDBUF
%105 = call i64 (i32, i32, i32, ...) @setsockopt(i32 %102, i32 %103, i32 %104, i32* %9, i64 4)
%106 = icmp slt i64 %105, 0
br i1 %106, label %107, label %109
107: ; preds = %101
%108 = call i32 (i8*, ...) @pwarning(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.7, i64 0, i64 0), i32 131072)
br label %109
109: ; preds = %107, %101
store i32 131072, i32* %9
%110 = load i32, i32* %10
%111 = load i32, i32* @SOL_SOCKET
%112 = load i32, i32* @SO_RCVBUF
%113 = call i64 (i32, i32, i32, ...) @setsockopt(i32 %110, i32 %111, i32 %112, i32* %9, i64 4)
%114 = icmp slt i64 %113, 0
br i1 %114, label %115, label %117
115: ; preds = %109
%116 = call i32 (i8*, ...) @pwarning(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i64 0, i64 0), i32 131072)
br label %117
117: ; preds = %115, %109
%118 = load i8*, i8** @AF_INET
%119 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 2
store i8* %118, i8** %119
%120 = load i8*, i8** @INADDR_ANY
%121 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
%122 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %121, i32 0, i32 0
store i8* %120, i8** %122
%123 = load i32*, i32** %4
%124 = load i32, i32* %123
%125 = call i8* @htons(i32 %124)
%126 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
store i8* %125, i8** %126
%127 = load i32, i32* %10
%128 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%129 = call i64 @bind(i32 %127, %struct.sockaddr* %128, i32 24)
%130 = icmp ne i64 %129, 0
br i1 %130, label %131, label %133
131: ; preds = %117
%132 = call i32 @pfatal(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
br label %133
133: ; preds = %131, %117
store i32 24, i32* %8
%134 = load i32, i32* %10
%135 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%136 = call i64 @getsockname(i32 %134, %struct.sockaddr* %135, i32* %8)
%137 = icmp ne i64 %136, 0
br i1 %137, label %138, label %140
138: ; preds = %133
%139 = call i32 @pfatal(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %140
140: ; preds = %138, %133
%141 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
%142 = load i8*, i8** %141
%143 = call i32 @ntohs(i8* %142)
%144 = call i32 @info(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i32 %143)
%145 = load i32, i32* %11
%146 = load i32*, i32** %6
store i32 %145, i32* %146
%147 = load i32, i32* %10
%148 = load i32*, i32** %5
store i32 %147, i32* %148
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i8*, %struct.TYPE_2__, i8* }
%struct.TYPE_2__ = type { i8* }
%struct.sockaddr = type { i32 }
@AF_INET = global i8* null
@SOCK_STREAM = global i32 0
@.str = [22 x i8] c"opening stream socket\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.1 = [25 x i8] c"setsockopt(SO_REUSEADDR)\00"
@INADDR_ANY = global i8* null
@errno = global i64 0
@EADDRINUSE = global i64 0
@.str.2 = [22 x i8] c"binding stream socket\00"
@.str.3 = [12 x i8] c"getsockname\00"
@.str.4 = [7 x i8] c"listen\00"
@.str.5 = [26 x i8] c"listening on TCP port %d\0A\00"
@SOCK_DGRAM = global i32 0
@.str.6 = [21 x i8] c"opening dgram socket\00"
@SO_SNDBUF = global i32 0
@.str.7 = [49 x i8] c"Could not increase send socket buffer size to %d\00"
@SO_RCVBUF = global i32 0
@.str.8 = [49 x i8] c"Could not increase recv socket buffer size to %d\00"
@.str.9 = [21 x i8] c"binding dgram socket\00"
@.str.10 = [26 x i8] c"listening on UDP port %d\0A\00"
define i32 @makesockets(i32* nocapture %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = alloca i32
%7 = bitcast %struct.sockaddr_in* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = bitcast i32* %6 to i8*
%10 = load i8*, i8** @AF_INET
%11 = load i32, i32* @SOCK_STREAM
%12 = tail call i32 @socket(i8* %10, i32 %11, i32 0)
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %3
%15 = tail call i32 @pfatal(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %3
store i32 1, i32* %6
%17 = load i32, i32* @SOL_SOCKET
%18 = load i32, i32* @SO_REUSEADDR
%19 = call i64 (i32, i32, i32, ...) @setsockopt(i32 %12, i32 %17, i32 %18, i32* %6, i64 4)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = call i32 (i8*, ...) @pwarning(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %21, %16
%24 = load i8*, i8** @AF_INET
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i8* %24, i8** %25
%26 = load i8*, i8** @INADDR_ANY
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1, i32 0
store i8* %26, i8** %27
%28 = load i32, i32* %0
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %42
30: ; preds = %23
%31 = call i8* @htons(i32 16534)
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
store i8* %31, i8** %32
%33 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%34 = call i64 @bind(i32 %12, %struct.sockaddr* %33, i32 24)
%35 = icmp eq i64 %34, 0
br i1 %35, label %51, label %36
36: ; preds = %30
%37 = load i64, i64* @errno
%38 = load i64, i64* @EADDRINUSE
%39 = icmp eq i64 %37, %38
br i1 %39, label %42, label %40
40: ; preds = %36
%41 = call i32 @pfatal(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %42
42: ; preds = %23, %36, %40
%43 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%44 = load i32, i32* %0
%45 = call i8* @htons(i32 %44)
%46 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
store i8* %45, i8** %46
%47 = call i64 @bind(i32 %12, %struct.sockaddr* %43, i32 24)
%48 = icmp eq i64 %47, 0
br i1 %48, label %51, label %49
49: ; preds = %42
%50 = call i32 @pfatal(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %51
51: ; preds = %42, %49, %30
%52 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
store i32 24, i32* %5
%53 = call i64 @getsockname(i32 %12, %struct.sockaddr* %52, i32* %5)
%54 = icmp eq i64 %53, 0
br i1 %54, label %57, label %55
55: ; preds = %51
%56 = call i32 @pfatal(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %57
57: ; preds = %55, %51
%58 = call i64 @listen(i32 %12, i32 128)
%59 = icmp slt i64 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %57
%61 = call i32 @pfatal(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %62
62: ; preds = %60, %57
%63 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
%64 = load i8*, i8** %63
%65 = call i32 @ntohs(i8* %64)
store i32 %65, i32* %0
%66 = call i32 @info(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i32 %65)
%67 = load i8*, i8** @AF_INET
%68 = load i32, i32* @SOCK_DGRAM
%69 = call i32 @socket(i8* %67, i32 %68, i32 0)
%70 = icmp slt i32 %69, 0
br i1 %70, label %71, label %73
71: ; preds = %62
%72 = call i32 @pfatal(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
br label %73
73: ; preds = %71, %62
store i32 1, i32* %6
%74 = load i32, i32* @SOL_SOCKET
%75 = load i32, i32* @SO_REUSEADDR
%76 = call i64 (i32, i32, i32, ...) @setsockopt(i32 %69, i32 %74, i32 %75, i32* %6, i64 4)
%77 = icmp slt i64 %76, 0
br i1 %77, label %78, label %80
78: ; preds = %73
%79 = call i32 (i8*, ...) @pwarning(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %80
80: ; preds = %78, %73
store i32 131072, i32* %6
%81 = load i32, i32* @SOL_SOCKET
%82 = load i32, i32* @SO_SNDBUF
%83 = call i64 (i32, i32, i32, ...) @setsockopt(i32 %69, i32 %81, i32 %82, i32* %6, i64 4)
%84 = icmp slt i64 %83, 0
br i1 %84, label %85, label %87
85: ; preds = %80
%86 = call i32 (i8*, ...) @pwarning(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.7, i64 0, i64 0), i32 131072)
br label %87
87: ; preds = %85, %80
store i32 131072, i32* %6
%88 = load i32, i32* @SOL_SOCKET
%89 = load i32, i32* @SO_RCVBUF
%90 = call i64 (i32, i32, i32, ...) @setsockopt(i32 %69, i32 %88, i32 %89, i32* %6, i64 4)
%91 = icmp slt i64 %90, 0
br i1 %91, label %92, label %94
92: ; preds = %87
%93 = call i32 (i8*, ...) @pwarning(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i64 0, i64 0), i32 131072)
br label %94
94: ; preds = %92, %87
%95 = load i8*, i8** @AF_INET
store i8* %95, i8** %25
%96 = load i8*, i8** @INADDR_ANY
store i8* %96, i8** %27
%97 = load i32, i32* %0
%98 = call i8* @htons(i32 %97)
store i8* %98, i8** %63
%99 = call i64 @bind(i32 %69, %struct.sockaddr* %52, i32 24)
%100 = icmp eq i64 %99, 0
br i1 %100, label %103, label %101
101: ; preds = %94
%102 = call i32 @pfatal(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
br label %103
103: ; preds = %101, %94
store i32 24, i32* %5
%104 = call i64 @getsockname(i32 %69, %struct.sockaddr* %52, i32* %5)
%105 = icmp eq i64 %104, 0
br i1 %105, label %108, label %106
106: ; preds = %103
%107 = call i32 @pfatal(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %108
108: ; preds = %106, %103
%109 = load i8*, i8** %63
%110 = call i32 @ntohs(i8* %109)
%111 = call i32 @info(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i32 %110)
store i32 %12, i32* %2
store i32 %69, i32* %1
ret i32 0
}