#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 /*<<< orphan*/ printf(char *, char);
void print_rev(char s[], int slength, int i) {
  if (i > (slength - 2))
    return;
  if (i == (slength - 2)) {
    printf("%c", s[i]);
    return;
  } else {
    print_rev(s, slength, i + 1);
    printf("%c", s[i]);
  }
}


x86 assembly (clang, -O0):
<print_rev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jle    1148 <print_rev+0x28>
jmp    11a0 <print_rev+0x80>
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jne    1176 <print_rev+0x56>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
lea    0xe98(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1030 <printf@plt>
jmp    11a0 <print_rev+0x80>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
add    $0x1,%edx
call   1040 <print_rev@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
lea    0xe69(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_rev>:
lea    -0x2(%rsi),%eax
cmp    %edx,%eax
jge    1128 <print_rev+0x8>
ret
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %rdi,%r14
je     113e <print_rev+0x1e>
lea    0x1(%rbx),%edx
mov    %r14,%rdi
call   1040 <print_rev@plt>
movslq %ebx,%rax
movsbl (%r14,%rax,1),%esi
lea    0xeb3(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
define void @print_rev(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %6
%8 = load i32, i32* %5
%9 = sub nsw i32 %8, 2
%10 = icmp sgt i32 %7, %9
br i1 %10, label %11, label %12
11: ; preds = %3
br label %35
12: ; preds = %3
%13 = load i32, i32* %6
%14 = load i32, i32* %5
%15 = sub nsw i32 %14, 2
%16 = icmp eq i32 %13, %15
br i1 %16, label %17, label %24
17: ; preds = %12
%18 = load i8*, i8** %4
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %22)
br label %35
24: ; preds = %12
%25 = load i8*, i8** %4
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
%29 = load i8*, i8** %4
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %33)
br label %35
35: ; preds = %11, %17, %24
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define void @print_rev(i8* nocapture %0, i32 %1, i32 %2) {
%4 = add nsw i32 %1, -2
%5 = icmp slt i32 %4, %2
br i1 %5, label %13, label %6
6: ; preds = %3
%7 = icmp eq i32 %4, %2
br i1 %7, label %8, label %14
8: ; preds = %6, %14
%9 = sext i32 %2 to i64
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
%12 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %11)
br label %13
13: ; preds = %8, %3
ret void
14: ; preds = %6
%15 = add nsw i32 %2, 1
tail call void @print_rev(i8* %0, i32 %1, i32 %15)
br label %8
}