#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*/ reverse(char *, char *);
void reverse_sentence(char *sentence) {
  char *begin = sentence, *temp = sentence;
  while (*temp) {
    *temp++;
    if (*temp == '\0') {
      reverse(begin, temp - 1);
    } else if (*temp == ' ') {
      reverse(begin, temp - 1);
      begin = temp + 1;
    }
  }
  reverse(sentence, temp - 1);
}


x86 assembly (clang, -O0):
<reverse_sentence>:
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     11a2 <reverse_sentence+0x92>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    116b <reverse_sentence+0x5b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0xffffffffffffffff,%rsi
call   1030 <reverse@plt>
jmp    119d <reverse_sentence+0x8d>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1198 <reverse_sentence+0x88>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0xffffffffffffffff,%rsi
call   1030 <reverse@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    119d <reverse_sentence+0x8d>
jmp    112c <reverse_sentence+0x1c>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0xffffffffffffffff,%rsi
call   1030 <reverse@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse_sentence>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
cmpb   $0x0,(%rdi)
mov    %rdi,%rbx
je     1165 <reverse_sentence+0x55>
lea    0x2(%r14),%rbx
mov    %r14,%r15
jmp    1147 <reverse_sentence+0x37>
nopl   0x0(%rax)
mov    %r15,%rdi
call   1030 <reverse@plt>
mov    %rbx,%r15
movzbl -0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1161 <reverse_sentence+0x51>
lea    -0x2(%rbx),%rsi
movzbl -0x1(%rbx),%eax
cmp    $0x20,%al
je     1130 <reverse_sentence+0x20>
test   %al,%al
jne    113f <reverse_sentence+0x2f>
mov    %r15,%rdi
call   1030 <reverse@plt>
jmp    113b <reverse_sentence+0x2b>
add    $0xfffffffffffffffe,%rbx
add    $0xffffffffffffffff,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <reverse@plt>

LLVM IR (-O0):
define void @reverse_sentence(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 = %37, %1
%8 = load i8*, i8** %4
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %38
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* %12
%15 = load i8*, i8** %4
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %11
%20 = load i8*, i8** %3
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i64 -1
%23 = call i32 @reverse(i8* %20, i8* %22)
br label %37
24: ; preds = %11
%25 = load i8*, i8** %4
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 32
br i1 %28, label %29, label %36
29: ; preds = %24
%30 = load i8*, i8** %3
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i64 -1
%33 = call i32 @reverse(i8* %30, i8* %32)
%34 = load i8*, i8** %4
%35 = getelementptr inbounds i8, i8* %34, i64 1
store i8* %35, i8** %3
br label %36
36: ; preds = %29, %24
br label %37
37: ; preds = %36, %19
br label %7
38: ; preds = %7
%39 = load i8*, i8** %2
%40 = load i8*, i8** %4
%41 = getelementptr inbounds i8, i8* %40, i64 -1
%42 = call i32 @reverse(i8* %39, i8* %41)
ret void
}

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