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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ handle_request(char *);
int init_connection();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ terminate_client();
int main(int argc, char **argv) {
  char buffer[1024];
  if (init_connection() == 1) {
    fprintf(stderr, "Failed to initialize client\n");
    return -1;
  }
  while (1) {
    printf("Enter you message : ");
    gets(buffer);
    if (strcmp(buffer, ".") == 0) {
      break;
    }
    handle_request(buffer);
    printf("\n");
  }
  terminate_client();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <init_connection@plt>
cmp    $0x1,%eax
jne    11ba <main+0x4a>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
lea    0xe57(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1224 <main+0xb4>
jmp    11bf <main+0x4f>
lea    0xe57(%rip),%rdi
call   1050 <printf@plt>
lea    -0x410(%rbp),%rdi
call   1090 <gets@plt>
lea    -0x410(%rbp),%rdi
lea    0xe4d(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11f9 <main+0x89>
jmp    1216 <main+0xa6>
lea    -0x410(%rbp),%rdi
call   1070 <handle_request@plt>
lea    0xe0f(%rip),%rdi
call   1050 <printf@plt>
jmp    11bf <main+0x4f>
mov    $0x0,%al
call   1030 <terminate_client@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
xor    %eax,%eax
call   1050 <init_connection@plt>
cmp    $0x1,%eax
jne    11b4 <main+0x34>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
lea    0xe58(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0xffffffff,%ebx
jmp    122b <main+0xab>
lea    0xe62(%rip),%rdi
call   1060 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   10a0 <gets@plt>
lea    0xe60(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1222 <main+0xa2>
mov    %rsp,%rbx
lea    0xe34(%rip),%r14
lea    0xe42(%rip),%r15
mov    %rbx,%rdi
call   1080 <handle_request@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   10a0 <gets@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    11f0 <main+0x70>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <terminate_client@plt>
mov    %ebx,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [29 x i8] c"Failed to initialize client\0A\00"
@.str.1 = [21 x i8] c"Enter you message : \00"
@.str.2 = [2 x i8] c".\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 (...) @init_connection()
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %27
12: ; preds = %2
br label %13
13: ; preds = %12, %21
%14 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%16 = call i32 @gets(i8* %15)
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %13
br label %25
21: ; preds = %13
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%23 = call i32 @handle_request(i8* %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %13
25: ; preds = %20
%26 = call i32 (...) @terminate_client()
store i32 0, i32* %3
br label %27
27: ; preds = %25, %9
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"Failed to initialize client\0A\00"
@.str.1 = [21 x i8] c"Enter you message : \00"
@.str.2 = [2 x i8] c".\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = tail call i32 (...) @init_connection()
%6 = icmp eq i32 %5, 1
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @gets(i8* %4)
%10 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %22, label %15
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %24
15: ; preds = %7, %15
%16 = call i32 @handle_request(i8* %4)
%17 = call i32 @putchar(i32 10)
%18 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @gets(i8* %4)
%20 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %15
22: ; preds = %15, %7
%23 = call i32 (...) @terminate_client()
br label %24
24: ; preds = %22, %12
%25 = phi i32 [ -1, %12 ], [ 0, %22 ]
ret i32 %25
}