#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*/ gets(char *);
int /*<<< orphan*/ pop_till_empty();
int /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ push(char);
int strlen(char *);
void main() {
  int i;
  char str[100];
  gets(str);
  i = strlen(str);
  i = i - 1;
  while (i >= 0) {
    while (str[i] != ' ') {
      push(str[i]);
      i--;
    }
    pop_till_empty();
    printf("%c", str[i]);
    i--;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
lea    -0x70(%rbp),%rdi
call   1060 <gets@plt>
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     11dd <main+0x8d>
jmp    1185 <main+0x35>
movslq -0x4(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x20,%eax
je     11b3 <main+0x63>
movslq -0x4(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%edi
call   1070 <push@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1185 <main+0x35>
mov    $0x0,%al
call   1050 <pop_till_empty@plt>
movslq -0x4(%rbp),%rax
lea    0xe3b(%rip),%rdi
movsbl -0x70(%rbp,%rax,1),%esi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1176 <main+0x26>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <gets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11dc <main+0x8c>
lea    0xe89(%rip),%r14
jmp    119e <main+0x4e>
nopl   0x0(%rax)
mov    %r15,%rbx
xor    %eax,%eax
call   1050 <pop_till_empty@plt>
movsbl (%rsp,%rbx,1),%esi
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15d,%eax
test   %r15d,%r15d
jle    11dc <main+0x8c>
lea    -0x1(%rax),%r15d
mov    (%rsp,%r15,1),%cl
cmp    $0x20,%cl
je     1180 <main+0x30>
mov    %eax,%ebx
add    $0xffffffffffffffff,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %cl,%edi
call   1070 <push@plt>
movzbl -0x1(%rsp,%rbx,1),%ecx
add    $0xffffffffffffffff,%rbx
add    $0xffffffff,%r15d
cmp    $0x20,%cl
jne    11c0 <main+0x70>
jmp    1183 <main+0x33>
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
define void @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%4 = call i32 @gets(i8* %3)
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = call i32 @strlen(i8* %5)
store i32 %6, i32* %1
%7 = load i32, i32* %1
%8 = sub nsw i32 %7, 1
store i32 %8, i32* %1
br label %9
9: ; preds = %28, %0
%10 = load i32, i32* %1
%11 = icmp sge i32 %10, 0
br i1 %11, label %12, label %37
12: ; preds = %9
br label %13
13: ; preds = %20, %12
%14 = load i32, i32* %1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 32
br i1 %19, label %20, label %28
20: ; preds = %13
%21 = load i32, i32* %1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = call i32 @push(i8 signext %24)
%26 = load i32, i32* %1
%27 = add nsw i32 %26, -1
store i32 %27, i32* %1
br label %13
28: ; preds = %13
%29 = call i32 (...) @pop_till_empty()
%30 = load i32, i32* %1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %33)
%35 = load i32, i32* %1
%36 = add nsw i32 %35, -1
store i32 %36, i32* %1
br label %9
37: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define void @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = call i32 @gets(i8* %2)
%4 = call i32 @strlen(i8* %2)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %34
6: ; preds = %0, %26
%7 = phi i32 [ %28, %26 ], [ %4, %0 ]
%8 = add nsw i32 %7, -1
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 32
br i1 %12, label %26, label %13
13: ; preds = %6
%14 = zext i32 %7 to i64
%15 = add nsw i64 %14, -1
br label %16
16: ; preds = %13, %16
%17 = phi i64 [ %15, %13 ], [ %20, %16 ]
%18 = phi i8 [ %11, %13 ], [ %22, %16 ]
%19 = call i32 @push(i8 signext %18)
%20 = add i64 %17, -1
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 32
br i1 %23, label %24, label %16
24: ; preds = %16
%25 = trunc i64 %20 to i32
br label %26
26: ; preds = %24, %6
%27 = phi i64 [ %9, %6 ], [ %20, %24 ]
%28 = phi i32 [ %8, %6 ], [ %25, %24 ]
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %27
%30 = call i32 (...) @pop_till_empty()
%31 = load i8, i8* %29
%32 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %31)
%33 = icmp sgt i32 %28, 0
br i1 %33, label %6, label %34
34: ; preds = %26, %0
ret void
}