#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*/ assert(int);
int /*<<< orphan*/ swap(char *, char *);
void reverse_word(char *p, char *q) {
  assert((p != NULL) && (q != NULL));
  char *f = p;
  char *r = q;
  while (f < r) {
    swap(f, r);
    f++;
    r--;
  }
}


x86 assembly (clang, -O0):
<reverse_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x21(%rbp)
je     114b <reverse_word+0x2b>
cmpq   $0x0,-0x10(%rbp)
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11a0 <reverse_word+0x80>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <swap@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    1168 <reverse_word+0x48>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse_word>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
test   %rdi,%rdi
setne  %al
test   %rsi,%rsi
setne  %cl
and    %al,%cl
movzbl %cl,%edi
call   1030 <assert@plt>
cmp    %r14,%rbx
jae    1168 <reverse_word+0x48>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <swap@plt>
add    $0x1,%rbx
add    $0xffffffffffffffff,%r14
cmp    %r14,%rbx
jb     1150 <reverse_word+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @reverse_word(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = icmp ne i8* %10, null
br label %12
12: ; preds = %9, %2
%13 = phi i1 [ false, %2 ], [ %11, %9 ]
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load i8*, i8** %3
store i8* %16, i8** %5
%17 = load i8*, i8** %4
store i8* %17, i8** %6
br label %18
18: ; preds = %22, %12
%19 = load i8*, i8** %5
%20 = load i8*, i8** %6
%21 = icmp ult i8* %19, %20
br i1 %21, label %22, label %30
22: ; preds = %18
%23 = load i8*, i8** %5
%24 = load i8*, i8** %6
%25 = call i32 @swap(i8* %23, i8* %24)
%26 = load i8*, i8** %5
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %5
%28 = load i8*, i8** %6
%29 = getelementptr inbounds i8, i8* %28, i32 -1
store i8* %29, i8** %6
br label %18
30: ; preds = %18
ret void
}

LLVM IR (-O2):
define void @reverse_word(i8* %0, i8* %1) {
%3 = icmp ne i8* %0, null
%4 = icmp ne i8* %1, null
%5 = and i1 %3, %4
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = icmp ult i8* %0, %1
br i1 %8, label %9, label %16
9: ; preds = %2, %9
%10 = phi i8* [ %14, %9 ], [ %1, %2 ]
%11 = phi i8* [ %13, %9 ], [ %0, %2 ]
%12 = tail call i32 @swap(i8* %11, i8* %10)
%13 = getelementptr inbounds i8, i8* %11, i64 1
%14 = getelementptr inbounds i8, i8* %10, i64 -1
%15 = icmp ult i8* %13, %14
br i1 %15, label %9, label %16
16: ; preds = %9, %2
ret void
}