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

/* Variables and functions */
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, ...);
char *readline(char const *);
int main(void) {
  const char prompt[] = "> ";
  char *buf;
  while ((buf = readline(prompt))) {
    ;
    printf("You said, %s\n", buf);
    free(buf);
  }
  printf("Goodbye\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%ax
mov    %ax,-0x7(%rbp)
mov    0xeb2(%rip),%al
mov    %al,-0x5(%rbp)
lea    -0x7(%rbp),%rdi
call   1050 <readline@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     118a <main+0x5a>
mov    -0x10(%rbp),%rsi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
jmp    1153 <main+0x23>
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movb   $0x0,0xe(%rsp)
movw   $0x203e,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1060 <readline@plt>
test   %rax,%rax
je     11a5 <main+0x65>
mov    %rax,%rbx
lea    0xe95(%rip),%r14
lea    0xc(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1060 <readline@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1180 <main+0x40>
lea    0xe65(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.prompt = [3 x i8] c"> \00"
@.str = [14 x i8] c"You said, %s\0A\00"
@.str.1 = [9 x i8] c"Goodbye\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i8]
%3 = alloca i8*
store i32 0, i32* %1
%4 = bitcast [3 x i8]* %2 to i8*
br label %5
5: ; preds = %9, %0
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%7 = call i8* @readline(i8* %6)
store i8* %7, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %14
9: ; preds = %5
%10 = load i8*, i8** %3
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i8*, i8** %3
%13 = call i32 @free(i8* %12)
br label %5
14: ; preds = %5
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.prompt = [3 x i8] c"> \00"
@.str = [14 x i8] c"You said, %s\0A\00"
@str = [8 x i8] c"Goodbye\00"
define i32 @main() {
%1 = alloca [3 x i8]
%2 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%3 = call i8* @readline(i8* %2)
%4 = icmp eq i8* %3, null
br i1 %4, label %11, label %5
5: ; preds = %0, %5
%6 = phi i8* [ %9, %5 ], [ %3, %0 ]
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = call i32 @free(i8* %6)
%9 = call i8* @readline(i8* %2)
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %5
11: ; preds = %5, %0
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
ret i32 0
}