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

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ F_SETFL;
int /*<<< orphan*/ O_NONBLOCK;
int /*<<< orphan*/ SOCK_STREAM;
int bind(int, struct sockaddr *, int);
int fcntl(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
char *inet_ntoa(TYPE_1__);
int listen(int, int);
int /*<<< orphan*/ printf(char *, char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int create_socket(char *address, int port) {
  int sock, errore;
  struct sockaddr_in temp_sock;
  sock = socket(AF_INET, SOCK_STREAM, 0);
  temp_sock.sin_family = AF_INET;
  temp_sock.sin_addr.s_addr = inet_addr(address);
  temp_sock.sin_port = htons(port);
  printf("server address %s\n", inet_ntoa(temp_sock.sin_addr));
  errore = fcntl(sock, F_SETFL, O_NONBLOCK);
  errore = bind(sock, (struct sockaddr *)&temp_sock, sizeof(temp_sock));
  errore = listen(sock, 5);
  return sock;
}


x86 assembly (clang, -O0):
<create_socket>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
mov    0x2e29(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10a0 <socket@plt>
mov    %eax,-0x10(%rbp)
mov    0x2e36(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <inet_addr@plt>
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xe20(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%edi
mov    0x2de1(%rip),%rax
mov    (%rax),%esi
mov    0x2de8(%rip),%rax
mov    (%rax),%edx
call   1030 <fcntl@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0xc,%edx
call   1090 <bind@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
mov    $0x5,%esi
call   1080 <listen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_socket>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r14d
mov    %rdi,%rbp
mov    0x2e51(%rip),%r15
mov    (%r15),%edi
mov    0x2e27(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10a0 <socket@plt>
mov    %eax,%ebx
mov    (%r15),%eax
mov    %eax,0x10(%rsp)
mov    %rbp,%rdi
call   1070 <inet_addr@plt>
mov    %eax,%ebp
mov    %eax,0x8(%rsp)
mov    %r14d,%edi
call   1050 <htons@plt>
mov    %eax,0xc(%rsp)
mov    %ebp,%edi
call   1040 <inet_ntoa@plt>
lea    0xe25(%rip),%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
mov    0x2de6(%rip),%rax
mov    (%rax),%esi
mov    0x2ded(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
call   1030 <fcntl@plt>
lea    0x8(%rsp),%rsi
mov    %ebx,%edi
mov    $0xc,%edx
call   1090 <bind@plt>
mov    %ebx,%edi
mov    $0x5,%esi
call   1080 <listen@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
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 = [19 x i8] c"server address %s\0A\00"
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
define i32 @create_socket(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.sockaddr_in
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = load i32, i32* @AF_INET
%9 = load i32, i32* @SOCK_STREAM
%10 = call i32 @socket(i32 %8, i32 %9, i32 0)
store i32 %10, i32* %5
%11 = load i32, i32* @AF_INET
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 2
store i32 %11, i32* %12
%13 = load i8*, i8** %3
%14 = call i32 @inet_addr(i8* %13)
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
%16 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %15, i32 0, i32 0
store i32 %14, i32* %16
%17 = load i32, i32* %4
%18 = call i32 @htons(i32 %17)
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
store i32 %18, i32* %19
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
%21 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %20, i32 0, i32 0
%22 = load i32, i32* %21
%23 = call i8* @inet_ntoa(i32 %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = load i32, i32* %5
%26 = load i32, i32* @F_SETFL
%27 = load i32, i32* @O_NONBLOCK
%28 = call i32 @fcntl(i32 %25, i32 %26, i32 %27)
store i32 %28, i32* %6
%29 = load i32, i32* %5
%30 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%31 = call i32 @bind(i32 %29, %struct.sockaddr* %30, i32 12)
store i32 %31, i32* %6
%32 = load i32, i32* %5
%33 = call i32 @listen(i32 %32, i32 5)
store i32 %33, i32* %6
%34 = load i32, i32* %5
ret i32 %34
}

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 = [19 x i8] c"server address %s\0A\00"
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
define i32 @create_socket(i8* %0, i32 %1) {
%3 = alloca %struct.sockaddr_in
%4 = bitcast %struct.sockaddr_in* %3 to i8*
%5 = load i32, i32* @AF_INET
%6 = load i32, i32* @SOCK_STREAM
%7 = tail call i32 @socket(i32 %5, i32 %6, i32 0)
%8 = load i32, i32* @AF_INET
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %8, i32* %9
%10 = tail call i32 @inet_addr(i8* %0)
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0, i32 0
store i32 %10, i32* %11
%12 = tail call i32 @htons(i32 %1)
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i32 %12, i32* %13
%14 = tail call i8* @inet_ntoa(i32 %10)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @F_SETFL
%17 = load i32, i32* @O_NONBLOCK
%18 = tail call i32 @fcntl(i32 %7, i32 %16, i32 %17)
%19 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%20 = call i32 @bind(i32 %7, %struct.sockaddr* %19, i32 12)
%21 = call i32 @listen(i32 %7, i32 5)
ret i32 %7
}