#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 i;
  char c;
  c = s[i++];
  if (i < strlen(s))
    reverse(s);
  s[strlen(s) - i] = c;
  i--;
}


x86 assembly (clang, -O0):
<reverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2efe(%rip),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,0x2ef3(%rip)
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x9(%rbp)
mov    0x2ee4(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jge    1172 <reverse+0x52>
mov    -0x8(%rbp),%rdi
call   1030 <reverse@plt>
mov    -0x9(%rbp),%al
mov    %al,-0x19(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x19(%rbp),%dl
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
sub    0x2e9c(%rip),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    0x2e90(%rip),%eax
add    $0xffffffff,%eax
mov    %eax,0x2e87(%rip)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
movslq 0x2f06(%rip),%rax
lea    0x1(%rax),%ebp
mov    %ebp,0x2efd(%rip)
mov    (%rdi,%rax,1),%r14b
call   1040 <strlen@plt>
cmp    %eax,%ebp
jge    114c <reverse+0x2c>
mov    %rbx,%rdi
call   1030 <reverse@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    0x2eda(%rip),%ecx
sub    %ecx,%eax
cltq
mov    %r14b,(%rbx,%rax,1)
add    $0xffffffff,%ecx
mov    %ecx,0x2ec9(%rip)
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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