#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;
};
typedef int /*<<< orphan*/ serv_addr;
typedef int /*<<< orphan*/ port;
typedef int /*<<< orphan*/ buffer_size;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int /*<<< orphan*/ *);
int /*<<< orphan*/ assert(int);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int listen(int, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int read(int, ...);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int write(int, int *, int);
size_t server_setget_info(int port, int *num_threads, int *persist_with_reads) {
  struct sockaddr_in serv_addr;
  int lfd = 0, ret = 0, connfd;
  size_t buffer_size;
  int conn_port = 20480;
  lfd = socket(AF_INET, SOCK_STREAM, 0);
  assert(lfd);
  memset(&serv_addr, 0, sizeof(serv_addr));
  serv_addr.sin_family = AF_INET;
  serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
  serv_addr.sin_port = htons(conn_port);
  ret = bind(lfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr));
  assert(ret == 0);
  ret = listen(lfd, 1);
  assert(ret == 0);
  connfd = accept(lfd, (struct sockaddr *)NULL, NULL);
  assert(connfd);
  ret = write(connfd, &port, sizeof(port));
  assert(ret == sizeof(port));
  ret = read(connfd, &buffer_size, sizeof(buffer_size));
  assert(ret == sizeof(buffer_size));
  ret = read(connfd, num_threads, sizeof(int));
  assert(ret == sizeof(int));
  ret = read(connfd, persist_with_reads, sizeof(int));
  assert(ret == sizeof(int));
  close(connfd);
  close(lfd);
  return buffer_size;
}


x86 assembly (clang, -O0):
<server_setget_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x5000,-0x44(%rbp)
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
mov    0x2de8(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10d0 <socket@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
call   1090 <assert@plt>
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    0x2dd5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
call   1050 <htonl@plt>
mov    %eax,-0x24(%rbp)
mov    -0x44(%rbp),%edi
call   1040 <htons@plt>
mov    %eax,-0x28(%rbp)
mov    -0x2c(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0xc,%edx
call   10b0 <bind@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x2c(%rbp),%edi
mov    $0x1,%esi
call   10a0 <listen@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x2c(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   10c0 <accept@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edi
call   1090 <assert@plt>
mov    -0x34(%rbp),%edi
lea    -0x4(%rbp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    %eax,-0x30(%rbp)
movslq -0x30(%rbp),%rax
cmp    $0x4,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x34(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1080 <read@plt>
mov    %eax,-0x30(%rbp)
movslq -0x30(%rbp),%rax
cmp    $0x8,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x34(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1080 <read@plt>
mov    %eax,-0x30(%rbp)
movslq -0x30(%rbp),%rax
cmp    $0x4,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x34(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1080 <read@plt>
mov    %eax,-0x30(%rbp)
movslq -0x30(%rbp),%rax
cmp    $0x4,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x34(%rbp),%edi
call   1070 <close@plt>
mov    -0x2c(%rbp),%edi
call   1070 <close@plt>
mov    -0x40(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<server_setget_info>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,0x4(%rsp)
mov    0x2e1b(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2df9(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10d0 <socket@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1090 <assert@plt>
lea    0x8(%rsp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    0x0(%rbp),%eax
mov    %eax,0x10(%rsp)
mov    0x2dd5(%rip),%rax
mov    (%rax),%edi
call   1050 <htonl@plt>
mov    %eax,0xc(%rsp)
mov    $0x5000,%edi
call   1040 <htons@plt>
mov    %eax,0x8(%rsp)
mov    %ebx,%edi
mov    %r12,%rsi
mov    $0xc,%edx
call   10b0 <bind@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1090 <assert@plt>
mov    %ebx,%edi
mov    $0x1,%esi
call   10a0 <listen@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1090 <assert@plt>
mov    %ebx,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10c0 <accept@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1090 <assert@plt>
lea    0x4(%rsp),%rsi
mov    %ebp,%edi
mov    $0x4,%edx
call   1030 <write@plt>
xor    %edi,%edi
cmp    $0x4,%eax
sete   %dil
call   1090 <assert@plt>
lea    0x18(%rsp),%rsi
mov    $0x8,%edx
mov    %ebp,%edi
xor    %eax,%eax
call   1080 <read@plt>
xor    %edi,%edi
cmp    $0x8,%eax
sete   %dil
call   1090 <assert@plt>
mov    $0x4,%edx
mov    %ebp,%edi
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <read@plt>
xor    %edi,%edi
cmp    $0x4,%eax
sete   %dil
call   1090 <assert@plt>
mov    $0x4,%edx
mov    %ebp,%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <read@plt>
xor    %edi,%edi
cmp    $0x4,%eax
sete   %dil
call   1090 <assert@plt>
mov    %ebp,%edi
call   1070 <close@plt>
mov    %ebx,%edi
call   1070 <close@plt>
mov    0x18(%rsp),%rax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@INADDR_ANY = global i32 0
define i64 @server_setget_info(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 i64
%12 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32* %2, i32** %6
store i32 0, i32* %8
store i32 0, i32* %9
store i32 20480, i32* %12
%13 = load i32, i32* @AF_INET
%14 = load i32, i32* @SOCK_STREAM
%15 = call i32 @socket(i32 %13, i32 %14, i32 0)
store i32 %15, i32* %8
%16 = load i32, i32* %8
%17 = call i32 @assert(i32 %16)
%18 = call i32 @memset(%struct.sockaddr_in* %7, i32 0, i32 12)
%19 = load i32, i32* @AF_INET
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 2
store i32 %19, i32* %20
%21 = load i32, i32* @INADDR_ANY
%22 = call i32 @htonl(i32 %21)
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
%24 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %23, i32 0, i32 0
store i32 %22, i32* %24
%25 = load i32, i32* %12
%26 = call i32 @htons(i32 %25)
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
store i32 %26, i32* %27
%28 = load i32, i32* %8
%29 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%30 = call i32 @bind(i32 %28, %struct.sockaddr* %29, i32 12)
store i32 %30, i32* %9
%31 = load i32, i32* %9
%32 = icmp eq i32 %31, 0
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
%35 = load i32, i32* %8
%36 = call i32 @listen(i32 %35, i32 1)
store i32 %36, i32* %9
%37 = load i32, i32* %9
%38 = icmp eq i32 %37, 0
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
%41 = load i32, i32* %8
%42 = call i32 @accept(i32 %41, %struct.sockaddr* null, i32* null)
store i32 %42, i32* %10
%43 = load i32, i32* %10
%44 = call i32 @assert(i32 %43)
%45 = load i32, i32* %10
%46 = call i32 @write(i32 %45, i32* %4, i32 4)
store i32 %46, i32* %9
%47 = load i32, i32* %9
%48 = sext i32 %47 to i64
%49 = icmp eq i64 %48, 4
%50 = zext i1 %49 to i32
%51 = call i32 @assert(i32 %50)
%52 = load i32, i32* %10
%53 = call i32 (i32, ...) @read(i32 %52, i64* %11, i64 8)
store i32 %53, i32* %9
%54 = load i32, i32* %9
%55 = sext i32 %54 to i64
%56 = icmp eq i64 %55, 8
%57 = zext i1 %56 to i32
%58 = call i32 @assert(i32 %57)
%59 = load i32, i32* %10
%60 = load i32*, i32** %5
%61 = call i32 (i32, ...) @read(i32 %59, i32* %60, i64 4)
store i32 %61, i32* %9
%62 = load i32, i32* %9
%63 = sext i32 %62 to i64
%64 = icmp eq i64 %63, 4
%65 = zext i1 %64 to i32
%66 = call i32 @assert(i32 %65)
%67 = load i32, i32* %10
%68 = load i32*, i32** %6
%69 = call i32 (i32, ...) @read(i32 %67, i32* %68, i64 4)
store i32 %69, i32* %9
%70 = load i32, i32* %9
%71 = sext i32 %70 to i64
%72 = icmp eq i64 %71, 4
%73 = zext i1 %72 to i32
%74 = call i32 @assert(i32 %73)
%75 = load i32, i32* %10
%76 = call i32 @close(i32 %75)
%77 = load i32, i32* %8
%78 = call i32 @close(i32 %77)
%79 = load i64, i64* %11
ret i64 %79
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@INADDR_ANY = global i32 0
define i64 @server_setget_info(i32 %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca %struct.sockaddr_in
%6 = alloca i64
store i32 %0, i32* %4
%7 = bitcast %struct.sockaddr_in* %5 to i8*
%8 = bitcast i64* %6 to i8*
%9 = load i32, i32* @AF_INET
%10 = load i32, i32* @SOCK_STREAM
%11 = tail call i32 @socket(i32 %9, i32 %10, i32 0)
%12 = tail call i32 @assert(i32 %11)
%13 = call i32 @memset(%struct.sockaddr_in* %5, i32 0, i32 12)
%14 = load i32, i32* @AF_INET
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 2
store i32 %14, i32* %15
%16 = load i32, i32* @INADDR_ANY
%17 = call i32 @htonl(i32 %16)
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 1, i32 0
store i32 %17, i32* %18
%19 = call i32 @htons(i32 20480)
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0
store i32 %19, i32* %20
%21 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%22 = call i32 @bind(i32 %11, %struct.sockaddr* %21, i32 12)
%23 = icmp eq i32 %22, 0
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = call i32 @listen(i32 %11, i32 1)
%27 = icmp eq i32 %26, 0
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = call i32 @accept(i32 %11, %struct.sockaddr* null, i32* null)
%31 = call i32 @assert(i32 %30)
%32 = call i32 @write(i32 %30, i32* %4, i32 4)
%33 = icmp eq i32 %32, 4
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
%36 = call i32 (i32, ...) @read(i32 %30, i64* %6, i64 8)
%37 = icmp eq i32 %36, 8
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
%40 = call i32 (i32, ...) @read(i32 %30, i32* %1, i64 4)
%41 = icmp eq i32 %40, 4
%42 = zext i1 %41 to i32
%43 = call i32 @assert(i32 %42)
%44 = call i32 (i32, ...) @read(i32 %30, i32* %2, i64 4)
%45 = icmp eq i32 %44, 4
%46 = zext i1 %45 to i32
%47 = call i32 @assert(i32 %46)
%48 = call i32 @close(i32 %30)
%49 = call i32 @close(i32 %11)
%50 = load i64, i64* %6
ret i64 %50
}