#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 EOF;
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
char getchar();
int /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ stdin;
int main(void) {
  char c;
  char s[] = "hello my darling wife!";
  fputs(s, stdin);
  while ((c = getchar()) != EOF)
    printf("%c\n", c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb5(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xeaf(%rip),%ax
mov    %ax,-0xc(%rbp)
mov    0xea7(%rip),%al
mov    %al,-0xa(%rbp)
lea    -0x20(%rbp),%rdi
mov    0x2e6b(%rip),%rax
mov    (%rax),%esi
call   1040 <fputs@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
mov    0x2e48(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11b8 <main+0x88>
lea    0xe6d(%rip),%rdi
movsbl -0x5(%rbp),%esi
call   1030 <printf@plt>
jmp    1184 <main+0x54>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movaps 0xec2(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0x21656669772067,%rax
mov    %rax,0xf(%rsp)
mov    0x2e90(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdi
call   1040 <fputs@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e70(%rip),%r14
cmp    (%r14),%al
je     1197 <main+0x67>
lea    0xe9b(%rip),%rbx
nopl   0x0(%rax)
movsbl %al,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r14),%al
jne    1180 <main+0x50>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.s = [23 x i8] c"hello my darling wife!\00"
@stdin = global i32 0
@EOF = global i8 0
@.str = [4 x i8] c"%c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [23 x i8]
store i32 0, i32* %1
%4 = bitcast [23 x i8]* %3 to i8*
%5 = getelementptr inbounds [23 x i8], [23 x i8]* %3, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i32 @fputs(i8* %5, i32 %6)
br label %8
8: ; preds = %14, %0
%9 = call signext i8 (...) @getchar()
store i8 %9, i8* %2
%10 = sext i8 %9 to i32
%11 = load i8, i8* @EOF
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %10, %12
br i1 %13, label %14, label %17
14: ; preds = %8
%15 = load i8, i8* %2
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %15)
br label %8
17: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@__const.main.s = [23 x i8] c"hello my darling wife!\00"
@stdin = global i32 0
@EOF = global i8 0
@.str = [4 x i8] c"%c\0A\00"
define i32 @main() {
%1 = alloca [23 x i8]
%2 = getelementptr inbounds [23 x i8], [23 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdin
%4 = call i32 @fputs(i8* %2, i32 %3)
%5 = call signext i8 (...) @getchar()
%6 = load i8, i8* @EOF
%7 = icmp eq i8 %5, %6
br i1 %7, label %14, label %8
8: ; preds = %0, %8
%9 = phi i8 [ %11, %8 ], [ %5, %0 ]
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %9)
%11 = call signext i8 (...) @getchar()
%12 = load i8, i8* @EOF
%13 = icmp eq i8 %11, %12
br i1 %13, label %14, label %8
14: ; preds = %8, %0
ret i32 0
}