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

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strncmp(char *, char *, int);
void *stupid_parrot(void *dummy) {
  char buffer[1024];
  (void)dummy;
  while (1) {
    printf("You: ");
    fgets(buffer, sizeof(buffer), stdin);
    if (!strncmp("stop it, please", buffer, sizeof("stop it, please") - 1))
      break;
    printf("Parrot: %s", buffer);
  }
  return NULL;
}


x86 assembly (clang, -O0):
<stupid_parrot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x410(%rbp),%rdi
mov    0x2e8d(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1050 <fgets@plt>
lea    -0x410(%rbp),%rsi
lea    0xe91(%rip),%rdi
mov    $0xf,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    118d <stupid_parrot+0x5d>
jmp    11a7 <stupid_parrot+0x77>
lea    -0x410(%rbp),%rsi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    113f <stupid_parrot+0xf>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stupid_parrot>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x400,%rsp
lea    0xeb9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e93(%rip),%r13
mov    0x0(%r13),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1050 <fgets@plt>
lea    0xe96(%rip),%rdi
mov    %rbx,%rsi
mov    $0xf,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11dc <stupid_parrot+0xac>
lea    0xe8e(%rip),%r14
mov    %rsp,%rbx
lea    0xe6e(%rip),%r15
lea    0xe6d(%rip),%r12
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1050 <fgets@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0xf,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    11a0 <stupid_parrot+0x70>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"You: \00"
@stdin = global i32 0
@.str.1 = [16 x i8] c"stop it, please\00"
@.str.2 = [11 x i8] c"Parrot: %s\00"
define i8* @stupid_parrot(i8* %0) {
%2 = alloca i8*
%3 = alloca [1024 x i8]
store i8* %0, i8** %2
%4 = load i8*, i8** %2
br label %5
5: ; preds = %1, %14
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 1024, i32 %8)
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%11 = call i32 @strncmp(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %10, i32 15)
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %5
br label %17
14: ; preds = %5
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %15)
br label %5
17: ; preds = %13
ret i8* null
}

LLVM IR (-O2):
@.str = [6 x i8] c"You: \00"
@stdin = global i32 0
@.str.1 = [16 x i8] c"stop it, please\00"
@.str.2 = [11 x i8] c"Parrot: %s\00"
define noalias i8* @stupid_parrot(i8* nocapture readnone %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %3, i32 1024, i32 %5)
%7 = call i32 @strncmp(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %3, i32 15)
%8 = icmp eq i32 %7, 0
br i1 %8, label %16, label %9
9: ; preds = %1, %9
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @stdin
%13 = call i32 @fgets(i8* %3, i32 1024, i32 %12)
%14 = call i32 @strncmp(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %3, i32 15)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %9
16: ; preds = %9, %1
ret i8* null
}