#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*/ strrev(char *, int, int);
void str_words_in_rev(char *input, int len) {
  int start = 0, end = 0;
  strrev(input, 0, len - 1);
  while (input[end] != '\0') {
    end++;
    while (input[end] != ' ' && input[end] != '\0') {
      end++;
    }
    strrev(input, start, end - 1);
    start = end + 1;
  }
}


x86 assembly (clang, -O0):
<str_words_in_rev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1030 <strrev@plt>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11c9 <str_words_in_rev+0xb9>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x15(%rbp)
je     118b <str_words_in_rev+0x7b>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    119b <str_words_in_rev+0x8b>
jmp    11a9 <str_words_in_rev+0x99>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115c <str_words_in_rev+0x4c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
call   1030 <strrev@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113e <str_words_in_rev+0x2e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_words_in_rev>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
lea    -0x1(%rsi),%edx
xor    %r14d,%r14d
xor    %esi,%esi
call   1030 <strrev@plt>
cmpb   $0x0,(%r12)
je     117e <str_words_in_rev+0x6e>
movabs $0x100000000,%r15
xor    %r13d,%r13d
nop
mov    %r13,%rbx
shl    $0x20,%rbx
movslq %r13d,%r13
lea    0x1(%r13),%ebp
xchg   %ax,%ax
add    %r15,%rbx
add    $0x1,%ebp
testb  $0xdf,0x1(%r12,%r13,1)
lea    0x1(%r13),%r13
jne    1150 <str_words_in_rev+0x40>
lea    -0x2(%rbp),%edx
mov    %r12,%rdi
mov    %r14d,%esi
call   1030 <strrev@plt>
sar    $0x20,%rbx
cmpb   $0x0,(%r12,%rbx,1)
mov    %ebp,%r14d
jne    1140 <str_words_in_rev+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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