#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_recursive(char s[]) {
  static int index;
  char c = s[index];
  s[index] = s[strlen(s) - 1 - index];
  s[strlen(s) - 1 - index] = c;
  index++;
  if (index < strlen(s) / 2)
    reverse_recursive(s);
}


x86 assembly (clang, -O0):
<reverse_recursive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movslq 0x2efd(%rip),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
sub    $0x1,%ecx
sub    0x2ed7(%rip),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq 0x2ec6(%rip),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x9(%rbp),%al
mov    %al,-0x19(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x19(%rbp),%dl
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
sub    $0x1,%ecx
sub    0x2e9a(%rip),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    0x2e8e(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e85(%rip)
mov    0x2e7f(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jge    11df <reverse_recursive+0xbf>
mov    -0x8(%rbp),%rdi
call   1040 <reverse_recursive@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse_recursive>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
nopw   0x0(%rax,%rax,1)
movslq 0x2f05(%rip),%rax
movzbl (%rbx,%rax,1),%r14d
mov    %rbx,%rdi
call   1030 <strlen@plt>
movslq 0x2ef1(%rip),%rcx
mov    %ecx,%edx
not    %edx
add    %eax,%edx
movslq %edx,%rax
movzbl (%rbx,%rax,1),%eax
mov    %al,(%rbx,%rcx,1)
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    0x2ed3(%rip),%ebp
mov    %ebp,%ecx
not    %ecx
add    %eax,%ecx
movslq %ecx,%rax
mov    %r14b,(%rbx,%rax,1)
add    $0x1,%ebp
mov    %ebp,0x2ebd(%rip)
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
cmp    %ecx,%ebp
jl     1120 <reverse_recursive+0x10>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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