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


x86 assembly (clang, -O0):
<reverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpl   $0x0,0x2f05(%rip)
jne    114b <reverse+0x2b>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,0x2eed(%rip)
mov    0x2ee3(%rip),%eax
cmp    0x2ee1(%rip),%eax
jge    11ca <reverse+0xaa>
mov    -0x8(%rbp),%rax
movslq 0x2ecc(%rip),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq 0x2ebe(%rip),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq 0x2eac(%rip),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq 0x2e9d(%rip),%rcx
mov    %dl,(%rax,%rcx,1)
mov    0x2e90(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e87(%rip)
mov    0x2e85(%rip),%eax
add    $0xffffffff,%eax
mov    %eax,0x2e7c(%rip)
mov    -0x8(%rbp),%rdi
call   1030 <reverse@plt>
jmp    11de <reverse+0xbe>
movl   $0x0,0x2e60(%rip)
movl   $0x0,0x2e5a(%rip)
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    113b <reverse+0x2b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <strlen@plt>
add    $0xffffffff,%eax
movslq 0x2eea(%rip),%rcx
cmp    %eax,%ecx
jge    1173 <reverse+0x63>
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,0x2ec8(%rip)
add    $0xffffffff,%eax
mov    %eax,0x2ec3(%rip)
test   %eax,%eax
jne    113b <reverse+0x2b>
jmp    1130 <reverse+0x20>
movl   $0x0,0x2eaf(%rip)
movl   $0x0,0x2ea9(%rip)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@reverse.i = internal global i32 0
@reverse.j = internal global i32 0
define void @reverse(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i32, i32* @reverse.j
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
%9 = sub nsw i32 %8, 1
store i32 %9, i32* @reverse.j
br label %10
10: ; preds = %6, %1
%11 = load i32, i32* @reverse.i
%12 = load i32, i32* @reverse.j
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %41
14: ; preds = %10
%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* %3
%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* %3
%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 %42
41: ; preds = %10
store i32 0, i32* @reverse.i
store i32 0, i32* @reverse.j
br label %42
42: ; preds = %41, %14
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
br label %9
9: ; preds = %6, %3
%10 = phi i32 [ %8, %6 ], [ %4, %3 ]
%11 = load i32, i32* @reverse.i
%12 = icmp slt i32 %11, %10
br i1 %12, label %13, label %22
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
store i32 0, i32* @reverse.i
store i32 0, i32* @reverse.j
ret void
}