#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 strlen(char *);
void reverse(char *s) {
  int c;
  char *t;
  for (t = s + (strlen(s) - 1); s < t; s++, t--) {
    c = *s;
    *s = *t;
    *t = c;
  }
}


x86 assembly (clang, -O0):
<reverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    118c <reverse+0x7c>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1140 <reverse+0x30>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x2,%eax
jl     114c <reverse+0x3c>
add    $0xffffffff,%eax
add    %rbx,%rax
add    $0x1,%rbx
nopl   0x0(%rax,%rax,1)
movzbl -0x1(%rbx),%ecx
movzbl (%rax),%edx
mov    %dl,-0x1(%rbx)
mov    %cl,(%rax)
add    $0xffffffffffffffff,%rax
lea    0x1(%rbx),%rcx
cmp    %rax,%rbx
mov    %rcx,%rbx
jb     1130 <reverse+0x20>
pop    %rbx
ret

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

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