#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*/ Receive_File(int);
int /*<<< orphan*/ SendFile(int);
int /*<<< orphan*/ free(void *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ send_receive_message(int);
void *connection_handler(void *socket_desc) {
  int sock = *(int *)socket_desc;
  int count = 0, job = 0;
  puts("1. send/receice massage");
  puts("2. send file");
  puts("3 receive file");
  scanf("%d", &job);
  switch (job) {
  case 1:
    puts("send/receice massage");
    send_receive_message(sock);
    break;
  case 2:
    puts("send file");
    SendFile(sock);
    break;
  case 3:
    puts("receive file");
    Receive_File(sock);
    break;
  default:
    puts("nothing to do GG");
    break;
  }
  free(socket_desc);
  return 0;
}


x86 assembly (clang, -O0):
<connection_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe76(%rip),%rdi
call   1050 <puts@plt>
lea    0xe82(%rip),%rdi
call   1050 <puts@plt>
lea    0xe83(%rip),%rdi
call   1050 <puts@plt>
lea    0xe86(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x1,%eax
je     11ed <connection_handler+0x8d>
jmp    11cb <connection_handler+0x6b>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
je     1206 <connection_handler+0xa6>
jmp    11dc <connection_handler+0x7c>
mov    -0x18(%rbp),%eax
sub    $0x3,%eax
je     121f <connection_handler+0xbf>
jmp    1238 <connection_handler+0xd8>
lea    0xe0f(%rip),%rdi
call   1050 <puts@plt>
mov    -0xc(%rbp),%edi
call   1060 <send_receive_message@plt>
jmp    1244 <connection_handler+0xe4>
lea    0xe0e(%rip),%rdi
call   1050 <puts@plt>
mov    -0xc(%rbp),%edi
call   1040 <SendFile@plt>
jmp    1244 <connection_handler+0xe4>
lea    0xe01(%rip),%rdi
call   1050 <puts@plt>
mov    -0xc(%rbp),%edi
call   1080 <Receive_File@plt>
jmp    1244 <connection_handler+0xe4>
lea    0xdf8(%rip),%rdi
call   1050 <puts@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<connection_handler>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%ebp
movl   $0x0,0x4(%rsp)
lea    0xe89(%rip),%rdi
call   1050 <puts@plt>
lea    0xe95(%rip),%rdi
call   1050 <puts@plt>
lea    0xe96(%rip),%rdi
call   1050 <puts@plt>
lea    0xe99(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x3,%eax
je     11cd <connection_handler+0x6d>
cmp    $0x2,%eax
je     11e2 <connection_handler+0x82>
cmp    $0x1,%eax
jne    11f7 <connection_handler+0x97>
lea    0xe44(%rip),%rdi
call   1050 <puts@plt>
mov    %ebp,%edi
call   1060 <send_receive_message@plt>
jmp    1203 <connection_handler+0xa3>
lea    0xe53(%rip),%rdi
call   1050 <puts@plt>
mov    %ebp,%edi
call   1080 <Receive_File@plt>
jmp    1203 <connection_handler+0xa3>
lea    0xe32(%rip),%rdi
call   1050 <puts@plt>
mov    %ebp,%edi
call   1040 <SendFile@plt>
jmp    1203 <connection_handler+0xa3>
lea    0xe39(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"1. send/receice massage\00"
@.str.1 = [13 x i8] c"2. send file\00"
@.str.2 = [15 x i8] c"3 receive file\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [21 x i8] c"send/receice massage\00"
@.str.5 = [10 x i8] c"send file\00"
@.str.6 = [13 x i8] c"receive file\00"
@.str.7 = [17 x i8] c"nothing to do GG\00"
define i8* @connection_handler(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = bitcast i8* %6 to i32*
%8 = load i32, i32* %7
store i32 %8, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%9 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%13 = load i32, i32* %5
switch i32 %13, label %26 [
i32 1, label %14
i32 2, label %18
i32 3, label %22
]
14: ; preds = %1
%15 = call i32 @puts(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%16 = load i32, i32* %3
%17 = call i32 @send_receive_message(i32 %16)
br label %28
18: ; preds = %1
%19 = call i32 @puts(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%20 = load i32, i32* %3
%21 = call i32 @SendFile(i32 %20)
br label %28
22: ; preds = %1
%23 = call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%24 = load i32, i32* %3
%25 = call i32 @Receive_File(i32 %24)
br label %28
26: ; preds = %1
%27 = call i32 @puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
br label %28
28: ; preds = %26, %22, %18, %14
%29 = load i8*, i8** %2
%30 = call i32 @free(i8* %29)
ret i8* null
}

LLVM IR (-O2):
@.str = [24 x i8] c"1. send/receice massage\00"
@.str.1 = [13 x i8] c"2. send file\00"
@.str.2 = [15 x i8] c"3 receive file\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [21 x i8] c"send/receice massage\00"
@.str.5 = [10 x i8] c"send file\00"
@.str.6 = [13 x i8] c"receive file\00"
@.str.7 = [17 x i8] c"nothing to do GG\00"
define noalias i8* @connection_handler(i8* nocapture %0) {
%2 = alloca i32
%3 = bitcast i8* %0 to i32*
%4 = load i32, i32* %3
%5 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
switch i32 %10, label %20 [
i32 1, label %11
i32 2, label %14
i32 3, label %17
]
11: ; preds = %1
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @send_receive_message(i32 %4)
br label %22
14: ; preds = %1
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 @SendFile(i32 %4)
br label %22
17: ; preds = %1
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%19 = call i32 @Receive_File(i32 %4)
br label %22
20: ; preds = %1
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
br label %22
22: ; preds = %20, %17, %14, %11
%23 = call i32 @free(i8* %0)
ret i8* null
}