#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_word(char *, char *);
void reverse_words(char *s) {
  if (!s) {
    return;
  }
  char *next = s;
  char *begin = next;
  char *end = next;
  while (*next != '\0') {
    begin = next;
    for (; *next != ' ' && *next != '\0'; ++next) {
    }
    end = next - 1;
    reverse_word(begin, end);
    for (; *next == ' '; ++next) {
    }
  }
}


x86 assembly (clang, -O0):
<reverse_words>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    112c <reverse_words+0x1c>
jmp    11eb <reverse_words+0xdb>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11eb <reverse_words+0xdb>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x21(%rbp)
je     1181 <reverse_words+0x71>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1191 <reverse_words+0x81>
jmp    11a7 <reverse_words+0x97>
jmp    1196 <reverse_words+0x86>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    115c <reverse_words+0x4c>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <reverse_word@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    11e6 <reverse_words+0xd6>
jmp    11d5 <reverse_words+0xc5>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11c0 <reverse_words+0xb0>
jmp    1144 <reverse_words+0x34>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse_words>:
push   %rbx
test   %rdi,%rdi
je     115e <reverse_words+0x4e>
mov    (%rdi),%al
test   %al,%al
je     115e <reverse_words+0x4e>
lea    -0x1(%rdi),%rbx
mov    %rdi,%rsi
test   $0xdf,%al
je     1140 <reverse_words+0x30>
nopw   0x0(%rax,%rax,1)
movzbl 0x1(%rsi),%eax
add    $0x1,%rsi
add    $0x1,%rbx
test   $0xdf,%al
jne    1130 <reverse_words+0x20>
add    $0xffffffffffffffff,%rsi
call   1030 <reverse_word@plt>
mov    %rbx,%rdi
nopl   0x0(%rax)
movzbl 0x1(%rdi),%eax
add    $0x1,%rdi
cmp    $0x20,%al
je     1150 <reverse_words+0x40>
jmp    1118 <reverse_words+0x8>
pop    %rbx
ret

LLVM IR (-O0):
define void @reverse_words(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = icmp ne i8* %6, null
br i1 %7, label %9, label %8
8: ; preds = %1
br label %52
9: ; preds = %1
%10 = load i8*, i8** %2
store i8* %10, i8** %3
%11 = load i8*, i8** %3
store i8* %11, i8** %4
%12 = load i8*, i8** %3
store i8* %12, i8** %5
br label %13
13: ; preds = %51, %9
%14 = load i8*, i8** %3
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %52
18: ; preds = %13
%19 = load i8*, i8** %3
store i8* %19, i8** %4
br label %20
20: ; preds = %33, %18
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 32
br i1 %24, label %25, label %30
25: ; preds = %20
%26 = load i8*, i8** %3
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 0
br label %30
30: ; preds = %25, %20
%31 = phi i1 [ false, %20 ], [ %29, %25 ]
br i1 %31, label %32, label %36
32: ; preds = %30
br label %33
33: ; preds = %32
%34 = load i8*, i8** %3
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %3
br label %20
36: ; preds = %30
%37 = load i8*, i8** %3
%38 = getelementptr inbounds i8, i8* %37, i64 -1
store i8* %38, i8** %5
%39 = load i8*, i8** %4
%40 = load i8*, i8** %5
%41 = call i32 @reverse_word(i8* %39, i8* %40)
br label %42
42: ; preds = %48, %36
%43 = load i8*, i8** %3
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 32
br i1 %46, label %47, label %51
47: ; preds = %42
br label %48
48: ; preds = %47
%49 = load i8*, i8** %3
%50 = getelementptr inbounds i8, i8* %49, i32 1
store i8* %50, i8** %3
br label %42
51: ; preds = %42
br label %13
52: ; preds = %8, %13
ret void
}

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