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

/* Type definitions */
struct sockaddr_in6 {
  int dummy;
};
typedef int /*<<< orphan*/ socklen_t;
typedef int /*<<< orphan*/ client_addr;

/* Variables and functions */
int atoi(char *);
int createServerConnection(int, struct sockaddr_in6 *);
int /*<<< orphan*/ generate_data();
int /*<<< orphan*/ memset(struct sockaddr_in6 *, int /*<<< orphan*/, int);
int /*<<< orphan*/ read_from_client(int, struct sockaddr_in6 *);
int /*<<< orphan*/ send_to_client(int, struct sockaddr_in6 *);
scalar_t__ strcmp(int /*<<< orphan*/, char *);
int main(int argc, char *argv[]) {
  int sock;
  int port = atoi(argv[1]);
  socklen_t clilen;
  struct sockaddr_in6 server_addr, client_addr;
  sock = createServerConnection(port, &server_addr);
  while (1) {
    if (strcmp(read_from_client(sock, &client_addr), "request") == 0) {
      generate_data();
      send_to_client(sock, &client_addr);
    }
    memset(&client_addr, 0, (int)sizeof(client_addr));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1070 <createServerConnection@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   1090 <read_from_client@plt>
mov    %eax,%edi
lea    0xe46(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11dc <main+0x6c>
mov    $0x0,%al
call   1060 <generate_data@plt>
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   1040 <send_to_client@plt>
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
jmp    11a5 <main+0x35>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x8(%rsi),%rdi
call   1080 <atoi@plt>
lea    0x8(%rsp),%rsi
mov    %eax,%edi
call   1070 <createServerConnection@plt>
mov    %eax,%ebx
mov    %rsp,%r14
lea    0xe66(%rip),%r15
jmp    11af <main+0x3f>
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1090 <read_from_client@plt>
mov    %eax,%edi
mov    %r15,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11a0 <main+0x30>
xor    %eax,%eax
call   1060 <generate_data@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1040 <send_to_client@plt>
jmp    11a0 <main+0x30>

LLVM IR (-O0):
%struct.sockaddr_in6 = type { i32 }
@.str = [8 x i8] c"request\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.sockaddr_in6
%10 = alloca %struct.sockaddr_in6
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @atoi(i8* %13)
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = call i32 @createServerConnection(i32 %15, %struct.sockaddr_in6* %9)
store i32 %16, i32* %6
br label %17
17: ; preds = %2, %26
%18 = load i32, i32* %6
%19 = call i32 @read_from_client(i32 %18, %struct.sockaddr_in6* %10)
%20 = call i64 @strcmp(i32 %19, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %17
%23 = call i32 (...) @generate_data()
%24 = load i32, i32* %6
%25 = call i32 @send_to_client(i32 %24, %struct.sockaddr_in6* %10)
br label %26
26: ; preds = %22, %17
%27 = call i32 @memset(%struct.sockaddr_in6* %10, i32 0, i32 4)
br label %17
}

LLVM IR (-O2):
%struct.sockaddr_in6 = type { i32 }
@.str = [8 x i8] c"request\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in6
%4 = alloca %struct.sockaddr_in6
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = bitcast %struct.sockaddr_in6* %3 to i8*
%9 = bitcast %struct.sockaddr_in6* %4 to i8*
%10 = call i32 @createServerConnection(i32 %7, %struct.sockaddr_in6* %3)
br label %11
11: ; preds = %18, %2
%12 = call i32 @read_from_client(i32 %10, %struct.sockaddr_in6* %4)
%13 = call i64 @strcmp(i32 %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = call i32 (...) @generate_data()
%17 = call i32 @send_to_client(i32 %10, %struct.sockaddr_in6* %4)
br label %18
18: ; preds = %15, %11
%19 = call i32 @memset(%struct.sockaddr_in6* %4, i32 0, i32 4)
br label %11
}