#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*/ _putchar(char);
void print_rev(char *s) {
  int i = 0;
  while (s[i] != '\0') {
    i++;
  }
  i--;
  while (s[i] != '\0') {
    _putchar(s[i]);
    i--;
  }
  _putchar('\n');
}


x86 assembly (clang, -O0):
<print_rev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1146 <print_rev+0x36>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <print_rev+0x13>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1183 <print_rev+0x73>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <_putchar@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    114f <print_rev+0x3f>
mov    $0xa,%edi
call   1030 <_putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_rev>:
push   %rbx
mov    $0xffffffff,%eax
movabs $0xfffffffe00000000,%rcx
ff ff ff
movabs $0x100000000,%rdx
mov    %rdi,%rsi
nopl   (%rax)
add    %rdx,%rcx
add    $0x1,%eax
cmpb   $0x0,(%rsi)
lea    0x1(%rsi),%rsi
jne    1130 <print_rev+0x20>
sar    $0x20,%rcx
mov    (%rdi,%rcx,1),%cl
test   %cl,%cl
je     1173 <print_rev+0x63>
cltq
lea    (%rdi,%rax,1),%rbx
add    $0xfffffffffffffffe,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %cl,%edi
call   1030 <_putchar@plt>
movzbl (%rbx),%ecx
add    $0xffffffffffffffff,%rbx
test   %cl,%cl
jne    1160 <print_rev+0x50>
mov    $0xa,%edi
pop    %rbx
jmp    1030 <_putchar@plt>

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

LLVM IR (-O2):
define void @print_rev(i8* nocapture %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i64 [ %7, %2 ], [ 0, %1 ]
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 0
%7 = add nuw i64 %3, 1
br i1 %6, label %8, label %2
8: ; preds = %2
%9 = shl i64 %3, 32
%10 = add i64 %9, -4294967296
%11 = ashr exact i64 %10, 32
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %27, label %15
15: ; preds = %8
%16 = shl i64 %3, 32
%17 = ashr exact i64 %16, 32
%18 = add nsw i64 %17, -1
br label %19
19: ; preds = %15, %19
%20 = phi i64 [ %18, %15 ], [ %23, %19 ]
%21 = phi i8 [ %13, %15 ], [ %25, %19 ]
%22 = tail call i32 @_putchar(i8 signext %21)
%23 = add i64 %20, -1
%24 = getelementptr inbounds i8, i8* %0, i64 %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %27, label %19
27: ; preds = %19, %8
%28 = tail call i32 @_putchar(i8 signext 10)
ret void
}