#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_in {
  int dummy;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;

/* Variables and functions */
int BUFSIZ;
int accept(int, struct sockaddr *, int *);
int /*<<< orphan*/ close(int);
int determine_reqtype(char *);
int /*<<< orphan*/ handletypes(int, int, char *);
int /*<<< orphan*/ recv(int, char *, int, int /*<<< orphan*/);
void conloop(int *fd) {
  int connection;
  int type;
  char request[BUFSIZ];
  struct sockaddr_in dest;
  socklen_t destlen;
  destlen = sizeof(struct sockaddr_in);
  for (;;) {
    connection = accept(*fd, (struct sockaddr *)&dest, &destlen);
    recv(connection, request, BUFSIZ, 0);
    type = determine_reqtype(request);
    handletypes(type, connection, request);
    close(connection);
  }
}


x86 assembly (clang, -O0):
<conloop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e7d(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x4,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
call   1070 <accept@plt>
mov    -0x38(%rbp),%rsi
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    0x2e2d(%rip),%rax
mov    (%rax),%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    -0x38(%rbp),%rdi
call   1060 <determine_reqtype@plt>
mov    -0x38(%rbp),%rdx
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <handletypes@plt>
mov    -0xc(%rbp),%edi
call   1050 <close@plt>
jmp    118f <conloop+0x3f>

x86 assembly (clang, -O2):
<conloop>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2e78(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r13
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
movl   $0x4,-0x2c(%rbp)
lea    -0x30(%rbp),%r15
lea    -0x2c(%rbp),%r12
nopw   0x0(%rax,%rax,1)
mov    (%r14),%edi
mov    %r15,%rsi
mov    %r12,%rdx
call   1070 <accept@plt>
mov    %eax,%ebx
mov    0x2e39(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    %r13,%rsi
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %r13,%rdi
call   1060 <determine_reqtype@plt>
mov    %eax,%edi
mov    %ebx,%esi
mov    %r13,%rdx
call   1040 <handletypes@plt>
mov    %ebx,%edi
call   1050 <close@plt>
jmp    1190 <conloop+0x40>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@BUFSIZ = global i32 0
define void @conloop(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca %struct.sockaddr_in
%8 = alloca i32
store i32* %0, i32** %2
%9 = load i32, i32* @BUFSIZ
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %5
%12 = alloca i8, i64 %10
store i64 %10, i64* %6
store i32 4, i32* %8
br label %13
13: ; preds = %13, %1
%14 = load i32*, i32** %2
%15 = load i32, i32* %14
%16 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%17 = call i32 @accept(i32 %15, %struct.sockaddr* %16, i32* %8)
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = load i32, i32* @BUFSIZ
%20 = call i32 @recv(i32 %18, i8* %12, i32 %19, i32 0)
%21 = call i32 @determine_reqtype(i8* %12)
store i32 %21, i32* %4
%22 = load i32, i32* %4
%23 = load i32, i32* %3
%24 = call i32 @handletypes(i32 %22, i32 %23, i8* %12)
%25 = load i32, i32* %3
%26 = call i32 @close(i32 %25)
br label %13
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@BUFSIZ = global i32 0
define void @conloop(i32* nocapture %0) {
%2 = alloca %struct.sockaddr_in
%3 = alloca i32
%4 = load i32, i32* @BUFSIZ
%5 = zext i32 %4 to i64
%6 = alloca i8, i64 %5
%7 = bitcast %struct.sockaddr_in* %2 to i8*
%8 = bitcast i32* %3 to i8*
store i32 4, i32* %3
%9 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
br label %10
10: ; preds = %10, %1
%11 = load i32, i32* %0
%12 = call i32 @accept(i32 %11, %struct.sockaddr* %9, i32* %3)
%13 = load i32, i32* @BUFSIZ
%14 = call i32 @recv(i32 %12, i8* %6, i32 %13, i32 0)
%15 = call i32 @determine_reqtype(i8* %6)
%16 = call i32 @handletypes(i32 %15, i32 %12, i8* %6)
%17 = call i32 @close(i32 %12)
br label %10
}