#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  char buffer[10];
  puts("Enter text a line at a time; enter a blank to exit.");
  while (1) {
    fgets(buffer, 10, stdin);
    if (buffer[0] == '\n')
      break;
    puts(buffer);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
lea    -0x1a(%rbp),%rdi
mov    0x2e9b(%rip),%rax
mov    (%rax),%edx
mov    $0xa,%esi
call   1040 <fgets@plt>
movsbl -0x1a(%rbp),%eax
cmp    $0xa,%eax
jne    116b <main+0x4b>
jmp    1179 <main+0x59>
lea    -0x1a(%rbp),%rdi
call   1030 <puts@plt>
jmp    1142 <main+0x22>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xed2(%rip),%rdi
call   1030 <puts@plt>
mov    0x2eae(%rip),%r14
mov    (%r14),%edx
lea    0xe(%rsp),%rdi
mov    $0xa,%esi
call   1040 <fgets@plt>
cmpb   $0xa,0xe(%rsp)
je     117f <main+0x5f>
lea    0xe(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1040 <fgets@plt>
cmpb   $0xa,0xe(%rsp)
jne    1160 <main+0x40>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [52 x i8] c"Enter text a line at a time; enter a blank to exit.\00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [10 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 @puts(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %2, %17
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %9, i32 10, i32 %10)
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 10
br i1 %15, label %16, label %17
16: ; preds = %8
br label %20
17: ; preds = %8
%18 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%19 = call i32 @puts(i8* %18)
br label %8
20: ; preds = %16
ret i32 0
}

LLVM IR (-O2):
@.str = [52 x i8] c"Enter text a line at a time; enter a blank to exit.\00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [10 x i8]
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %4, i32 10, i32 %6)
%8 = load i8, i8* %4
%9 = icmp eq i8 %8, 10
br i1 %9, label %16, label %10
10: ; preds = %2, %10
%11 = call i32 @puts(i8* %4)
%12 = load i32, i32* @stdin
%13 = call i32 @fgets(i8* %4, i32 10, i32 %12)
%14 = load i8, i8* %4
%15 = icmp eq i8 %14, 10
br i1 %15, label %16, label %10
16: ; preds = %10, %2
ret i32 0
}