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

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read(int, char *, int);
void *func(void *fd) {
  char str[128];
  while (1) {
    memset(str, 0, sizeof(str));
    read(*(int *)fd, str, sizeof(str));
    printf("%s\n", str);
    if (str[0] == 'q') {
      printf("over\n");
      return 0;
    }
  }
}


x86 assembly (clang, -O0):
<func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
lea    -0x90(%rbp),%rsi
mov    $0x80,%edx
call   1050 <read@plt>
lea    -0x90(%rbp),%rsi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0x90(%rbp),%eax
cmp    $0x71,%eax
jne    11a7 <func+0x77>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret
jmp    113f <func+0xf>

x86 assembly (clang, -O2):
<func>:
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %rdi,%r14
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
mov    (%r14),%edi
mov    %rbx,%rsi
mov    $0x80,%edx
call   1050 <read@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
cmpb   $0x71,(%rsp)
jne    1140 <func+0x10>
lea    0xe8c(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [6 x i8] c"over\0A\00"
define i8* @func(i8* %0) {
%2 = alloca i8*
%3 = alloca [128 x i8]
store i8* %0, i8** %2
br label %4
4: ; preds = %1, %20
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 128)
%7 = load i8*, i8** %2
%8 = bitcast i8* %7 to i32*
%9 = load i32, i32* %8
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%11 = call i32 @read(i32 %9, i8* %10, i32 128)
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 113
br i1 %17, label %18, label %20
18: ; preds = %4
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret i8* null
20: ; preds = %4
br label %4
}

LLVM IR (-O2):
@str = [5 x i8] c"over\00"
define noalias i8* @func(i8* nocapture %0) {
%2 = alloca [128 x i8]
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%4 = bitcast i8* %0 to i32*
br label %5
5: ; preds = %5, %1
%6 = call i32 @memset(i8* %3, i32 0, i32 128)
%7 = load i32, i32* %4
%8 = call i32 @read(i32 %7, i8* %3, i32 128)
%9 = call i32 @puts(i8* %3)
%10 = load i8, i8* %3
%11 = icmp eq i8 %10, 113
br i1 %11, label %12, label %5
12: ; preds = %5
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
ret i8* null
}