#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*/ printf(char *, char *);
int /*<<< orphan*/ reverse(char *, int, int);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main(int argc, const char *argv[]) {
  char s[100];
  scanf("%[^\n]", s);
  int l = strlen(s);
  int i, j;
  char state = 0;
  i = 0;
  while (i < l) {
    j = i;
    while (s[i] == ' ' && s[i] != '\0') {
      i++;
      j = i;
    }
    while (s[j] != ' ' && s[j] != '\0') {
      j++;
      state = 1;
    }
    if (state) {
      reverse(s, i, j);
      state = 0;
      i = j;
    }
  }
  reverse(s, 0, l);
  printf("%s", s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x80(%rbp),%rsi
lea    0xe9c(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x80(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x84(%rbp)
movb   $0x0,-0x8d(%rbp)
movl   $0x0,-0x88(%rbp)
mov    -0x88(%rbp),%eax
cmp    -0x84(%rbp),%eax
jge    12b1 <main+0x171>
mov    -0x88(%rbp),%eax
mov    %eax,-0x8c(%rbp)
movslq -0x88(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x8e(%rbp)
jne    11dc <main+0x9c>
movslq -0x88(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x8e(%rbp)
mov    -0x8e(%rbp),%al
test   $0x1,%al
jne    11ef <main+0xaf>
jmp    120f <main+0xcf>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
mov    -0x88(%rbp),%eax
mov    %eax,-0x8c(%rbp)
jmp    11a7 <main+0x67>
jmp    1214 <main+0xd4>
movslq -0x8c(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x8f(%rbp)
je     1249 <main+0x109>
movslq -0x8c(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x8f(%rbp)
mov    -0x8f(%rbp),%al
test   $0x1,%al
jne    125c <main+0x11c>
jmp    1277 <main+0x137>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
movb   $0x1,-0x8d(%rbp)
jmp    1214 <main+0xd4>
cmpb   $0x0,-0x8d(%rbp)
je     12ac <main+0x16c>
lea    -0x80(%rbp),%rdi
mov    -0x88(%rbp),%esi
mov    -0x8c(%rbp),%edx
call   1030 <reverse@plt>
movb   $0x0,-0x8d(%rbp)
mov    -0x8c(%rbp),%eax
mov    %eax,-0x88(%rbp)
jmp    1189 <main+0x49>
lea    -0x80(%rbp),%rdi
mov    -0x84(%rbp),%edx
xor    %esi,%esi
call   1030 <reverse@plt>
lea    -0x80(%rbp),%rsi
lea    0xd39(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x70,%rsp
lea    0xead(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%r12d
test   %eax,%eax
jle    120a <main+0xca>
xor    %ebx,%ebx
movabs $0xffffffff00000000,%r15
ff ff ff
movabs $0x100000000,%rbp
mov    %rsp,%r14
jmp    119f <main+0x5f>
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebx,%edx
call   1030 <reverse@plt>
cmp    %r12d,%ebx
jge    120a <main+0xca>
movslq %ebx,%rax
lea    -0x1(%rax),%esi
lea    (%rsp,%rax,1),%rcx
shl    $0x20,%rax
add    %r15,%rax
mov    %ebx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %edx,%ebx
add    %rbp,%rax
add    $0x1,%esi
cmpb   $0x20,(%rcx)
lea    0x1(%rcx),%rcx
lea    0x1(%rbx),%edx
je     11c0 <main+0x80>
movslq %ebx,%rax
add    %rsp,%rax
mov    $0x1,%cl
testb  $0xdf,(%rax)
je     11fe <main+0xbe>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
add    $0x1,%rax
xor    %ecx,%ecx
testb  $0xdf,(%rax)
jne    11f0 <main+0xb0>
test   $0x1,%cl
je     1190 <main+0x50>
mov    %esi,%ebx
cmp    %r12d,%ebx
jl     119f <main+0x5f>
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r12d,%edx
call   1030 <reverse@plt>
lea    0xde5(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%[^\0A]\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%12 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
store i32 %14, i32* %7
store i8 0, i8* %10
store i32 0, i32* %8
br label %15
15: ; preds = %70, %2
%16 = load i32, i32* %8
%17 = load i32, i32* %7
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %71
19: ; preds = %15
%20 = load i32, i32* %8
store i32 %20, i32* %9
br label %21
21: ; preds = %37, %19
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 32
br i1 %27, label %28, label %35
28: ; preds = %21
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 0
br label %35
35: ; preds = %28, %21
%36 = phi i1 [ false, %21 ], [ %34, %28 ]
br i1 %36, label %37, label %41
37: ; preds = %35
%38 = load i32, i32* %8
%39 = add nsw i32 %38, 1
store i32 %39, i32* %8
%40 = load i32, i32* %8
store i32 %40, i32* %9
br label %21
41: ; preds = %35
br label %42
42: ; preds = %58, %41
%43 = load i32, i32* %9
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp ne i32 %47, 32
br i1 %48, label %49, label %56
49: ; preds = %42
%50 = load i32, i32* %9
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp ne i32 %54, 0
br label %56
56: ; preds = %49, %42
%57 = phi i1 [ false, %42 ], [ %55, %49 ]
br i1 %57, label %58, label %61
58: ; preds = %56
%59 = load i32, i32* %9
%60 = add nsw i32 %59, 1
store i32 %60, i32* %9
store i8 1, i8* %10
br label %42
61: ; preds = %56
%62 = load i8, i8* %10
%63 = icmp ne i8 %62, 0
br i1 %63, label %64, label %70
64: ; preds = %61
%65 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%66 = load i32, i32* %8
%67 = load i32, i32* %9
%68 = call i32 @reverse(i8* %65, i32 %66, i32 %67)
store i8 0, i8* %10
%69 = load i32, i32* %9
store i32 %69, i32* %8
br label %70
70: ; preds = %64, %61
br label %15
71: ; preds = %15
%72 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%73 = load i32, i32* %7
%74 = call i32 @reverse(i8* %72, i32 0, i32 %73)
%75 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%76 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %75)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%[^\0A]\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = call i32 @strlen(i8* %4)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %35
8: ; preds = %2, %32
%9 = phi i32 [ %33, %32 ], [ 0, %2 ]
%10 = sext i32 %9 to i64
br label %11
11: ; preds = %11, %8
%12 = phi i64 [ %16, %11 ], [ %10, %8 ]
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 32
%16 = add i64 %12, 1
br i1 %15, label %11, label %17
17: ; preds = %11
%18 = trunc i64 %12 to i32
%19 = shl i64 %12, 32
%20 = ashr exact i64 %19, 32
br label %21
21: ; preds = %17, %26
%22 = phi i64 [ %20, %17 ], [ %27, %26 ]
%23 = phi i1 [ true, %17 ], [ false, %26 ]
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %22
%25 = load i8, i8* %24
switch i8 %25, label %26 [
i8 32, label %28
i8 0, label %28
]
26: ; preds = %21
%27 = add i64 %22, 1
br label %21
28: ; preds = %21, %21
%29 = trunc i64 %22 to i32
br i1 %23, label %32, label %30
30: ; preds = %28
%31 = call i32 @reverse(i8* %4, i32 %18, i32 %29)
br label %32
32: ; preds = %30, %28
%33 = phi i32 [ %29, %30 ], [ %18, %28 ]
%34 = icmp slt i32 %33, %6
br i1 %34, label %8, label %35
35: ; preds = %32, %2
%36 = call i32 @reverse(i8* %4, i32 0, i32 %6)
%37 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
ret i32 0
}