#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 string_rev(char a[100], int m) {
  if (m == 2)
    printf("%c", a[0]);
  else {
    printf("%c", a[m - 2]);
    string_rev(a, m - 1);
  }
}


x86 assembly (clang, -O0):
<string_rev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jne    1151 <string_rev+0x31>
mov    -0x8(%rbp),%rax
lea    0xebc(%rip),%rdi
movsbl (%rax),%esi
call   1030 <printf@plt>
jmp    117d <string_rev+0x5d>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
lea    0xe9b(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
sub    $0x1,%esi
call   1040 <string_rev@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_rev>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r14
cmp    $0x2,%esi
je     1156 <string_rev+0x46>
movslq %esi,%rax
lea    (%rax,%r14,1),%r12
add    $0xfffffffffffffffe,%r12
mov    $0x2,%r13d
sub    %esi,%r13d
xor    %ebx,%ebx
lea    0xec2(%rip),%r15
xchg   %ax,%ax
movsbl (%r12,%rbx,1),%esi
mov    %r15,%rdi
call   1030 <printf@plt>
add    $0xffffffffffffffff,%rbx
cmp    %ebx,%r13d
jne    1140 <string_rev+0x30>
movsbl (%r14),%esi
lea    0xe9f(%rip),%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <printf@plt>

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

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