#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*/ packet_disp_err(int);
int packet_pack_exit_req(char *);
int packet_unpack_exit_resp(char *);
int recv_packet(int, char *);
int send_fix_len(int, char *, int);
int do_exit(int sockfd) {
  int ret = 0;
  char packet[1024];
  ret = packet_pack_exit_req(packet);
  ret = send_fix_len(sockfd, packet, ret);
  if (-1 == ret) {
    goto exit;
  }
  ret = recv_packet(sockfd, packet);
  if (ret <= 0) {
    goto exit;
  }
  ret = packet_unpack_exit_resp(packet);
  if (0 == ret) {
  } else {
    packet_disp_err(ret);
  }
  ret = 1;
exit:
  return ret;
}


x86 assembly (clang, -O0):
<do_exit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0x410(%rbp),%rdi
call   1070 <packet_pack_exit_req@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1030 <send_fix_len@plt>
mov    %eax,-0x8(%rbp)
mov    $0xffffffff,%eax
cmp    -0x8(%rbp),%eax
jne    119c <do_exit+0x4c>
jmp    11eb <do_exit+0x9b>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
call   1060 <recv_packet@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jg     11bd <do_exit+0x6d>
jmp    11eb <do_exit+0x9b>
lea    -0x410(%rbp),%rdi
call   1040 <packet_unpack_exit_resp@plt>
mov    %eax,-0x8(%rbp)
xor    %eax,%eax
cmp    -0x8(%rbp),%eax
jne    11dc <do_exit+0x8c>
jmp    11e4 <do_exit+0x94>
mov    -0x8(%rbp),%edi
call   1050 <packet_disp_err@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_exit>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %edi,%ebx
mov    %rsp,%r14
mov    %r14,%rdi
call   1070 <packet_pack_exit_req@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <send_fix_len@plt>
cmp    $0xffffffff,%eax
je     11a0 <do_exit+0x50>
mov    %rsp,%rsi
mov    %ebx,%edi
call   1060 <recv_packet@plt>
test   %eax,%eax
jle    11a7 <do_exit+0x57>
mov    %rsp,%rdi
call   1040 <packet_unpack_exit_resp@plt>
mov    $0x1,%ebx
test   %eax,%eax
je     11a9 <do_exit+0x59>
mov    %eax,%edi
call   1050 <packet_disp_err@plt>
jmp    11a9 <do_exit+0x59>
mov    $0xffffffff,%ebx
jmp    11a9 <do_exit+0x59>
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @do_exit(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [1024 x i8]
store i32 %0, i32* %2
store i32 0, i32* %3
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%6 = call i32 @packet_pack_exit_req(i8* %5)
store i32 %6, i32* %3
%7 = load i32, i32* %2
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%9 = load i32, i32* %3
%10 = call i32 @send_fix_len(i32 %7, i8* %8, i32 %9)
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = icmp eq i32 -1, %11
br i1 %12, label %13, label %14
13: ; preds = %1
br label %31
14: ; preds = %1
%15 = load i32, i32* %2
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%17 = call i32 @recv_packet(i32 %15, i8* %16)
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = icmp sle i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %14
br label %31
21: ; preds = %14
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%23 = call i32 @packet_unpack_exit_resp(i8* %22)
store i32 %23, i32* %3
%24 = load i32, i32* %3
%25 = icmp eq i32 0, %24
br i1 %25, label %26, label %27
26: ; preds = %21
br label %30
27: ; preds = %21
%28 = load i32, i32* %3
%29 = call i32 @packet_disp_err(i32 %28)
br label %30
30: ; preds = %27, %26
store i32 1, i32* %3
br label %31
31: ; preds = %30, %20, %13
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
define i32 @do_exit(i32 %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = call i32 @packet_pack_exit_req(i8* %3)
%5 = call i32 @send_fix_len(i32 %0, i8* %3, i32 %4)
%6 = icmp eq i32 %5, -1
br i1 %6, label %15, label %7
7: ; preds = %1
%8 = call i32 @recv_packet(i32 %0, i8* %3)
%9 = icmp slt i32 %8, 1
br i1 %9, label %15, label %10
10: ; preds = %7
%11 = call i32 @packet_unpack_exit_resp(i8* %3)
%12 = icmp eq i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = call i32 @packet_disp_err(i32 %11)
br label %15
15: ; preds = %13, %10, %7, %1
%16 = phi i32 [ -1, %1 ], [ %8, %7 ], [ 1, %10 ], [ 1, %13 ]
ret i32 %16
}