#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*/ printf(char *, char *);
int /*<<< orphan*/ read(int, ...);
void *receiveMessages(void *arg) {
  char *input;
  int ssize;
  input = calloc(256, sizeof(char *));
  while (1) {
    read(*((int *)arg), &ssize, sizeof(ssize));
    read(*((int *)arg), input, (ssize + 1) * sizeof(char));
    printf("re_1:%s", input);
  }
}


x86 assembly (clang, -O0):
<receiveMessages>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x100,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
lea    -0x14(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1040 <read@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movslq %eax,%rdx
shl    $0x0,%rdx
mov    %rdx,-0x20(%rbp)
mov    $0x0,%al
call   1040 <read@plt>
mov    -0x10(%rbp),%rsi
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
jmp    114f <receiveMessages+0x1f>

x86 assembly (clang, -O2):
<receiveMessages>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x100,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
lea    0x4(%rsp),%r15
lea    0xea7(%rip),%r12
nopl   0x0(%rax)
mov    (%r14),%edi
mov    $0x4,%edx
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <read@plt>
mov    (%r14),%edi
movslq 0x4(%rsp),%rdx
add    $0x1,%rdx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <read@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
jmp    1160 <receiveMessages+0x30>

LLVM IR (-O0):
@.str = [8 x i8] c"re_1:%s\00"
define i8* @receiveMessages(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = call i8* @calloc(i32 256, i32 8)
store i8* %5, i8** %3
br label %6
6: ; preds = %1, %6
%7 = load i8*, i8** %2
%8 = bitcast i8* %7 to i32*
%9 = load i32, i32* %8
%10 = call i32 (i32, ...) @read(i32 %9, i32* %4, i64 4)
%11 = load i8*, i8** %2
%12 = bitcast i8* %11 to i32*
%13 = load i32, i32* %12
%14 = load i8*, i8** %3
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = mul i64 %17, 1
%19 = call i32 (i32, ...) @read(i32 %13, i8* %14, i64 %18)
%20 = load i8*, i8** %3
%21 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %20)
br label %6
}

LLVM IR (-O2):
@.str = [8 x i8] c"re_1:%s\00"
define noalias i8* @receiveMessages(i8* nocapture %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call dereferenceable_or_null(2048) i8* @calloc(i32 256, i32 8)
%5 = bitcast i8* %0 to i32*
br label %6
6: ; preds = %6, %1
%7 = load i32, i32* %5
%8 = call i32 (i32, ...) @read(i32 %7, i32* %2, i64 4)
%9 = load i32, i32* %5
%10 = load i32, i32* %2
%11 = add nsw i32 %10, 1
%12 = sext i32 %11 to i64
%13 = call i32 (i32, ...) @read(i32 %9, i8* %4, i64 %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %4)
br label %6
}