#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;
char getchar();
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ reverse_string(char *);
int main() {
  char ch, buf[4096];
  char *ptr;
  ptr = &buf[0];
  while ((ch = getchar()) != EOF) {
    if (ch == ' ' || ch == '\n') {
      *ptr = '\0';
      reverse_string(buf);
      printf("%s", buf);
      putchar(ch);
      ptr = &buf[0];
    } else {
      *ptr++ = ch;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1010(%rbp),%rax
mov    %rax,-0x1018(%rbp)
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
mov    0x2e74(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11fd <main+0xbd>
movsbl -0x5(%rbp),%eax
cmp    $0x20,%eax
je     1199 <main+0x59>
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
jne    11de <main+0x9e>
mov    -0x1018(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x1010(%rbp),%rdi
call   1040 <reverse_string@plt>
lea    -0x1010(%rbp),%rsi
lea    0xe43(%rip),%rdi
call   1050 <printf@plt>
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
lea    -0x1010(%rbp),%rax
mov    %rax,-0x1018(%rbp)
jmp    11f8 <main+0xb8>
mov    -0x5(%rbp),%cl
mov    -0x1018(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x1018(%rbp)
mov    %cl,(%rax)
jmp    1160 <main+0x20>
xor    %eax,%eax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1000,%rsp
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e8a(%rip),%r12
cmp    (%r12),%al
jne    1177 <main+0x37>
xor    %eax,%eax
add    $0x1000,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    %eax,%ebx
mov    %rsp,%r15
lea    0xe7d(%rip),%r14
mov    %r15,%r13
jmp    11c2 <main+0x82>
nopl   0x0(%rax,%rax,1)
movb   $0x0,0x0(%r13)
mov    %r15,%rdi
call   1040 <reverse_string@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <printf@plt>
movsbl %bl,%edi
call   1030 <putchar@plt>
mov    %r15,%r13
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,%ebx
cmp    (%r12),%al
je     1164 <main+0x24>
cmp    $0x20,%bl
je     1190 <main+0x50>
cmp    $0xa,%bl
je     1190 <main+0x50>
mov    %bl,0x0(%r13)
add    $0x1,%r13
jmp    11b3 <main+0x73>

LLVM IR (-O0):
@EOF = global i8 0
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [4096 x i8]
%4 = alloca i8*
store i32 0, i32* %1
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
store i8* %5, i8** %4
br label %6
6: ; preds = %33, %0
%7 = call signext i8 (...) @getchar()
store i8 %7, i8* %2
%8 = sext i8 %7 to i32
%9 = load i8, i8* @EOF
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %8, %10
br i1 %11, label %12, label %34
12: ; preds = %6
%13 = load i8, i8* %2
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 32
br i1 %15, label %20, label %16
16: ; preds = %12
%17 = load i8, i8* %2
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 10
br i1 %19, label %20, label %29
20: ; preds = %16, %12
%21 = load i8*, i8** %4
store i8 0, i8* %21
%22 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%23 = call i32 @reverse_string(i8* %22)
%24 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%25 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %24)
%26 = load i8, i8* %2
%27 = call i32 @putchar(i8 signext %26)
%28 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
store i8* %28, i8** %4
br label %33
29: ; preds = %16
%30 = load i8, i8* %2
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %4
store i8 %30, i8* %31
br label %33
33: ; preds = %29, %20
br label %6
34: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@EOF = global i8 0
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [4096 x i8]
%2 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 0
%3 = call signext i8 (...) @getchar()
%4 = load i8, i8* @EOF
%5 = icmp eq i8 %3, %4
br i1 %5, label %20, label %6
6: ; preds = %0, %15
%7 = phi i8 [ %17, %15 ], [ %3, %0 ]
%8 = phi i8* [ %16, %15 ], [ %2, %0 ]
switch i8 %7, label %13 [
i8 32, label %9
i8 10, label %9
]
9: ; preds = %6, %6
store i8 0, i8* %8
%10 = call i32 @reverse_string(i8* %2)
%11 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%12 = call i32 @putchar(i8 signext %7)
br label %15
13: ; preds = %6
%14 = getelementptr inbounds i8, i8* %8, i64 1
store i8 %7, i8* %8
br label %15
15: ; preds = %13, %9
%16 = phi i8* [ %2, %9 ], [ %14, %13 ]
%17 = call signext i8 (...) @getchar()
%18 = load i8, i8* @EOF
%19 = icmp eq i8 %17, %18
br i1 %19, label %20, label %6
20: ; preds = %15, %0
ret i32 0
}