#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__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct netent {
  int dummy;
};
struct linger {
  scalar_t__ l_onoff;
};
struct in_addr {
  int dummy;
};
struct hostent {
  int /*<<< orphan*/ h_addr;
};
typedef int /*<<< orphan*/ name;
typedef int /*<<< orphan*/ bufsize;

/* Variables and functions */
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ PF_INET;
int PF_UNSPEC;
int SOCK_DGRAM;
int SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_LINGER;
int /*<<< orphan*/ SO_RCVBUF;
int /*<<< orphan*/ SO_SNDBUF;
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
struct hostent *gethostbyname(char *);
scalar_t__ getsockname(int, struct sockaddr *, int *);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
scalar_t__ inet_makeaddr(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ inet_netof(int /*<<< orphan*/);
scalar_t__ listen(int, int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, char *, int);
int socket(int /*<<< orphan*/, int, int);
int dsm_server_open(int type, int *port, int broadcast,
                    struct sockaddr_in *gaddr, int bufsize) {
  int s;
  struct sockaddr_in from, name;
  struct netent *net;
  struct hostent *hp;
  int prot, len;
  int on = 1;
  struct linger l;
  struct sockaddr_in laddr, *saddr;
  saddr = (gaddr != NULL ? gaddr : &laddr);
  prot = (type == SOCK_DGRAM ? 0 : PF_UNSPEC);
  memset(saddr, 0, sizeof(struct sockaddr_in));
  saddr->sin_family = PF_INET;
  saddr->sin_addr.s_addr = htonl(INADDR_ANY);
  saddr->sin_port = htons(*port);
  if (broadcast && !(hp = gethostbyname("eiche.informatik.hu-berlin.de"))) {
    perror("gethostbyname error");
    return (0);
  }
  if (broadcast)
    memcpy((char *)&saddr->sin_addr,
           (char *)inet_makeaddr(inet_netof(hp->h_addr), INADDR_ANY),
           sizeof(struct in_addr));
  if ((s = socket(PF_INET, type, prot)) < 0) {
    perror("socket error");
    return (0);
  }
  l.l_onoff = 0;
  if (setsockopt(s, SOL_SOCKET, SO_LINGER, (char *)&l, sizeof(struct linger)) <
      0) {
    perror("setsockopt linger error");
    close(s);
    return (0);
  }
  if (bufsize != 0 && setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&bufsize,
                                 sizeof(bufsize)) < 0)
    perror("setsockopt RCVBUF error");
  if (bufsize != 0 && setsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *)&bufsize,
                                 sizeof(bufsize)) < 0)
    perror("setsockopt SNDBUF error");
  if (bind(s, (struct sockaddr *)saddr, sizeof(struct sockaddr))) {
    close(s);
    return (0);
  }
  if (*port == 0) {
    len = sizeof(name);
    if (getsockname(s, (struct sockaddr *)&name, &len) < 0) {
      perror("getsockname error");
      close(s);
      return (0);
    }
    *port = ntohs(name.sin_port);
  }
  if (type == SOCK_STREAM) {
    if (listen(s, 5)) {
      perror("listen error");
      close(s);
      return (0);
    }
  }
  return (s);
}


x86 assembly (clang, -O0):
<dsm_server_open>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
movl   $0x1,-0x64(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     122f <dsm_server_open+0x3f>
mov    -0x20(%rbp),%rax
mov    %rax,-0x90(%rbp)
jmp    123f <dsm_server_open+0x4f>
lea    -0x80(%rbp),%rax
mov    %rax,-0x90(%rbp)
jmp    123f <dsm_server_open+0x4f>
mov    -0x90(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2d69(%rip),%rcx
cmp    (%rcx),%eax
jne    126c <dsm_server_open+0x7c>
xor    %eax,%eax
mov    %eax,-0x94(%rbp)
jmp    127b <dsm_server_open+0x8b>
mov    0x2d6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x94(%rbp)
mov    -0x94(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x88(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x2d02(%rip),%rax
mov    (%rax),%ecx
mov    -0x88(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    0x2d17(%rip),%rax
mov    (%rax),%edi
call   1060 <htonl@plt>
mov    %eax,%ecx
mov    -0x88(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1040 <htons@plt>
mov    %eax,%ecx
mov    -0x88(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x0,-0x14(%rbp)
je     1316 <dsm_server_open+0x126>
lea    0xd15(%rip),%rdi
call   1090 <gethostbyname@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
jne    1316 <dsm_server_open+0x126>
lea    0xd19(%rip),%rdi
call   10f0 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    155b <dsm_server_open+0x36b>
cmpl   $0x0,-0x14(%rbp)
je     1361 <dsm_server_open+0x171>
mov    -0x88(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0xa0(%rbp)
mov    -0x58(%rbp),%rax
mov    (%rax),%edi
call   10c0 <inet_netof@plt>
mov    %eax,%edi
mov    0x2c82(%rip),%rax
mov    (%rax),%esi
call   1050 <inet_makeaddr@plt>
mov    -0xa0(%rbp),%rdi
mov    %rax,%rsi
mov    $0x4,%edx
call   10a0 <memcpy@plt>
mov    0x2c38(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%esi
mov    -0x5c(%rbp),%edx
call   1110 <socket@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jge    1399 <dsm_server_open+0x1a9>
lea    0xcaa(%rip),%rdi
call   10f0 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    155b <dsm_server_open+0x36b>
movq   $0x0,-0x70(%rbp)
mov    -0x28(%rbp),%edi
mov    0x2c3d(%rip),%rax
mov    (%rax),%esi
mov    0x2c1c(%rip),%rax
mov    (%rax),%edx
lea    -0x70(%rbp),%rcx
mov    $0x8,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    13ef <dsm_server_open+0x1ff>
lea    0xc69(%rip),%rdi
call   10f0 <perror@plt>
mov    -0x28(%rbp),%edi
call   1080 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    155b <dsm_server_open+0x36b>
cmpl   $0x0,-0x24(%rbp)
je     1433 <dsm_server_open+0x243>
mov    -0x28(%rbp),%edi
mov    0x2be5(%rip),%rax
mov    (%rax),%esi
mov    0x2ba4(%rip),%rax
mov    (%rax),%edx
lea    -0x24(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    1433 <dsm_server_open+0x243>
lea    0xc29(%rip),%rdi
call   10f0 <perror@plt>
cmpl   $0x0,-0x24(%rbp)
je     1477 <dsm_server_open+0x287>
mov    -0x28(%rbp),%edi
mov    0x2ba1(%rip),%rax
mov    (%rax),%esi
mov    0x2b88(%rip),%rax
mov    (%rax),%edx
lea    -0x24(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    1477 <dsm_server_open+0x287>
lea    0xbfd(%rip),%rdi
call   10f0 <perror@plt>
mov    -0x28(%rbp),%edi
mov    -0x88(%rbp),%rsi
mov    $0x4,%edx
call   10e0 <bind@plt>
cmp    $0x0,%rax
je     14a9 <dsm_server_open+0x2b9>
mov    -0x28(%rbp),%edi
call   1080 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    155b <dsm_server_open+0x36b>
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1507 <dsm_server_open+0x317>
movl   $0xc,-0x60(%rbp)
mov    -0x28(%rbp),%edi
lea    -0x48(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   1100 <getsockname@plt>
cmp    $0x0,%rax
jge    14f7 <dsm_server_open+0x307>
lea    0xba9(%rip),%rdi
call   10f0 <perror@plt>
mov    -0x28(%rbp),%edi
call   1080 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    155b <dsm_server_open+0x36b>
mov    -0x48(%rbp),%edi
call   10d0 <ntohs@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%eax
mov    0x2a97(%rip),%rcx
cmp    (%rcx),%eax
jne    1555 <dsm_server_open+0x365>
mov    -0x28(%rbp),%edi
mov    $0x5,%esi
call   10b0 <listen@plt>
cmp    $0x0,%rax
je     1550 <dsm_server_open+0x360>
lea    0xb62(%rip),%rdi
call   10f0 <perror@plt>
mov    -0x28(%rbp),%edi
call   1080 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    155b <dsm_server_open+0x36b>
jmp    1555 <dsm_server_open+0x365>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dsm_server_open>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %edx,%r14d
mov    %rsi,%r12
mov    %r8d,0xc(%rsp)
mov    %r8d,0x8(%rsp)
mov    0x2dab(%rip),%rax
xor    %r13d,%r13d
mov    %edi,0x10(%rsp)
cmp    %edi,(%rax)
je     122a <dsm_server_open+0x3a>
mov    0x2db9(%rip),%rax
mov    (%rax),%r13d
lea    0x4(%rcx),%rax
test   %rcx,%rcx
lea    0x28(%rsp),%rbx
cmovne %rcx,%rbx
lea    0x2c(%rsp),%rbp
cmovne %rax,%rbp
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x2d47(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rbx)
mov    0x2d63(%rip),%r15
mov    (%r15),%edi
call   1060 <htonl@plt>
mov    %eax,0x4(%rbx)
mov    %r12,0x18(%rsp)
mov    (%r12),%edi
call   1040 <htons@plt>
mov    %eax,(%rbx)
test   %r14d,%r14d
je     12bb <dsm_server_open+0xcb>
lea    0xd74(%rip),%rdi
call   1090 <gethostbyname@plt>
test   %rax,%rax
je     141b <dsm_server_open+0x22b>
mov    (%rax),%edi
call   10c0 <inet_netof@plt>
mov    (%r15),%esi
mov    %eax,%edi
call   1050 <inet_makeaddr@plt>
mov    %rbp,%rdi
mov    %rax,%rsi
mov    $0x4,%edx
call   10a0 <memcpy@plt>
mov    0x2cde(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rsp),%r15d
mov    %r15d,%esi
mov    %r13d,%edx
call   1110 <socket@plt>
test   %eax,%eax
js     13fc <dsm_server_open+0x20c>
mov    %eax,%ebp
movq   $0x0,0x20(%rsp)
mov    0x2cfa(%rip),%r14
mov    (%r14),%esi
mov    0x2cd8(%rip),%rax
mov    (%rax),%edx
lea    0x20(%rsp),%rcx
mov    %ebp,%edi
mov    $0x8,%r8d
call   1030 <setsockopt@plt>
test   %rax,%rax
js     140a <dsm_server_open+0x21a>
cmpl   $0x0,0xc(%rsp)
je     1371 <dsm_server_open+0x181>
mov    (%r14),%esi
mov    0x2c8a(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
test   %rax,%rax
js     142c <dsm_server_open+0x23c>
cmpl   $0x0,0x8(%rsp)
je     1371 <dsm_server_open+0x181>
mov    (%r14),%esi
mov    0x2c84(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
test   %rax,%rax
js     1448 <dsm_server_open+0x258>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x4,%edx
call   10e0 <bind@plt>
test   %rax,%rax
je     139f <dsm_server_open+0x1af>
mov    %ebp,%edi
call   1080 <close@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x18(%rsp),%rbx
cmpl   $0x0,(%rbx)
jne    13d6 <dsm_server_open+0x1e6>
movl   $0xc,0x14(%rsp)
lea    0x38(%rsp),%rsi
lea    0x14(%rsp),%rdx
mov    %ebp,%edi
call   1100 <getsockname@plt>
test   %rax,%rax
js     1459 <dsm_server_open+0x269>
mov    0x38(%rsp),%edi
call   10d0 <ntohs@plt>
mov    %eax,(%rbx)
mov    0x2bcb(%rip),%rax
cmp    %r15d,(%rax)
jne    138e <dsm_server_open+0x19e>
mov    %ebp,%edi
mov    $0x5,%esi
call   10b0 <listen@plt>
test   %rax,%rax
je     138e <dsm_server_open+0x19e>
lea    0xc9f(%rip),%rdi
jmp    1411 <dsm_server_open+0x221>
lea    0xc2f(%rip),%rdi
call   10f0 <perror@plt>
jmp    138c <dsm_server_open+0x19c>
lea    0xc2e(%rip),%rdi
call   10f0 <perror@plt>
jmp    1385 <dsm_server_open+0x195>
lea    0xbfc(%rip),%rdi
call   10f0 <perror@plt>
jmp    138c <dsm_server_open+0x19c>
lea    0xc24(%rip),%rdi
call   10f0 <perror@plt>
cmpl   $0x0,0x8(%rsp)
jne    134a <dsm_server_open+0x15a>
jmp    1371 <dsm_server_open+0x181>
lea    0xc20(%rip),%rdi
call   10f0 <perror@plt>
jmp    1371 <dsm_server_open+0x181>
lea    0xc27(%rip),%rdi
jmp    1411 <dsm_server_open+0x221>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.netent = type { i32 }
%struct.hostent = type { i32 }
%struct.linger = type { i64 }
%struct.sockaddr = type { i32 }
@SOCK_DGRAM = global i32 0
@PF_UNSPEC = global i32 0
@PF_INET = global i32 0
@INADDR_ANY = global i32 0
@.str = [30 x i8] c"eiche.informatik.hu-berlin.de\00"
@.str.1 = [20 x i8] c"gethostbyname error\00"
@.str.2 = [13 x i8] c"socket error\00"
@SOL_SOCKET = global i32 0
@SO_LINGER = global i32 0
@.str.3 = [24 x i8] c"setsockopt linger error\00"
@SO_RCVBUF = global i32 0
@.str.4 = [24 x i8] c"setsockopt RCVBUF error\00"
@SO_SNDBUF = global i32 0
@.str.5 = [24 x i8] c"setsockopt SNDBUF error\00"
@.str.6 = [18 x i8] c"getsockname error\00"
@SOCK_STREAM = global i32 0
@.str.7 = [13 x i8] c"listen error\00"
define i32 @dsm_server_open(i32 %0, i32* %1, i32 %2, %struct.sockaddr_in* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca %struct.sockaddr_in*
%11 = alloca i32
%12 = alloca i32
%13 = alloca %struct.sockaddr_in
%14 = alloca %struct.sockaddr_in
%15 = alloca %struct.netent*
%16 = alloca %struct.hostent*
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca %struct.linger
%21 = alloca %struct.sockaddr_in
%22 = alloca %struct.sockaddr_in*
store i32 %0, i32* %7
store i32* %1, i32** %8
store i32 %2, i32* %9
store %struct.sockaddr_in* %3, %struct.sockaddr_in** %10
store i32 %4, i32* %11
store i32 1, i32* %19
%23 = load %struct.sockaddr_in*, %struct.sockaddr_in** %10
%24 = icmp ne %struct.sockaddr_in* %23, null
br i1 %24, label %25, label %27
25: ; preds = %5
%26 = load %struct.sockaddr_in*, %struct.sockaddr_in** %10
br label %28
27: ; preds = %5
br label %28
28: ; preds = %27, %25
%29 = phi %struct.sockaddr_in* [ %26, %25 ], [ %21, %27 ]
store %struct.sockaddr_in* %29, %struct.sockaddr_in** %22
%30 = load i32, i32* %7
%31 = load i32, i32* @SOCK_DGRAM
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %34
33: ; preds = %28
br label %36
34: ; preds = %28
%35 = load i32, i32* @PF_UNSPEC
br label %36
36: ; preds = %34, %33
%37 = phi i32 [ 0, %33 ], [ %35, %34 ]
store i32 %37, i32* %17
%38 = load %struct.sockaddr_in*, %struct.sockaddr_in** %22
%39 = call i32 @memset(%struct.sockaddr_in* %38, i32 0, i32 12)
%40 = load i32, i32* @PF_INET
%41 = load %struct.sockaddr_in*, %struct.sockaddr_in** %22
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %41, i32 0, i32 2
store i32 %40, i32* %42
%43 = load i32, i32* @INADDR_ANY
%44 = call i32 @htonl(i32 %43)
%45 = load %struct.sockaddr_in*, %struct.sockaddr_in** %22
%46 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %45, i32 0, i32 1
%47 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %46, i32 0, i32 0
store i32 %44, i32* %47
%48 = load i32*, i32** %8
%49 = load i32, i32* %48
%50 = call i32 @htons(i32 %49)
%51 = load %struct.sockaddr_in*, %struct.sockaddr_in** %22
%52 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %51, i32 0, i32 0
store i32 %50, i32* %52
%53 = load i32, i32* %9
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %60
55: ; preds = %36
%56 = call %struct.hostent* @gethostbyname(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
store %struct.hostent* %56, %struct.hostent** %16
%57 = icmp ne %struct.hostent* %56, null
br i1 %57, label %60, label %58
58: ; preds = %55
%59 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %6
br label %161
60: ; preds = %55, %36
%61 = load i32, i32* %9
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %75
63: ; preds = %60
%64 = load %struct.sockaddr_in*, %struct.sockaddr_in** %22
%65 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %64, i32 0, i32 1
%66 = bitcast %struct.TYPE_2__* %65 to i8*
%67 = load %struct.hostent*, %struct.hostent** %16
%68 = getelementptr inbounds %struct.hostent, %struct.hostent* %67, i32 0, i32 0
%69 = load i32, i32* %68
%70 = call i32 @inet_netof(i32 %69)
%71 = load i32, i32* @INADDR_ANY
%72 = call i64 @inet_makeaddr(i32 %70, i32 %71)
%73 = inttoptr i64 %72 to i8*
%74 = call i32 @memcpy(i8* %66, i8* %73, i32 4)
br label %75
75: ; preds = %63, %60
%76 = load i32, i32* @PF_INET
%77 = load i32, i32* %7
%78 = load i32, i32* %17
%79 = call i32 @socket(i32 %76, i32 %77, i32 %78)
store i32 %79, i32* %12
%80 = icmp slt i32 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %75
%82 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %6
br label %161
83: ; preds = %75
%84 = getelementptr inbounds %struct.linger, %struct.linger* %20, i32 0, i32 0
store i64 0, i64* %84
%85 = load i32, i32* %12
%86 = load i32, i32* @SOL_SOCKET
%87 = load i32, i32* @SO_LINGER
%88 = bitcast %struct.linger* %20 to i8*
%89 = call i64 @setsockopt(i32 %85, i32 %86, i32 %87, i8* %88, i32 8)
%90 = icmp slt i64 %89, 0
br i1 %90, label %91, label %95
91: ; preds = %83
%92 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%93 = load i32, i32* %12
%94 = call i32 @close(i32 %93)
store i32 0, i32* %6
br label %161
95: ; preds = %83
%96 = load i32, i32* %11
%97 = icmp ne i32 %96, 0
br i1 %97, label %98, label %107
98: ; preds = %95
%99 = load i32, i32* %12
%100 = load i32, i32* @SOL_SOCKET
%101 = load i32, i32* @SO_RCVBUF
%102 = bitcast i32* %11 to i8*
%103 = call i64 @setsockopt(i32 %99, i32 %100, i32 %101, i8* %102, i32 4)
%104 = icmp slt i64 %103, 0
br i1 %104, label %105, label %107
105: ; preds = %98
%106 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %107
107: ; preds = %105, %98, %95
%108 = load i32, i32* %11
%109 = icmp ne i32 %108, 0
br i1 %109, label %110, label %119
110: ; preds = %107
%111 = load i32, i32* %12
%112 = load i32, i32* @SOL_SOCKET
%113 = load i32, i32* @SO_SNDBUF
%114 = bitcast i32* %11 to i8*
%115 = call i64 @setsockopt(i32 %111, i32 %112, i32 %113, i8* %114, i32 4)
%116 = icmp slt i64 %115, 0
br i1 %116, label %117, label %119
117: ; preds = %110
%118 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
br label %119
119: ; preds = %117, %110, %107
%120 = load i32, i32* %12
%121 = load %struct.sockaddr_in*, %struct.sockaddr_in** %22
%122 = bitcast %struct.sockaddr_in* %121 to %struct.sockaddr*
%123 = call i64 @bind(i32 %120, %struct.sockaddr* %122, i32 4)
%124 = icmp ne i64 %123, 0
br i1 %124, label %125, label %128
125: ; preds = %119
%126 = load i32, i32* %12
%127 = call i32 @close(i32 %126)
store i32 0, i32* %6
br label %161
128: ; preds = %119
%129 = load i32*, i32** %8
%130 = load i32, i32* %129
%131 = icmp eq i32 %130, 0
br i1 %131, label %132, label %146
132: ; preds = %128
store i32 12, i32* %18
%133 = load i32, i32* %12
%134 = bitcast %struct.sockaddr_in* %14 to %struct.sockaddr*
%135 = call i64 @getsockname(i32 %133, %struct.sockaddr* %134, i32* %18)
%136 = icmp slt i64 %135, 0
br i1 %136, label %137, label %141
137: ; preds = %132
%138 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%139 = load i32, i32* %12
%140 = call i32 @close(i32 %139)
store i32 0, i32* %6
br label %161
141: ; preds = %132
%142 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 0
%143 = load i32, i32* %142
%144 = call i32 @ntohs(i32 %143)
%145 = load i32*, i32** %8
store i32 %144, i32* %145
br label %146
146: ; preds = %141, %128
%147 = load i32, i32* %7
%148 = load i32, i32* @SOCK_STREAM
%149 = icmp eq i32 %147, %148
br i1 %149, label %150, label %159
150: ; preds = %146
%151 = load i32, i32* %12
%152 = call i64 @listen(i32 %151, i32 5)
%153 = icmp ne i64 %152, 0
br i1 %153, label %154, label %158
154: ; preds = %150
%155 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%156 = load i32, i32* %12
%157 = call i32 @close(i32 %156)
store i32 0, i32* %6
br label %161
158: ; preds = %150
br label %159
159: ; preds = %158, %146
%160 = load i32, i32* %12
store i32 %160, i32* %6
br label %161
161: ; preds = %159, %154, %137, %125, %91, %81, %58
%162 = load i32, i32* %6
ret i32 %162
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.linger = type { i64 }
%struct.netent = type { i32 }
%struct.hostent = type { i32 }
%struct.sockaddr = type { i32 }
@SOCK_DGRAM = global i32 0
@PF_UNSPEC = global i32 0
@PF_INET = global i32 0
@INADDR_ANY = global i32 0
@.str = [30 x i8] c"eiche.informatik.hu-berlin.de\00"
@.str.1 = [20 x i8] c"gethostbyname error\00"
@.str.2 = [13 x i8] c"socket error\00"
@SOL_SOCKET = global i32 0
@SO_LINGER = global i32 0
@.str.3 = [24 x i8] c"setsockopt linger error\00"
@SO_RCVBUF = global i32 0
@.str.4 = [24 x i8] c"setsockopt RCVBUF error\00"
@SO_SNDBUF = global i32 0
@.str.5 = [24 x i8] c"setsockopt SNDBUF error\00"
@.str.6 = [18 x i8] c"getsockname error\00"
@SOCK_STREAM = global i32 0
@.str.7 = [13 x i8] c"listen error\00"
define i32 @dsm_server_open(i32 %0, i32* nocapture %1, i32 %2, %struct.sockaddr_in* %3, i32 %4) {
%6 = alloca i32
%7 = alloca %struct.sockaddr_in
%8 = alloca i32
%9 = alloca %struct.linger
%10 = alloca %struct.sockaddr_in
store i32 %4, i32* %6
%11 = bitcast %struct.sockaddr_in* %7 to i8*
%12 = bitcast i32* %8 to i8*
%13 = bitcast %struct.linger* %9 to i8*
%14 = bitcast %struct.sockaddr_in* %10 to i8*
%15 = icmp eq %struct.sockaddr_in* %3, null
%16 = select i1 %15, %struct.sockaddr_in* %10, %struct.sockaddr_in* %3
%17 = load i32, i32* @SOCK_DGRAM
%18 = icmp eq i32 %17, %0
%19 = load i32, i32* @PF_UNSPEC
%20 = select i1 %18, i32 0, i32 %19
%21 = call i32 @memset(%struct.sockaddr_in* %16, i32 0, i32 12)
%22 = load i32, i32* @PF_INET
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i64 0, i32 2
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
%25 = select i1 %15, i32* %23, i32* %24
store i32 %22, i32* %25
%26 = load i32, i32* @INADDR_ANY
%27 = call i32 @htonl(i32 %26)
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i64 0, i32 1
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
%30 = select i1 %15, %struct.TYPE_2__* %28, %struct.TYPE_2__* %29
%31 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %28, i64 0, i32 0
%32 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %29, i64 0, i32 0
%33 = select i1 %15, i32* %31, i32* %32
store i32 %27, i32* %33
%34 = load i32, i32* %1
%35 = call i32 @htons(i32 %34)
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i64 0, i32 0
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
%38 = select i1 %15, i32* %36, i32* %37
store i32 %35, i32* %38
%39 = icmp eq i32 %2, 0
br i1 %39, label %54, label %40
40: ; preds = %5
%41 = call %struct.hostent* @gethostbyname(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%42 = icmp eq %struct.hostent* %41, null
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %118
45: ; preds = %40
%46 = bitcast %struct.TYPE_2__* %30 to i8*
%47 = getelementptr inbounds %struct.hostent, %struct.hostent* %41, i64 0, i32 0
%48 = load i32, i32* %47
%49 = call i32 @inet_netof(i32 %48)
%50 = load i32, i32* @INADDR_ANY
%51 = call i64 @inet_makeaddr(i32 %49, i32 %50)
%52 = inttoptr i64 %51 to i8*
%53 = call i32 @memcpy(i8* %46, i8* %52, i32 4)
br label %54
54: ; preds = %5, %45
%55 = load i32, i32* @PF_INET
%56 = call i32 @socket(i32 %55, i32 %0, i32 %20)
%57 = icmp slt i32 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %54
%59 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %118
60: ; preds = %54
%61 = getelementptr inbounds %struct.linger, %struct.linger* %9, i64 0, i32 0
store i64 0, i64* %61
%62 = load i32, i32* @SOL_SOCKET
%63 = load i32, i32* @SO_LINGER
%64 = call i64 @setsockopt(i32 %56, i32 %62, i32 %63, i8* %13, i32 8)
%65 = icmp slt i64 %64, 0
br i1 %65, label %66, label %69
66: ; preds = %60
%67 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%68 = call i32 @close(i32 %56)
br label %118
69: ; preds = %60
%70 = icmp eq i32 %4, 0
br i1 %70, label %89, label %71
71: ; preds = %69
%72 = load i32, i32* @SOL_SOCKET
%73 = load i32, i32* @SO_RCVBUF
%74 = bitcast i32* %6 to i8*
%75 = call i64 @setsockopt(i32 %56, i32 %72, i32 %73, i8* %74, i32 4)
%76 = icmp slt i64 %75, 0
br i1 %76, label %77, label %79
77: ; preds = %71
%78 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %79
79: ; preds = %77, %71
%80 = load i32, i32* %6
%81 = icmp eq i32 %80, 0
br i1 %81, label %89, label %82
82: ; preds = %79
%83 = load i32, i32* @SOL_SOCKET
%84 = load i32, i32* @SO_SNDBUF
%85 = call i64 @setsockopt(i32 %56, i32 %83, i32 %84, i8* %74, i32 4)
%86 = icmp slt i64 %85, 0
br i1 %86, label %87, label %89
87: ; preds = %82
%88 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
br label %89
89: ; preds = %69, %87, %82, %79
%90 = bitcast %struct.sockaddr_in* %16 to %struct.sockaddr*
%91 = call i64 @bind(i32 %56, %struct.sockaddr* %90, i32 4)
%92 = icmp eq i64 %91, 0
br i1 %92, label %95, label %93
93: ; preds = %89
%94 = call i32 @close(i32 %56)
br label %118
95: ; preds = %89
%96 = load i32, i32* %1
%97 = icmp eq i32 %96, 0
br i1 %97, label %98, label %109
98: ; preds = %95
store i32 12, i32* %8
%99 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%100 = call i64 @getsockname(i32 %56, %struct.sockaddr* %99, i32* %8)
%101 = icmp slt i64 %100, 0
br i1 %101, label %102, label %105
102: ; preds = %98
%103 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%104 = call i32 @close(i32 %56)
br label %118
105: ; preds = %98
%106 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 0
%107 = load i32, i32* %106
%108 = call i32 @ntohs(i32 %107)
store i32 %108, i32* %1
br label %109
109: ; preds = %105, %95
%110 = load i32, i32* @SOCK_STREAM
%111 = icmp eq i32 %110, %0
br i1 %111, label %112, label %118
112: ; preds = %109
%113 = call i64 @listen(i32 %56, i32 5)
%114 = icmp eq i64 %113, 0
br i1 %114, label %118, label %115
115: ; preds = %112
%116 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%117 = call i32 @close(i32 %56)
br label %118
118: ; preds = %109, %112, %115, %102, %93, %66, %58, %43
%119 = phi i32 [ 0, %58 ], [ 0, %66 ], [ 0, %93 ], [ 0, %102 ], [ 0, %115 ], [ 0, %43 ], [ %56, %112 ], [ %56, %109 ]
ret i32 %119
}