#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 s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ serveraddr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ error(char *);
int htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(unsigned short);
int listen(int, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
void intialize_node(int sockfd, struct sockaddr_in serveraddr) {
  sockfd = socket(AF_INET, SOCK_STREAM, 0);
  if (sockfd < 0)
    error("ERROR OPENING SOCKET");
  memset(&serveraddr, 0, sizeof(serveraddr));
  serveraddr.sin_family = AF_INET;
  serveraddr.sin_addr.s_addr = htonl(INADDR_ANY);
  serveraddr.sin_port = htons((unsigned short)80);
  int res = bind(sockfd, (struct sockaddr *)&serveraddr, sizeof(serveraddr));
  if (res < 0)
    error("SOCKET BINDING ERROR");
  res = listen(sockfd, 100);
  if (res < 0)
    error("LISTENING ERROR");
  printf("Server running on address %d:%d\n", serveraddr.sin_addr.s_addr, 80);
}


x86 assembly (clang, -O0):
<intialize_node>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rsi,-0x20(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    %edi,-0x24(%rbp)
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
mov    0x2e20(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10a0 <socket@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    11d2 <intialize_node+0x52>
lea    0xe33(%rip),%rdi
call   1090 <error@plt>
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    0x2dff(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
call   1050 <htonl@plt>
mov    %eax,-0x10(%rbp)
mov    $0x50,%edi
call   1030 <htons@plt>
mov    %eax,-0xc(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x10(%rbp),%rsi
mov    $0xc,%edx
call   1080 <bind@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    1236 <intialize_node+0xb6>
lea    0xde4(%rip),%rdi
call   1090 <error@plt>
mov    -0x24(%rbp),%edi
mov    $0x64,%esi
call   1070 <listen@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    125c <intialize_node+0xdc>
lea    0xdd3(%rip),%rdi
call   1090 <error@plt>
mov    -0x10(%rbp),%esi
lea    0xdd4(%rip),%rdi
mov    $0x50,%edx
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<intialize_node>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,(%rsp)
mov    %edx,0x8(%rsp)
mov    0x2e50(%rip),%r15
mov    (%r15),%edi
mov    0x2e2e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10a0 <socket@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    11bd <intialize_node+0x3d>
lea    0xe48(%rip),%rdi
call   1090 <error@plt>
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    (%r15),%eax
mov    %eax,0x8(%rsp)
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
call   1050 <htonl@plt>
mov    %eax,(%rsp)
mov    $0x50,%edi
call   1030 <htons@plt>
mov    %eax,0x4(%rsp)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   1080 <bind@plt>
test   %eax,%eax
jns    1214 <intialize_node+0x94>
lea    0xe06(%rip),%rdi
call   1090 <error@plt>
mov    %ebx,%edi
mov    $0x64,%esi
call   1070 <listen@plt>
test   %eax,%eax
jns    1230 <intialize_node+0xb0>
lea    0xdff(%rip),%rdi
call   1090 <error@plt>
mov    (%rsp),%esi
lea    0xe00(%rip),%rdi
mov    $0x50,%edx
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [21 x i8] c"ERROR OPENING SOCKET\00"
@INADDR_ANY = global i32 0
@.str.1 = [21 x i8] c"SOCKET BINDING ERROR\00"
@.str.2 = [16 x i8] c"LISTENING ERROR\00"
@.str.3 = [33 x i8] c"Server running on address %d:%d\0A\00"
define void @intialize_node(i32 %0, i64 %1, i32 %2) {
%4 = alloca %struct.sockaddr_in
%5 = alloca { i64, i32 }
%6 = alloca i32
%7 = alloca i32
%8 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %5, i32 0, i32 0
store i64 %1, i64* %8
%9 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %5, i32 0, i32 1
store i32 %2, i32* %9
%10 = bitcast %struct.sockaddr_in* %4 to i8*
%11 = bitcast { i64, i32 }* %5 to i8*
store i32 %0, i32* %6
%12 = load i32, i32* @AF_INET
%13 = load i32, i32* @SOCK_STREAM
%14 = call i32 @socket(i32 %12, i32 %13, i32 0)
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %3
%18 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %3
%20 = call i32 @memset(%struct.sockaddr_in* %4, i32 0, i32 12)
%21 = load i32, i32* @AF_INET
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 2
store i32 %21, i32* %22
%23 = load i32, i32* @INADDR_ANY
%24 = call i32 @htonl(i32 %23)
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 0
%26 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %25, i32 0, i32 0
store i32 %24, i32* %26
%27 = call i32 @htons(i16 zeroext 80)
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 1
store i32 %27, i32* %28
%29 = load i32, i32* %6
%30 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%31 = call i32 @bind(i32 %29, %struct.sockaddr* %30, i32 12)
store i32 %31, i32* %7
%32 = load i32, i32* %7
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %19
%35 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %36
36: ; preds = %34, %19
%37 = load i32, i32* %6
%38 = call i32 @listen(i32 %37, i32 100)
store i32 %38, i32* %7
%39 = load i32, i32* %7
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %36
%42 = call i32 @error(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %43
43: ; preds = %41, %36
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 0
%45 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %44, i32 0, i32 0
%46 = load i32, i32* %45
%47 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %46, i32 80)
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [21 x i8] c"ERROR OPENING SOCKET\00"
@INADDR_ANY = global i32 0
@.str.1 = [21 x i8] c"SOCKET BINDING ERROR\00"
@.str.2 = [16 x i8] c"LISTENING ERROR\00"
@.str.3 = [33 x i8] c"Server running on address %d:%d\0A\00"
define void @intialize_node(i32 %0, i64 %1, i32 %2) {
%4 = alloca %struct.sockaddr_in
%5 = bitcast %struct.sockaddr_in* %4 to i64*
store i64 %1, i64* %5
%6 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %2, i32* %6
%7 = load i32, i32* @AF_INET
%8 = load i32, i32* @SOCK_STREAM
%9 = tail call i32 @socket(i32 %7, i32 %8, i32 0)
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = tail call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %3
%14 = call i32 @memset(%struct.sockaddr_in* %4, i32 0, i32 12)
%15 = load i32, i32* @AF_INET
store i32 %15, i32* %6
%16 = load i32, i32* @INADDR_ANY
%17 = call i32 @htonl(i32 %16)
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0, i32 0
store i32 %17, i32* %18
%19 = call i32 @htons(i16 zeroext 80)
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i32 %19, i32* %20
%21 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%22 = call i32 @bind(i32 %9, %struct.sockaddr* %21, i32 12)
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %13
%25 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %24, %13
%27 = call i32 @listen(i32 %9, i32 100)
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 @error(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %31
31: ; preds = %29, %26
%32 = load i32, i32* %18
%33 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %32, i32 80)
ret void
}