#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*/ swap(char *, char *);
void reverse(char *str) {
  char *end;
  for (end = str; *end; ++end)
    ;
  --end;
  while (str < end) {
    swap(str, end);
    ++str;
    --end;
  }
}


x86 assembly (clang, -O0):
<reverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1147 <reverse+0x37>
jmp    1136 <reverse+0x26>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1124 <reverse+0x14>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    118b <reverse+0x7b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <swap@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1153 <reverse+0x43>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    -0x2(%rdi),%rbx
nopl   0x0(%rax,%rax,1)
cmpb   $0x0,0x2(%rbx)
lea    0x1(%rbx),%rbx
jne    1120 <reverse+0x10>
cmp    %r14,%rbx
jbe    1148 <reverse+0x38>
nop
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <swap@plt>
add    $0x1,%r14
add    $0xffffffffffffffff,%rbx
cmp    %rbx,%r14
jb     1130 <reverse+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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