#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*/ debug_puts(char *);
int main() {
  volatile char in_char;
  debug_puts(
      "\n\n"
      "Press any key(and enter,if input is buffered, i.e. from keyboard):"
      "\n> ");
  in_char = (*((volatile char *)0x22));
  debug_puts("\nYou entered: ");
  do {
    (*((volatile char *)0x20)) = in_char;
  } while ((in_char = (*((volatile char *)0x22))) != '\n');
  (*((volatile char *)0x20)) = '\n';
  (*((volatile char *)0x20)) = '\n';
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
call   1030 <debug_puts@plt>
mov    $0x22,%eax
mov    (%rax),%al
mov    %al,-0x5(%rbp)
lea    0xf0c(%rip),%rdi
call   1030 <debug_puts@plt>
mov    -0x5(%rbp),%cl
mov    $0x20,%eax
mov    %cl,(%rax)
mov    $0x22,%eax
mov    (%rax),%al
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
jne    1141 <main+0x31>
mov    $0x20,%eax
movb   $0xa,(%rax)
mov    $0x20,%eax
movb   $0xa,(%rax)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
call   1030 <debug_puts@plt>
mov    0x22,%al
mov    %al,0x7(%rsp)
lea    0xf19(%rip),%rdi
call   1030 <debug_puts@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl 0x7(%rsp),%eax
mov    %al,0x20
movzbl 0x22,%eax
mov    %al,0x7(%rsp)
cmp    $0xa,%al
jne    1140 <main+0x30>
movb   $0xa,0x20
0a
movb   $0xa,0x20
0a
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [72 x i8] c"\0A\0APress any key(and enter,if input is buffered, i.e. from keyboard):\0A> \00"
@.str.1 = [15 x i8] c"\0AYou entered: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 @debug_puts(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0))
%4 = load volatile i8, i8* inttoptr (i64 34 to i8*)
store volatile i8 %4, i8* %2
%5 = call i32 @debug_puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %6
6: ; preds = %8, %0
%7 = load volatile i8, i8* %2
store volatile i8 %7, i8* inttoptr (i64 32 to i8*)
br label %8
8: ; preds = %6
%9 = load volatile i8, i8* inttoptr (i64 34 to i8*)
store volatile i8 %9, i8* %2
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 10
br i1 %11, label %6, label %12
12: ; preds = %8
store volatile i8 10, i8* inttoptr (i64 32 to i8*)
store volatile i8 10, i8* inttoptr (i64 32 to i8*)
ret i32 0
}

LLVM IR (-O2):
@.str = [72 x i8] c"\0A\0APress any key(and enter,if input is buffered, i.e. from keyboard):\0A> \00"
@.str.1 = [15 x i8] c"\0AYou entered: \00"
define i32 @main() {
%1 = alloca i8
%2 = tail call i32 @debug_puts(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0))
%3 = load volatile i8, i8* inttoptr (i64 34 to i8*)
store volatile i8 %3, i8* %1
%4 = tail call i32 @debug_puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %5
5: ; preds = %5, %0
%6 = load volatile i8, i8* %1
store volatile i8 %6, i8* inttoptr (i64 32 to i8*)
%7 = load volatile i8, i8* inttoptr (i64 34 to i8*)
store volatile i8 %7, i8* %1
%8 = icmp eq i8 %7, 10
br i1 %8, label %9, label %5
9: ; preds = %5
store volatile i8 10, i8* inttoptr (i64 32 to i8*)
store volatile i8 10, i8* inttoptr (i64 32 to i8*)
ret i32 0
}