#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[]) {
  static int c, i, j;
  if (j == 0)
    j = strlen(s) - 1;
  if (i == j)
    return;
  c = s[i];
  s[i] = s[j];
  s[j] = c;
  i++;
  j--;
  reverse(s);
}


x86 assembly (clang, -O0):
<reverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpl   $0x0,0x2f09(%rip)
jne    114b <reverse+0x2b>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,0x2ef1(%rip)
mov    0x2ee7(%rip),%eax
cmp    0x2ee5(%rip),%eax
jne    1162 <reverse+0x42>
jmp    11d0 <reverse+0xb0>
mov    -0x8(%rbp),%rax
movslq 0x2ecb(%rip),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,0x2ebd(%rip)
mov    -0x8(%rbp),%rax
movslq 0x2eba(%rip),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq 0x2ea8(%rip),%rcx
mov    %dl,(%rax,%rcx,1)
mov    0x2e9b(%rip),%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq 0x2e96(%rip),%rcx
mov    %dl,(%rax,%rcx,1)
mov    0x2e89(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e80(%rip)
mov    0x2e7e(%rip),%eax
add    $0xffffffff,%eax
mov    %eax,0x2e75(%rip)
mov    -0x8(%rbp),%rdi
call   1030 <reverse@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2f13(%rip),%eax
test   %eax,%eax
jne    1141 <reverse+0x31>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <strlen@plt>
add    $0xffffffff,%eax
mov    %eax,0x2eef(%rip)
movslq 0x2ee4(%rip),%rcx
cmp    %eax,%ecx
je     1179 <reverse+0x69>
movzbl (%r14,%rcx,1),%edx
movslq %eax,%rsi
movzbl (%r14,%rsi,1),%ebx
mov    %bl,(%r14,%rcx,1)
mov    %dl,(%r14,%rsi,1)
add    $0x1,%ecx
mov    %ecx,0x2ec2(%rip)
add    $0xffffffff,%eax
mov    %eax,0x2ebd(%rip)
test   %eax,%eax
jne    1141 <reverse+0x31>
jmp    1130 <reverse+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@reverse.c = internal global i32 0
@reverse.i = internal global i32 0
@reverse.j = internal global i32 0
define void @reverse(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i32, i32* @reverse.j
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
%8 = sub nsw i32 %7, 1
store i32 %8, i32* @reverse.j
br label %9
9: ; preds = %5, %1
%10 = load i32, i32* @reverse.i
%11 = load i32, i32* @reverse.j
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %14
13: ; preds = %9
br label %41
14: ; preds = %9
%15 = load i8*, i8** %2
%16 = load i32, i32* @reverse.i
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
store i32 %20, i32* @reverse.c
%21 = load i8*, i8** %2
%22 = load i32, i32* @reverse.j
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = load i8*, i8** %2
%27 = load i32, i32* @reverse.i
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
store i8 %25, i8* %29
%30 = load i32, i32* @reverse.c
%31 = trunc i32 %30 to i8
%32 = load i8*, i8** %2
%33 = load i32, i32* @reverse.j
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
store i8 %31, i8* %35
%36 = load i32, i32* @reverse.i
%37 = add nsw i32 %36, 1
store i32 %37, i32* @reverse.i
%38 = load i32, i32* @reverse.j
%39 = add nsw i32 %38, -1
store i32 %39, i32* @reverse.j
%40 = load i8*, i8** %2
br label %41
41: ; preds = %14, %13
ret void
}

LLVM IR (-O2):
@reverse.i = internal unnamed_addr global i32 0
@reverse.j = internal unnamed_addr global i32 0
define void @reverse(i8* %0) {
%2 = load i32, i32* @reverse.j
br label %3
3: ; preds = %13, %1
%4 = phi i32 [ %21, %13 ], [ %2, %1 ]
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = tail call i32 @strlen(i8* %0)
%8 = add nsw i32 %7, -1
store i32 %8, i32* @reverse.j
br label %9
9: ; preds = %6, %3
%10 = phi i32 [ %8, %6 ], [ %4, %3 ]
%11 = load i32, i32* @reverse.i
%12 = icmp eq i32 %11, %10
br i1 %12, label %22, label %13
13: ; preds = %9
%14 = sext i32 %11 to i64
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = load i8, i8* %15
%17 = sext i32 %10 to i64
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = load i8, i8* %18
store i8 %19, i8* %15
store i8 %16, i8* %18
%20 = add nsw i32 %11, 1
store i32 %20, i32* @reverse.i
%21 = add nsw i32 %10, -1
store i32 %21, i32* @reverse.j
br label %3
22: ; preds = %9
ret void
}