#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 ssize_t;

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ pthread_exit(int /*<<< orphan*/);
int read(int, char *, int);
void *readThread(void *parameters) {
  char readBuff[256];
  int fd;
  fd = *((int *)parameters);
  while (1) {
    ssize_t len;
    memset(&readBuff[0], 0, 256);
    len = read(fd, &readBuff[0], 256);
    if (-1 == len) {
    }
    if (0 == len) {
      printf("no data!\n");
    }
    int i = 0;
    for (i = 0; i < len; i++) {
      printf("%c %d", readBuff[i], readBuff[i]);
      printf("\n");
    }
  }
  pthread_exit(0);
}


x86 assembly (clang, -O0):
<readThread>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x114(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1040 <memset@plt>
mov    -0x114(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    $0x100,%edx
call   1050 <read@plt>
mov    %eax,-0x118(%rbp)
mov    $0xffffffff,%eax
cmp    -0x118(%rbp),%eax
jne    1191 <readThread+0x61>
jmp    1191 <readThread+0x61>
xor    %eax,%eax
cmp    -0x118(%rbp),%eax
jne    11ad <readThread+0x7d>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x11c(%rbp)
movl   $0x0,-0x11c(%rbp)
mov    -0x11c(%rbp),%eax
cmp    -0x118(%rbp),%eax
jge    1221 <readThread+0xf1>
movslq -0x11c(%rbp),%rax
movsbl -0x110(%rbp,%rax,1),%esi
ff
movslq -0x11c(%rbp),%rax
movsbl -0x110(%rbp,%rax,1),%edx
ff
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x11c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x11c(%rbp)
jmp    11c1 <readThread+0x91>
jmp    114b <readThread+0x1b>

x86 assembly (clang, -O2):
<readThread>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    (%rdi),%r15d
mov    %rsp,%r12
lea    0xe98(%rip),%r14
lea    0xe8b(%rip),%r13
jmp    1188 <readThread+0x38>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
mov    %r15d,%edi
mov    %r12,%rsi
mov    $0x100,%edx
call   1070 <read@plt>
test   %eax,%eax
je     1180 <readThread+0x30>
jle    1188 <readThread+0x38>
mov    %eax,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl (%rsp,%rbp,1),%edx
mov    %r13,%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11c0 <readThread+0x70>
jmp    1188 <readThread+0x38>

LLVM IR (-O0):
@.str = [10 x i8] c"no data!\0A\00"
@.str.1 = [6 x i8] c"%c %d\00"
@.str.2 = [2 x i8] c"\0A\00"
define i8* @readThread(i8* %0) {
%2 = alloca i8*
%3 = alloca [256 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = bitcast i8* %7 to i32*
%9 = load i32, i32* %8
store i32 %9, i32* %4
br label %10
10: ; preds = %1, %45
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%12 = call i32 @memset(i8* %11, i32 0, i32 256)
%13 = load i32, i32* %4
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%15 = call i32 @read(i32 %13, i8* %14, i32 256)
store i32 %15, i32* %5
%16 = load i32, i32* %5
%17 = icmp eq i32 -1, %16
br i1 %17, label %18, label %19
18: ; preds = %10
br label %19
19: ; preds = %18, %10
%20 = load i32, i32* %5
%21 = icmp eq i32 0, %20
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %22, %19
store i32 0, i32* %6
store i32 0, i32* %6
br label %25
25: ; preds = %42, %24
%26 = load i32, i32* %6
%27 = load i32, i32* %5
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %45
29: ; preds = %25
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %34, i32 %39)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %42
42: ; preds = %29
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %25
45: ; preds = %25
br label %10
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%c %d\00"
@str = [9 x i8] c"no data!\00"
define noalias i8* @readThread(i8* nocapture %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = bitcast i8* %0 to i32*
%5 = load i32, i32* %4
br label %6
6: ; preds = %12, %1
%7 = call i32 @memset(i8* %3, i32 0, i32 256)
%8 = call i32 @read(i32 %5, i8* %3, i32 256)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %17, %10, %13
br label %6
13: ; preds = %6
%14 = icmp sgt i32 %8, 0
br i1 %14, label %15, label %12
15: ; preds = %13
%16 = zext i32 %8 to i64
br label %17
17: ; preds = %15, %17
%18 = phi i64 [ 0, %15 ], [ %24, %17 ]
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %21)
%23 = call i32 @putchar(i32 10)
%24 = add nuw nsw i64 %18, 1
%25 = icmp eq i64 %24, %16
br i1 %25, label %12, label %17
}