#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 */
struct String {
  int dummy;
};

/* Variables and functions */
int Reader_io_read(int /*<<< orphan*/);
int /*<<< orphan*/ Writer_io_write(int /*<<< orphan*/, int);
int /*<<< orphan*/ printstring(struct String *);
struct String *string_fromlit(char *);
int main(int argc, char *argv[]) {
  int c;
  struct String *s;
  s = string_fromlit("Type some data and press enter: ");
  printstring(s);
  while ((c = Reader_io_read(0)) != '\n') {
    Writer_io_write(0, c);
  }
  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    0xea3(%rip),%rdi
call   1050 <string_fromlit@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <printstring@plt>
xor    %edi,%edi
call   1060 <Reader_io_read@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xa,%eax
je     1191 <main+0x51>
mov    -0x14(%rbp),%esi
xor    %edi,%edi
call   1040 <Writer_io_write@plt>
jmp    116f <main+0x2f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeb8(%rip),%rdi
call   1050 <string_fromlit@plt>
mov    %rax,%rdi
call   1030 <printstring@plt>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %edi,%edi
call   1060 <Reader_io_read@plt>
cmp    $0xa,%eax
je     1177 <main+0x37>
xor    %edi,%edi
mov    %eax,%esi
call   1040 <Writer_io_write@plt>
jmp    1160 <main+0x20>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.String = type { i32 }
@.str = [33 x i8] c"Type some data and press enter: \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.String*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call %struct.String* @string_fromlit(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store %struct.String* %8, %struct.String** %7
%9 = load %struct.String*, %struct.String** %7
%10 = call i32 @printstring(%struct.String* %9)
br label %11
11: ; preds = %14, %2
%12 = call i32 @Reader_io_read(i32 0)
store i32 %12, i32* %6
%13 = icmp ne i32 %12, 10
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* %6
%16 = call i32 @Writer_io_write(i32 0, i32 %15)
br label %11
17: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
%struct.String = type { i32 }
@.str = [33 x i8] c"Type some data and press enter: \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call %struct.String* @string_fromlit(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @printstring(%struct.String* %3)
%5 = tail call i32 @Reader_io_read(i32 0)
%6 = icmp eq i32 %5, 10
br i1 %6, label %12, label %7
7: ; preds = %2, %7
%8 = phi i32 [ %10, %7 ], [ %5, %2 ]
%9 = tail call i32 @Writer_io_write(i32 0, i32 %8)
%10 = tail call i32 @Reader_io_read(i32 0)
%11 = icmp eq i32 %10, 10
br i1 %11, label %12, label %7
12: ; preds = %7, %2
ret i32 0
}