#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 PrintInReverse(char *s) {
  char *currChar;
  for (currChar = s; *currChar; currChar++)
    ;
  for (currChar--; currChar != s; currChar--)
    printf("%c", *currChar);
  printf("%c\n", *currChar);
}


x86 assembly (clang, -O0):
<PrintInReverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1147 <PrintInReverse+0x37>
jmp    1136 <PrintInReverse+0x26>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1124 <PrintInReverse+0x14>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
je     1185 <PrintInReverse+0x75>
mov    -0x10(%rbp),%rax
lea    0xe94(%rip),%rdi
movsbl (%rax),%esi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1153 <PrintInReverse+0x43>
mov    -0x10(%rbp),%rax
lea    0xe73(%rip),%rdi
movsbl (%rax),%esi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintInReverse>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
mov    $0xfffffffffffffffe,%rbx
nop
cmpb   $0x0,0x2(%r15,%rbx,1)
lea    0x1(%rbx),%rbx
jne    1120 <PrintInReverse+0x10>
test   %rbx,%rbx
je     1153 <PrintInReverse+0x43>
lea    0xec8(%rip),%r14
nopl   0x0(%rax,%rax,1)
movsbl (%r15,%rbx,1),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0xffffffffffffffff,%rbx
jne    1140 <PrintInReverse+0x30>
movsbl (%r15),%esi
lea    0xea5(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [4 x i8] c"%c\0A\00"
define void @PrintInReverse(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
store i8* %4, i8** %3
br label %5
5: ; preds = %10, %1
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %5
br label %10
10: ; preds = %9
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i32 1
store i8* %12, i8** %3
br label %5
13: ; preds = %5
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i32 -1
store i8* %15, i8** %3
br label %16
16: ; preds = %24, %13
%17 = load i8*, i8** %3
%18 = load i8*, i8** %2
%19 = icmp ne i8* %17, %18
br i1 %19, label %20, label %27
20: ; preds = %16
%21 = load i8*, i8** %3
%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 %24
24: ; preds = %20
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i32 -1
store i8* %26, i8** %3
br label %16
27: ; preds = %16
%28 = load i8*, i8** %3
%29 = load i8, i8* %28
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8 signext %29)
ret void
}

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