#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*/ exchange(char *, char *);
void rev(char *s) {
  int len = 0;
  while (s[len])
    len++;
  for (int i = 0; i < len / 2; i++)
    exchange(&s[i], &s[len - 1 - i]);
}


x86 assembly (clang, -O0):
<rev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1143 <rev+0x33>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <rev+0x13>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jge    1198 <rev+0x88>
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
sub    -0x10(%rbp),%eax
cltq
add    %rax,%rsi
call   1030 <exchange@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114a <rev+0x3a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rev>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0xffffffffffffffff,%rax
nop
cmpb   $0x0,0x1(%r14,%rax,1)
lea    0x1(%rax),%rax
jne    1120 <rev+0x10>
test   $0xfffffffe,%eax
je     1169 <rev+0x59>
movslq %eax,%r15
lea    (%r14,%r15,1),%rbx
add    $0xffffffffffffffff,%rbx
shr    %r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <exchange@plt>
add    $0x1,%r14
add    $0xffffffffffffffff,%rbx
add    $0xffffffffffffffff,%r15
jne    1150 <rev+0x40>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @rev(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %5
5: ; preds = %12, %1
%6 = load i8*, i8** %2
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %5
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
store i32 %14, i32* %3
br label %5
15: ; preds = %5
store i32 0, i32* %4
br label %16
16: ; preds = %34, %15
%17 = load i32, i32* %4
%18 = load i32, i32* %3
%19 = sdiv i32 %18, 2
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %37
21: ; preds = %16
%22 = load i8*, i8** %2
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8*, i8** %2
%27 = load i32, i32* %3
%28 = sub nsw i32 %27, 1
%29 = load i32, i32* %4
%30 = sub nsw i32 %28, %29
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %26, i64 %31
%33 = call i32 @exchange(i8* %25, i8* %32)
br label %34
34: ; preds = %21
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %16
37: ; preds = %16
ret void
}

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