#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 */
char getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
int main(void) {
  char c;
  int count;
  for (;;) {
    count = 0;
    printf("Please enter a line [blank line to terminate]> ");
    do {
      c = getchar();
      putchar(c);
      count++;
    } while (c != '\n');
    if (count == 1)
      break;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xeb3(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
jne    1152 <main+0x22>
cmpl   $0x1,-0xc(%rbp)
jne    118a <main+0x5a>
jmp    118f <main+0x5f>
jmp    113f <main+0xf>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xec5(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <printf@plt>
mov    $0x1,%ebx
nopl   (%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
movsbl %al,%ebp
mov    %ebp,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
cmp    $0xa,%bpl
jne    1150 <main+0x20>
test   %ebx,%ebx
jne    1140 <main+0x10>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [48 x i8] c"Please enter a line [blank line to terminate]> \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
store i32 0, i32* %1
br label %4
4: ; preds = %20, %0
store i32 0, i32* %3
%5 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %12, %4
%7 = call signext i8 (...) @getchar()
store i8 %7, i8* %2
%8 = load i8, i8* %2
%9 = call i32 @putchar(i8 signext %8)
%10 = load i32, i32* %3
%11 = add nsw i32 %10, 1
store i32 %11, i32* %3
br label %12
12: ; preds = %6
%13 = load i8, i8* %2
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 10
br i1 %15, label %6, label %16
16: ; preds = %12
%17 = load i32, i32* %3
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %20
19: ; preds = %16
br label %21
20: ; preds = %16
br label %4
21: ; preds = %19
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@.str = [48 x i8] c"Please enter a line [blank line to terminate]> \00"
define i32 @main() {
br label %1
1: ; preds = %9, %0
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
br label %3
3: ; preds = %3, %1
%4 = phi i32 [ 0, %1 ], [ %7, %3 ]
%5 = tail call signext i8 (...) @getchar()
%6 = tail call i32 @putchar(i8 signext %5)
%7 = add nuw nsw i32 %4, 1
%8 = icmp eq i8 %5, 10
br i1 %8, label %9, label %3
9: ; preds = %3
%10 = icmp eq i32 %4, 0
br i1 %10, label %11, label %1
11: ; preds = %9
ret i32 0
}