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

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int /*<<< orphan*/ *);
int /*<<< orphan*/ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ listen(int, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ parse_gesture(unsigned char *);
int /*<<< orphan*/ recv(int, unsigned char *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main() {
  unsigned char buffer[30];
  struct sockaddr_in server;
  memset(&server, 0, sizeof(struct sockaddr_in));
  server.sin_family = AF_INET;
  server.sin_addr.s_addr = htonl(INADDR_ANY);
  server.sin_port = htons(6970);
  int sock = socket(AF_INET, SOCK_STREAM, 0);
  bind(sock, (struct sockaddr *)&server, sizeof(server));
  listen(sock, 10);
  int conn = accept(sock, (struct sockaddr *)NULL, NULL);
  while (1) {
    recv(conn, buffer, 30, 0);
    parse_gesture(buffer);
  }
  close(conn);
  close(sock);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
call   1050 <htonl@plt>
mov    %eax,-0x3c(%rbp)
mov    $0x1b3a,%edi
call   1040 <htons@plt>
mov    %eax,-0x40(%rbp)
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
mov    0x2de7(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10b0 <socket@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0xc,%edx
call   1090 <bind@plt>
mov    -0x44(%rbp),%edi
mov    $0xa,%esi
call   1080 <listen@plt>
mov    -0x44(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   10a0 <accept@plt>
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x1e,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
lea    -0x30(%rbp),%rdi
call   1070 <parse_gesture@plt>
jmp    1225 <main+0x95>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    0x2e39(%rip),%rbp
mov    0x0(%rbp),%eax
mov    %eax,0x8(%rsp)
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
call   1050 <htonl@plt>
mov    %eax,0x4(%rsp)
mov    $0x1b3a,%edi
call   1040 <htons@plt>
mov    %eax,(%rsp)
mov    0x0(%rbp),%edi
mov    0x2df1(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10b0 <socket@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   1090 <bind@plt>
mov    %ebp,%edi
mov    $0xa,%esi
call   1080 <listen@plt>
mov    %ebp,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <accept@plt>
mov    %eax,%ebp
lea    0x10(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x1e,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %rbx,%rdi
call   1070 <parse_gesture@plt>
jmp    1220 <main+0x90>

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
@INADDR_ANY = global i32 0
@SOCK_STREAM = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [30 x i8]
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 12)
%7 = load i32, i32* @AF_INET
%8 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 2
store i32 %7, i32* %8
%9 = load i32, i32* @INADDR_ANY
%10 = call i32 @htonl(i32 %9)
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 1
%12 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %11, i32 0, i32 0
store i32 %10, i32* %12
%13 = call i32 @htons(i32 6970)
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 0
store i32 %13, i32* %14
%15 = load i32, i32* @AF_INET
%16 = load i32, i32* @SOCK_STREAM
%17 = call i32 @socket(i32 %15, i32 %16, i32 0)
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%20 = call i32 @bind(i32 %18, %struct.sockaddr* %19, i32 12)
%21 = load i32, i32* %4
%22 = call i32 @listen(i32 %21, i32 10)
%23 = load i32, i32* %4
%24 = call i32 @accept(i32 %23, %struct.sockaddr* null, i32* null)
store i32 %24, i32* %5
br label %25
25: ; preds = %0, %25
%26 = load i32, i32* %5
%27 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%28 = call i32 @recv(i32 %26, i8* %27, i32 30, i32 0)
%29 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%30 = call i32 @parse_gesture(i8* %29)
br label %25
}

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
@INADDR_ANY = global i32 0
@SOCK_STREAM = global i32 0
define i32 @main() {
%1 = alloca [30 x i8]
%2 = alloca %struct.sockaddr_in
%3 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%4 = bitcast %struct.sockaddr_in* %2 to i8*
%5 = call i32 @memset(%struct.sockaddr_in* %2, i32 0, i32 12)
%6 = load i32, i32* @AF_INET
%7 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 2
store i32 %6, i32* %7
%8 = load i32, i32* @INADDR_ANY
%9 = call i32 @htonl(i32 %8)
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1, i32 0
store i32 %9, i32* %10
%11 = call i32 @htons(i32 6970)
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0
store i32 %11, i32* %12
%13 = load i32, i32* @AF_INET
%14 = load i32, i32* @SOCK_STREAM
%15 = call i32 @socket(i32 %13, i32 %14, i32 0)
%16 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%17 = call i32 @bind(i32 %15, %struct.sockaddr* %16, i32 12)
%18 = call i32 @listen(i32 %15, i32 10)
%19 = call i32 @accept(i32 %15, %struct.sockaddr* null, i32* null)
br label %20
20: ; preds = %20, %0
%21 = call i32 @recv(i32 %19, i8* %3, i32 30, i32 0)
%22 = call i32 @parse_gesture(i8* %3)
br label %20
}