#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;
};

/* Variables and functions */
int InitSocket(int, int, int *, struct sockaddr_in *);
int /*<<< orphan*/ Loop(int, struct sockaddr_in *, int, char *, char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ printf(char *);
int main() {
  int sockfd, newsockfd;
  int clilen;
  int nConCount = 0;
  struct sockaddr_in serv_addr, cli_addr;
  char buffer[256];
  char writeBuf[256];
  if (InitSocket(9000, 5, &sockfd, &serv_addr) != 1) {
    printf("initsocket error");
    return 0;
  }
  while (1) {
    Loop(sockfd, &cli_addr, clilen, buffer, writeBuf);
  }
  close(sockfd);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x2328,%edi
mov    $0x5,%esi
lea    -0x8(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1040 <InitSocket@plt>
cmp    $0x1,%eax
je     1180 <main+0x50>
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x220,%rsp
pop    %rbp
ret
jmp    1185 <main+0x55>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%edx
lea    -0x120(%rbp),%rcx
lea    -0x220(%rbp),%r8
lea    -0x20(%rbp),%rsi
call   1050 <Loop@plt>
jmp    1185 <main+0x55>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x220,%rsp
lea    0xc(%rsp),%rdx
lea    0x18(%rsp),%rcx
mov    $0x2328,%edi
mov    $0x5,%esi
call   1040 <InitSocket@plt>
cmp    $0x1,%eax
jne    1184 <main+0x54>
lea    0x10(%rsp),%r14
lea    0x120(%rsp),%r15
lea    0x20(%rsp),%rbx
nopl   0x0(%rax)
mov    0xc(%rsp),%edi
mov    %r14,%rsi
mov    %r15,%rcx
mov    %rbx,%r8
call   1050 <Loop@plt>
jmp    1170 <main+0x40>
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x220,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32 }
@.str = [17 x i8] c"initsocket error\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.sockaddr_in
%7 = alloca %struct.sockaddr_in
%8 = alloca [256 x i8]
%9 = alloca [256 x i8]
store i32 0, i32* %1
store i32 0, i32* %5
%10 = call i32 @InitSocket(i32 9000, i32 5, i32* %2, %struct.sockaddr_in* %6)
%11 = icmp ne i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
ret i32 0
14: ; preds = %0
br label %15
15: ; preds = %14, %15
%16 = load i32, i32* %2
%17 = load i32, i32* %4
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%20 = call i32 @Loop(i32 %16, %struct.sockaddr_in* %7, i32 %17, i8* %18, i8* %19)
br label %15
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32 }
@.str = [17 x i8] c"initsocket error\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.sockaddr_in
%3 = alloca %struct.sockaddr_in
%4 = alloca [256 x i8]
%5 = alloca [256 x i8]
%6 = bitcast i32* %1 to i8*
%7 = bitcast %struct.sockaddr_in* %2 to i8*
%8 = bitcast %struct.sockaddr_in* %3 to i8*
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%11 = call i32 @InitSocket(i32 9000, i32 5, i32* %1, %struct.sockaddr_in* %2)
%12 = icmp eq i32 %11, 1
br i1 %12, label %15, label %13
13: ; preds = %0
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
ret i32 0
15: ; preds = %0, %15
%16 = load i32, i32* %1
%17 = call i32 @Loop(i32 %16, %struct.sockaddr_in* %3, i32 undef, i8* %9, i8* %10)
br label %15
}