#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 */
typedef int /*<<< orphan*/ response;
typedef int /*<<< orphan*/ converted;

/* Variables and functions */
int /*<<< orphan*/ PRINT_ERR(char *);
int /*<<< orphan*/ PRINT_INFO(char *);
int htonl(int);
int ntohl(int);
scalar_t__ read(int, int *, int);
scalar_t__ write(int, int *, int);
void tell_receiver_test_exit(int sockfd) {
  int request = (int)'E';
  int converted = htonl(request);
  int response = 0;
  if (write(sockfd, &converted, sizeof(converted)) < 0) {
    PRINT_ERR("cannot write data to the socket for sender/receiver sync");
  }
  if (read(sockfd, &response, sizeof(response)) <= 0) {
    PRINT_ERR("cannot read data from the socket for sender/receiver sync");
  }
  if (ntohl(response) == 13) {
    PRINT_INFO("receiver exited from current test");
  } else {
    PRINT_ERR("receiver is not able to handle this interrupt");
  }
}


x86 assembly (clang, -O0):
<tell_receiver_test_exit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x45,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <htonl@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%edi
lea    -0xc(%rbp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
cmp    $0x0,%rax
jge    11ab <tell_receiver_test_exit+0x4b>
lea    0xe5a(%rip),%rdi
call   1080 <PRINT_ERR@plt>
mov    -0x4(%rbp),%edi
lea    -0x10(%rbp),%rsi
mov    $0x4,%edx
call   1050 <read@plt>
cmp    $0x0,%rax
jg     11d2 <tell_receiver_test_exit+0x72>
lea    0xe6c(%rip),%rdi
call   1080 <PRINT_ERR@plt>
mov    -0x10(%rbp),%edi
call   1070 <ntohl@plt>
cmp    $0xd,%eax
jne    11f4 <tell_receiver_test_exit+0x94>
lea    0xe89(%rip),%rdi
call   1060 <PRINT_INFO@plt>
jmp    1200 <tell_receiver_test_exit+0xa0>
lea    0xe9a(%rip),%rdi
call   1080 <PRINT_ERR@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tell_receiver_test_exit>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    $0x45,%edi
call   1040 <htonl@plt>
mov    %eax,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xc(%rsp),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   1030 <write@plt>
test   %rax,%rax
jns    119f <tell_receiver_test_exit+0x3f>
lea    0xe66(%rip),%rdi
call   1080 <PRINT_ERR@plt>
lea    0x8(%rsp),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   1050 <read@plt>
test   %rax,%rax
jg     11c1 <tell_receiver_test_exit+0x61>
lea    0xe7d(%rip),%rdi
call   1080 <PRINT_ERR@plt>
mov    0x8(%rsp),%edi
call   1070 <ntohl@plt>
cmp    $0xd,%eax
jne    11e0 <tell_receiver_test_exit+0x80>
lea    0xe9d(%rip),%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1060 <PRINT_INFO@plt>
lea    0xeae(%rip),%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1080 <PRINT_ERR@plt>

LLVM IR (-O0):
@.str = [57 x i8] c"cannot write data to the socket for sender/receiver sync\00"
@.str.1 = [58 x i8] c"cannot read data from the socket for sender/receiver sync\00"
@.str.2 = [34 x i8] c"receiver exited from current test\00"
@.str.3 = [46 x i8] c"receiver is not able to handle this interrupt\00"
define void @tell_receiver_test_exit(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
store i32 69, i32* %3
%6 = load i32, i32* %3
%7 = call i32 @htonl(i32 %6)
store i32 %7, i32* %4
store i32 0, i32* %5
%8 = load i32, i32* %2
%9 = call i64 @write(i32 %8, i32* %4, i32 4)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = call i32 @PRINT_ERR(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %1
%14 = load i32, i32* %2
%15 = call i64 @read(i32 %14, i32* %5, i32 4)
%16 = icmp sle i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 @PRINT_ERR(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %17, %13
%20 = load i32, i32* %5
%21 = call i32 @ntohl(i32 %20)
%22 = icmp eq i32 %21, 13
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = call i32 @PRINT_INFO(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %27
25: ; preds = %19
%26 = call i32 @PRINT_ERR(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %25, %23
ret void
}

LLVM IR (-O2):
@.str = [57 x i8] c"cannot write data to the socket for sender/receiver sync\00"
@.str.1 = [58 x i8] c"cannot read data from the socket for sender/receiver sync\00"
@.str.2 = [34 x i8] c"receiver exited from current test\00"
@.str.3 = [46 x i8] c"receiver is not able to handle this interrupt\00"
define void @tell_receiver_test_exit(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @htonl(i32 69)
store i32 %5, i32* %2
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = call i64 @write(i32 %0, i32* %2, i32 4)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = tail call i32 @PRINT_ERR(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %1
%12 = call i64 @read(i32 %0, i32* %3, i32 4)
%13 = icmp slt i64 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 @PRINT_ERR(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
%17 = load i32, i32* %3
%18 = tail call i32 @ntohl(i32 %17)
%19 = icmp eq i32 %18, 13
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = tail call i32 @PRINT_INFO(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %24
22: ; preds = %16
%23 = tail call i32 @PRINT_ERR(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %22, %20
ret void
}