#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdin;
int strlen(char *);
char *strtok(char *, char *);
int main() {
  char str[90];
  char *words[90];
  int n = 0;
  fgets(str, 90, stdin);
  str[strlen(str) - 1] = '\0';
  char *pos = NULL;
  pos = strtok(str, " ");
  words[n++] = pos;
  while ((pos = strtok(NULL, " ")) != NULL) {
    words[n++] = pos;
  }
  for (int i = n - 1; i > 0; i--)
    printf("%s ", words[i]);
  printf("%s", words[0]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x350,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x334(%rbp)
lea    -0x60(%rbp),%rdi
mov    0x2e81(%rip),%rax
mov    (%rax),%edx
mov    $0x5a,%esi
call   1050 <fgets@plt>
lea    -0x60(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x60(%rbp,%rax,1)
movq   $0x0,-0x340(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x340(%rbp)
mov    -0x340(%rbp),%rcx
mov    -0x334(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x334(%rbp)
cltq
mov    %rcx,-0x330(%rbp,%rax,8)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0xe2d(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x340(%rbp)
cmp    $0x0,%rax
je     1212 <main+0xd2>
mov    -0x340(%rbp),%rcx
mov    -0x334(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x334(%rbp)
cltq
mov    %rcx,-0x330(%rbp,%rax,8)
ff
jmp    11ca <main+0x8a>
mov    -0x334(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x344(%rbp)
cmpl   $0x0,-0x344(%rbp)
jle    125d <main+0x11d>
movslq -0x344(%rbp),%rax
mov    -0x330(%rbp,%rax,8),%rsi
ff
lea    0xdbc(%rip),%rdi
call   1040 <printf@plt>
mov    -0x344(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x344(%rbp)
jmp    1221 <main+0xe1>
mov    -0x330(%rbp),%rsi
lea    0xd99(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x350,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x330,%rsp
mov    0x2e95(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x5a,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
lea    0xe87(%rip),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strtok@plt>
mov    %rax,%r14
mov    %rax,0x60(%rsp)
xor    %edi,%edi
mov    %r15,%rsi
call   1060 <strtok@plt>
test   %rax,%rax
je     11fa <main+0xba>
mov    $0x1,%ebx
lea    0xe59(%rip),%r15
nopl   0x0(%rax)
mov    %rax,0x60(%rsp,%rbx,8)
add    $0x1,%rbx
xor    %edi,%edi
mov    %r15,%rsi
call   1060 <strtok@plt>
test   %rax,%rax
jne    11b0 <main+0x70>
cmp    $0x2,%ebx
jl     11fa <main+0xba>
mov    %ebx,%ebx
add    $0x1,%rbx
lea    0xe26(%rip),%r15
nopw   0x0(%rax,%rax,1)
lea    -0x2(%rbx),%eax
mov    0x60(%rsp,%rax,8),%rsi
mov    %r15,%rdi
call   1040 <printf@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x2,%rbx
ja     11e0 <main+0xa0>
lea    0xe03(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x330,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [2 x i8] c" \00"
@.str.1 = [4 x i8] c"%s \00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [90 x i8]
%3 = alloca [90 x i8*]
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%7 = getelementptr inbounds [90 x i8], [90 x i8]* %2, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 90, i32 %8)
%10 = getelementptr inbounds [90 x i8], [90 x i8]* %2, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
%12 = sub nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [90 x i8], [90 x i8]* %2, i64 0, i64 %13
store i8 0, i8* %14
store i8* null, i8** %5
%15 = getelementptr inbounds [90 x i8], [90 x i8]* %2, i64 0, i64 0
%16 = call i8* @strtok(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %16, i8** %5
%17 = load i8*, i8** %5
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
%20 = sext i32 %18 to i64
%21 = getelementptr inbounds [90 x i8*], [90 x i8*]* %3, i64 0, i64 %20
store i8* %17, i8** %21
br label %22
22: ; preds = %25, %0
%23 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %23, i8** %5
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %31
25: ; preds = %22
%26 = load i8*, i8** %5
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
%29 = sext i32 %27 to i64
%30 = getelementptr inbounds [90 x i8*], [90 x i8*]* %3, i64 0, i64 %29
store i8* %26, i8** %30
br label %22
31: ; preds = %22
%32 = load i32, i32* %4
%33 = sub nsw i32 %32, 1
store i32 %33, i32* %6
br label %34
34: ; preds = %43, %31
%35 = load i32, i32* %6
%36 = icmp sgt i32 %35, 0
br i1 %36, label %37, label %46
37: ; preds = %34
%38 = load i32, i32* %6
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [90 x i8*], [90 x i8*]* %3, i64 0, i64 %39
%41 = load i8*, i8** %40
%42 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %41)
br label %43
43: ; preds = %37
%44 = load i32, i32* %6
%45 = add nsw i32 %44, -1
store i32 %45, i32* %6
br label %34
46: ; preds = %34
%47 = getelementptr inbounds [90 x i8*], [90 x i8*]* %3, i64 0, i64 0
%48 = load i8*, i8** %47
%49 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %48)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [2 x i8] c" \00"
@.str.1 = [4 x i8] c"%s \00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [90 x i8]
%2 = alloca [90 x i8*]
%3 = getelementptr inbounds [90 x i8], [90 x i8]* %1, i64 0, i64 0
%4 = bitcast [90 x i8*]* %2 to i8*
%5 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %3, i32 90, i32 %5)
%7 = call i32 @strlen(i8* %3)
%8 = add nsw i32 %7, -1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [90 x i8], [90 x i8]* %1, i64 0, i64 %9
store i8 0, i8* %10
%11 = call i8* @strtok(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = getelementptr inbounds [90 x i8*], [90 x i8*]* %2, i64 0, i64 0
store i8* %11, i8** %12
%13 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i8* %13, null
br i1 %14, label %27, label %20
15: ; preds = %20
%16 = trunc i64 %23 to i32
%17 = icmp sgt i32 %16, 1
br i1 %17, label %18, label %27
18: ; preds = %15
%19 = and i64 %23, 4294967295
br label %29
20: ; preds = %0, %20
%21 = phi i64 [ %23, %20 ], [ 1, %0 ]
%22 = phi i8* [ %25, %20 ], [ %13, %0 ]
%23 = add nuw i64 %21, 1
%24 = getelementptr inbounds [90 x i8*], [90 x i8*]* %2, i64 0, i64 %21
store i8* %22, i8** %24
%25 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%26 = icmp eq i8* %25, null
br i1 %26, label %15, label %20
27: ; preds = %29, %0, %15
%28 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %11)
ret i32 0
29: ; preds = %18, %29
%30 = phi i64 [ %19, %18 ], [ %31, %29 ]
%31 = add nsw i64 %30, -1
%32 = and i64 %31, 4294967295
%33 = getelementptr inbounds [90 x i8*], [90 x i8*]* %2, i64 0, i64 %32
%34 = load i8*, i8** %33
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %34)
%36 = icmp ugt i64 %30, 2
br i1 %36, label %29, label %27
}