void reverse(char string[]) {
  static int element, offset;
  char temporary_character;
  if (string[element] == '\0') {
    --element;
    return;
  } else {
    ++element;
    reverse(string);
  }
  if (element > offset) {
    temporary_character = string[element];
    string[element--] = string[offset];
    string[offset++] = temporary_character;
  } else
    element = offset = 0;
}


x86 assembly (clang, -O0):
<reverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movslq 0x2f05(%rip),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    1148 <reverse+0x38>
mov    0x2ef2(%rip),%eax
add    $0xffffffff,%eax
mov    %eax,0x2ee9(%rip)
jmp    11e3 <reverse+0xd3>
mov    0x2ede(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ed5(%rip)
mov    -0x8(%rbp),%rdi
call   1030 <reverse@plt>
mov    0x2ec6(%rip),%eax
cmp    0x2ec4(%rip),%eax
jle    11cf <reverse+0xbf>
mov    -0x8(%rbp),%rax
movslq 0x2eaf(%rip),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rax
movslq 0x2ea2(%rip),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    0x2e91(%rip),%ecx
mov    %ecx,%esi
add    $0xffffffff,%esi
mov    %esi,0x2e86(%rip)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x9(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    0x2e77(%rip),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,0x2e6c(%rip)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    11e3 <reverse+0xd3>
movl   $0x0,0x2e57(%rip)
movl   $0x0,0x2e49(%rip)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse>:
push   %rbx
movslq 0x2f14(%rip),%rax
cmpb   $0x0,(%rdi,%rax,1)
je     1163 <reverse+0x53>
mov    %rdi,%rbx
add    $0x1,%eax
mov    %eax,0x2f02(%rip)
call   1030 <reverse@plt>
movslq 0x2ef6(%rip),%rcx
movslq 0x2ef3(%rip),%rax
cmp    %eax,%ecx
jle    116e <reverse+0x5e>
mov    (%rbx,%rcx,1),%sil
mov    (%rbx,%rax,1),%dl
lea    -0x1(%rcx),%edi
mov    %edi,0x2edb(%rip)
mov    %dl,(%rbx,%rcx,1)
lea    0x1(%rax),%ecx
mov    %ecx,0x2ed3(%rip)
mov    %sil,(%rbx,%rax,1)
pop    %rbx
ret
add    $0xffffffff,%eax
mov    %eax,0x2ec0(%rip)
pop    %rbx
ret
movl   $0x0,0x2eb8(%rip)
movl   $0x0,0x2eaa(%rip)
pop    %rbx
ret

LLVM IR (-O0):
@reverse.element = internal global i32 0
@reverse.offset = 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.element
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i8, i8* %4, i64 %6
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load i32, i32* @reverse.element
%13 = add nsw i32 %12, -1
store i32 %13, i32* @reverse.element
br label %45
14: ; preds = %1
%15 = load i32, i32* @reverse.element
%16 = add nsw i32 %15, 1
store i32 %16, i32* @reverse.element
%17 = load i8*, i8** %2
br label %18
18: ; preds = %14
%19 = load i32, i32* @reverse.element
%20 = load i32, i32* @reverse.offset
%21 = icmp sgt i32 %19, %20
br i1 %21, label %22, label %44
22: ; preds = %18
%23 = load i8*, i8** %2
%24 = load i32, i32* @reverse.element
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
store i8 %27, i8* %3
%28 = load i8*, i8** %2
%29 = load i32, i32* @reverse.offset
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
%33 = load i8*, i8** %2
%34 = load i32, i32* @reverse.element
%35 = add nsw i32 %34, -1
store i32 %35, i32* @reverse.element
%36 = sext i32 %34 to i64
%37 = getelementptr inbounds i8, i8* %33, i64 %36
store i8 %32, i8* %37
%38 = load i8, i8* %3
%39 = load i8*, i8** %2
%40 = load i32, i32* @reverse.offset
%41 = add nsw i32 %40, 1
store i32 %41, i32* @reverse.offset
%42 = sext i32 %40 to i64
%43 = getelementptr inbounds i8, i8* %39, i64 %42
store i8 %38, i8* %43
br label %45
44: ; preds = %18
store i32 0, i32* @reverse.offset
store i32 0, i32* @reverse.element
br label %45
45: ; preds = %11, %44, %22
ret void
}

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