#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*/ fatalError(char *);
int strlen(char *);
int write(int, ...);
int sendMessagesToClient(int socketFD, char *answer) {
  int serverResponse = 0;
  int answerLength = strlen(answer) + 1;
  int n = 0;
  if (write(socketFD, &answerLength, 4) == -1)
    fatalError("Response sending error 1");
  if (answerLength != 1) {
    if ((n = write(socketFD, answer, answerLength)) == -1)
      fatalError("Response sending error 3");
  }
  return 0;
}


x86 assembly (clang, -O0):
<sendMessagesToClient>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1030 <write@plt>
cmp    $0xffffffff,%eax
jne    1184 <sendMessagesToClient+0x54>
lea    0xe81(%rip),%rdi
call   1050 <fatalError@plt>
cmpl   $0x1,-0x18(%rbp)
je     11bc <sendMessagesToClient+0x8c>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
jne    11b7 <sendMessagesToClient+0x87>
lea    0xe67(%rip),%rdi
call   1050 <fatalError@plt>
jmp    11bc <sendMessagesToClient+0x8c>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendMessagesToClient>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rsi
mov    %ebp,%edi
mov    $0x4,%edx
xor    %eax,%eax
call   1030 <write@plt>
cmp    $0xffffffff,%eax
jne    116b <sendMessagesToClient+0x3b>
lea    0xe9a(%rip),%rdi
call   1050 <fatalError@plt>
mov    0x4(%rsp),%edx
cmp    $0x1,%edx
je     1191 <sendMessagesToClient+0x61>
mov    %ebp,%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <write@plt>
cmp    $0xffffffff,%eax
jne    1191 <sendMessagesToClient+0x61>
lea    0xe8d(%rip),%rdi
call   1050 <fatalError@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Response sending error 1\00"
@.str.1 = [25 x i8] c"Response sending error 3\00"
define i32 @sendMessagesToClient(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
store i32 0, i32* %5
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
%10 = add nsw i32 %9, 1
store i32 %10, i32* %6
store i32 0, i32* %7
%11 = load i32, i32* %3
%12 = call i32 (i32, ...) @write(i32 %11, i32* %6, i32 4)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @fatalError(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %2
%17 = load i32, i32* %6
%18 = icmp ne i32 %17, 1
br i1 %18, label %19, label %28
19: ; preds = %16
%20 = load i32, i32* %3
%21 = load i8*, i8** %4
%22 = load i32, i32* %6
%23 = call i32 (i32, ...) @write(i32 %20, i8* %21, i32 %22)
store i32 %23, i32* %7
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = call i32 @fatalError(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %25, %19
br label %28
28: ; preds = %27, %16
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"Response sending error 1\00"
@.str.1 = [25 x i8] c"Response sending error 3\00"
define i32 @sendMessagesToClient(i32 %0, i8* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @strlen(i8* %1)
%6 = add nsw i32 %5, 1
store i32 %6, i32* %3
%7 = call i32 (i32, ...) @write(i32 %0, i32* %3, i32 4)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @fatalError(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 1
br i1 %13, label %19, label %14
14: ; preds = %11
%15 = call i32 (i32, ...) @write(i32 %0, i8* %1, i32 %12)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 @fatalError(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %14, %17, %11
ret i32 0
}