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

/* Variables and functions */
char *calloc(int, int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ sleep(double);
int /*<<< orphan*/ stdin;
int strlen(char *);
int /*<<< orphan*/ write(int, ...);
void sendMessages(int fd) {
  int ssize = 1;
  char *input;
  input = calloc(256, sizeof(char *));
  while (1) {
    fgets(input, 256 - 1, stdin);
    if (strlen(input) < 1)
      sleep(0.1);
    else {
      ssize = strlen(input);
      write(fd, &ssize, sizeof(ssize));
      write(fd, input, (strlen(input) + 1) * sizeof(char));
    }
  }
  free(input);
}


x86 assembly (clang, -O0):
<sendMessages>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    $0x100,%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e68(%rip),%rax
mov    (%rax),%edx
mov    $0xff,%esi
call   1050 <fgets@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x1,%eax
jge    11b0 <sendMessages+0x60>
movsd  0xe5a(%rip),%xmm0
call   1070 <sleep@plt>
jmp    11fe <sendMessages+0xae>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x8(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
add    $0x1,%eax
movslq %eax,%rdx
shl    $0x0,%rdx
mov    $0x0,%al
call   1030 <write@plt>
jmp    1175 <sendMessages+0x25>

x86 assembly (clang, -O2):
<sendMessages>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebp
movl   $0x1,0x4(%rsp)
mov    $0x100,%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,%rbx
mov    0x2e6e(%rip),%r15
lea    0x4(%rsp),%r14
jmp    11c7 <sendMessages+0x77>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,0x4(%rsp)
mov    $0x4,%edx
mov    %ebp,%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <write@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
movslq %eax,%rdx
mov    %ebp,%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <write@plt>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    $0xff,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jg     1190 <sendMessages+0x40>
movsd  0xe15(%rip),%xmm0
call   1070 <sleep@plt>
jmp    11c7 <sendMessages+0x77>

LLVM IR (-O0):
@stdin = global i32 0
define void @sendMessages(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %2
store i32 1, i32* %3
%5 = call i8* @calloc(i32 256, i32 8)
store i8* %5, i8** %4
br label %6
6: ; preds = %1, %28
%7 = load i8*, i8** %4
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 255, i32 %8)
%10 = load i8*, i8** %4
%11 = call i32 @strlen(i8* %10)
%12 = icmp slt i32 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %6
%14 = call i32 @sleep(double 1.000000e-01)
br label %28
15: ; preds = %6
%16 = load i8*, i8** %4
%17 = call i32 @strlen(i8* %16)
store i32 %17, i32* %3
%18 = load i32, i32* %2
%19 = call i32 (i32, ...) @write(i32 %18, i32* %3, i64 4)
%20 = load i32, i32* %2
%21 = load i8*, i8** %4
%22 = load i8*, i8** %4
%23 = call i32 @strlen(i8* %22)
%24 = add nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = mul i64 %25, 1
%27 = call i32 (i32, ...) @write(i32 %20, i8* %21, i64 %26)
br label %28
28: ; preds = %15, %13
br label %6
}

LLVM IR (-O2):
@stdin = global i32 0
define void @sendMessages(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 1, i32* %2
%4 = tail call dereferenceable_or_null(2048) i8* @calloc(i32 256, i32 8)
br label %5
5: ; preds = %19, %1
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %4, i32 255, i32 %6)
%8 = call i32 @strlen(i8* %4)
%9 = icmp slt i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = call i32 @sleep(double 1.000000e-01)
br label %19
12: ; preds = %5
%13 = call i32 @strlen(i8* %4)
store i32 %13, i32* %2
%14 = call i32 (i32, ...) @write(i32 %0, i32* %2, i64 4)
%15 = call i32 @strlen(i8* %4)
%16 = add nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = call i32 (i32, ...) @write(i32 %0, i8* %4, i64 %17)
br label %19
19: ; preds = %12, %10
br label %5
}