#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*/ rev_str(char *, char *);
void rev_word(char *str) {
  char *start = str;
  char *curr = str;
  while (*curr) {
    curr++;
    if (*curr == ' ') {
      rev_str(start, curr - 1);
      start = curr + 1;
    }
  }
  rev_str(start, curr - 1);
  rev_str(str, curr - 1);
}


x86 assembly (clang, -O0):
<rev_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1177 <rev_word+0x67>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1172 <rev_word+0x62>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0xffffffffffffffff,%rsi
call   1030 <rev_str@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    112c <rev_word+0x1c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0xffffffffffffffff,%rsi
call   1030 <rev_str@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0xffffffffffffffff,%rsi
call   1030 <rev_str@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rev_word>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
cmpb   $0x0,(%rdi)
mov    %rdi,%rbx
je     1156 <rev_word+0x46>
lea    0x2(%r14),%rbx
mov    %r14,%rdi
jmp    1138 <rev_word+0x28>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
test   %al,%al
je     1152 <rev_word+0x42>
movzbl -0x1(%rbx),%eax
cmp    $0x20,%al
jne    1130 <rev_word+0x20>
lea    -0x2(%rbx),%rsi
call   1030 <rev_str@plt>
movzbl -0x1(%rbx),%eax
mov    %rbx,%rdi
jmp    1130 <rev_word+0x20>
add    $0xfffffffffffffffe,%rbx
add    $0xffffffffffffffff,%rbx
mov    %rbx,%rsi
call   1030 <rev_str@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <rev_str@plt>

LLVM IR (-O0):
define void @rev_word(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
store i8* %5, i8** %3
%6 = load i8*, i8** %2
store i8* %6, i8** %4
br label %7
7: ; preds = %25, %1
%8 = load i8*, i8** %4
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %26
11: ; preds = %7
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %4
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 32
br i1 %17, label %18, label %25
18: ; preds = %11
%19 = load i8*, i8** %3
%20 = load i8*, i8** %4
%21 = getelementptr inbounds i8, i8* %20, i64 -1
%22 = call i32 @rev_str(i8* %19, i8* %21)
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 1
store i8* %24, i8** %3
br label %25
25: ; preds = %18, %11
br label %7
26: ; preds = %7
%27 = load i8*, i8** %3
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i64 -1
%30 = call i32 @rev_str(i8* %27, i8* %29)
%31 = load i8*, i8** %2
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i64 -1
%34 = call i32 @rev_str(i8* %31, i8* %33)
ret void
}

LLVM IR (-O2):
define void @rev_word(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %18, label %4
4: ; preds = %1, %14
%5 = phi i8* [ %7, %14 ], [ %0, %1 ]
%6 = phi i8* [ %16, %14 ], [ %0, %1 ]
%7 = getelementptr inbounds i8, i8* %5, i64 1
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 32
br i1 %9, label %10, label %14
10: ; preds = %4
%11 = tail call i32 @rev_str(i8* %6, i8* %5)
%12 = getelementptr inbounds i8, i8* %5, i64 2
%13 = load i8, i8* %7
br label %14
14: ; preds = %10, %4
%15 = phi i8 [ %13, %10 ], [ %8, %4 ]
%16 = phi i8* [ %12, %10 ], [ %6, %4 ]
%17 = icmp eq i8 %15, 0
br i1 %17, label %18, label %4
18: ; preds = %14, %1
%19 = phi i8* [ %0, %1 ], [ %16, %14 ]
%20 = phi i8* [ %0, %1 ], [ %7, %14 ]
%21 = getelementptr inbounds i8, i8* %20, i64 -1
%22 = tail call i32 @rev_str(i8* %19, i8* %21)
%23 = tail call i32 @rev_str(i8* %0, i8* %21)
ret void
}