#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*/ printf(char *, char);
int /*<<< orphan*/ rev(char *, char *);
void revword(char *str) {
  char *end = str;
  char tmp;
  if (str) {
    while (*end != ' ') {
      printf("chars: %c \n", *end);
      ++end;
    }
    --end;
    rev(str, end);
    while (*end == ' ') {
      ++end;
    }
    ++end;
    str = end;
  }
}


x86 assembly (clang, -O0):
<revword>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11c6 <revword+0xa6>
jmp    1144 <revword+0x24>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     1178 <revword+0x58>
mov    -0x10(%rbp),%rax
lea    0xea1(%rip),%rdi
movsbl (%rax),%esi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1144 <revword+0x24>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <rev@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    11b2 <revword+0x92>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1191 <revword+0x71>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<revword>:
test   %rdi,%rdi
je     116b <revword+0x4b>
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    (%rdi),%al
mov    %rdi,%rbx
cmp    $0x20,%al
je     1157 <revword+0x37>
lea    0xec3(%rip),%r15
mov    %r14,%rbx
movsbl %al,%esi
mov    %r15,%rdi
call   1040 <printf@plt>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
cmp    $0x20,%al
jne    1140 <revword+0x20>
add    $0xffffffffffffffff,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <rev@plt>
ret

LLVM IR (-O0):
@.str = [12 x i8] c"chars: %c \0A\00"
define void @revword(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
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %38
8: ; preds = %1
br label %9
9: ; preds = %14, %8
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 32
br i1 %13, label %14, label %20
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8 signext %16)
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %3
br label %9
20: ; preds = %9
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i32 -1
store i8* %22, i8** %3
%23 = load i8*, i8** %2
%24 = load i8*, i8** %3
%25 = call i32 @rev(i8* %23, i8* %24)
br label %26
26: ; preds = %31, %20
%27 = load i8*, i8** %3
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 32
br i1 %30, label %31, label %34
31: ; preds = %26
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %3
br label %26
34: ; preds = %26
%35 = load i8*, i8** %3
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %3
%37 = load i8*, i8** %3
store i8* %37, i8** %2
br label %38
38: ; preds = %34, %1
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"chars: %c \0A\00"
define void @revword(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %17, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 32
br i1 %5, label %13, label %6
6: ; preds = %3, %6
%7 = phi i8 [ %11, %6 ], [ %4, %3 ]
%8 = phi i8* [ %10, %6 ], [ %0, %3 ]
%9 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8 signext %7)
%10 = getelementptr inbounds i8, i8* %8, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 32
br i1 %12, label %13, label %6
13: ; preds = %6, %3
%14 = phi i8* [ %0, %3 ], [ %10, %6 ]
%15 = getelementptr inbounds i8, i8* %14, i64 -1
%16 = tail call i32 @rev(i8* %0, i8* %15)
br label %17
17: ; preds = %13, %1
ret void
}