#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*/ servaddr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ err_quit(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int initserver(int /*<<< orphan*/, struct sockaddr *, int, int);
int /*<<< orphan*/ serve(int);
int main(int argc, char *argv[]) {
  int sockfd;
  if (argc != 1)
    err_quit("usage: alistturingmachine");
  struct sockaddr_in servaddr;
  servaddr.sin_family = AF_INET;
  servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
  servaddr.sin_port = htons(6121);
  if ((sockfd = initserver(SOCK_STREAM, (struct sockaddr *)&servaddr,
                           sizeof(servaddr), 10)) >= 0) {
    serve(sockfd);
    exit(0);
  }
  exit(1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     118c <main+0x2c>
lea    0xe79(%rip),%rdi
call   1050 <err_quit@plt>
mov    0x2e55(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
call   1040 <htonl@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x17e9,%edi
call   1030 <htons@plt>
mov    %eax,-0x20(%rbp)
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
mov    $0xc,%edx
mov    $0xa,%ecx
call   1070 <initserver@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jl     11ed <main+0x8d>
mov    -0x14(%rbp),%edi
call   1060 <serve@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
cmp    $0x1,%edi
je     1175 <main+0x15>
lea    0xe90(%rip),%rdi
call   1050 <err_quit@plt>
mov    0x2e6c(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
call   1040 <htonl@plt>
mov    %eax,0xc(%rsp)
mov    $0x17e9,%edi
call   1030 <htons@plt>
mov    %eax,0x8(%rsp)
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
mov    $0xc,%edx
mov    $0xa,%ecx
call   1070 <initserver@plt>
test   %eax,%eax
js     11d1 <main+0x71>
mov    %eax,%edi
call   1060 <serve@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [26 x i8] c"usage: alistturingmachine\00"
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@SOCK_STREAM = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.sockaddr_in
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @err_quit(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %2
%13 = load i32, i32* @AF_INET
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 2
store i32 %13, i32* %14
%15 = load i32, i32* @INADDR_ANY
%16 = call i32 @htonl(i32 %15)
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
%18 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %17, i32 0, i32 0
store i32 %16, i32* %18
%19 = call i32 @htons(i32 6121)
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
store i32 %19, i32* %20
%21 = load i32, i32* @SOCK_STREAM
%22 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%23 = call i32 @initserver(i32 %21, %struct.sockaddr* %22, i32 12, i32 10)
store i32 %23, i32* %6
%24 = icmp sge i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %12
%26 = load i32, i32* %6
%27 = call i32 @serve(i32 %26)
%28 = call i32 @exit(i32 0)
unreachable
29: ; preds = %12
%30 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [26 x i8] c"usage: alistturingmachine\00"
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@SOCK_STREAM = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sockaddr_in
%4 = icmp eq i32 %0, 1
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @err_quit(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %2
%8 = bitcast %struct.sockaddr_in* %3 to i8*
%9 = load i32, i32* @AF_INET
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %9, i32* %10
%11 = load i32, i32* @INADDR_ANY
%12 = tail call i32 @htonl(i32 %11)
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %12, i32* %13
%14 = tail call i32 @htons(i32 6121)
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %14, i32* %15
%16 = load i32, i32* @SOCK_STREAM
%17 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%18 = call i32 @initserver(i32 %16, %struct.sockaddr* %17, i32 12, i32 10)
%19 = icmp sgt i32 %18, -1
br i1 %19, label %20, label %23
20: ; preds = %7
%21 = call i32 @serve(i32 %18)
%22 = call i32 @exit(i32 0)
unreachable
23: ; preds = %7
%24 = call i32 @exit(i32 1)
unreachable
}