#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, j;
  for (i = 0; s[i]; i++)
    ;
  for (j = (i - 1); s[j]; j--)
    _putchar(s[j]);
  _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
cmpb   $0x0,(%rax,%rcx,1)
je     1148 <print_rev+0x38>
jmp    113a <print_rev+0x2a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <print_rev+0x13>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1182 <print_rev+0x72>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <_putchar@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1151 <print_rev+0x41>
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
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %5
5: ; preds = %13, %1
%6 = load i8*, i8** %2
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %5
br label %13
13: ; preds = %12
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %5
16: ; preds = %5
%17 = load i32, i32* %3
%18 = sub nsw i32 %17, 1
store i32 %18, i32* %4
br label %19
19: ; preds = %33, %16
%20 = load i8*, i8** %2
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = icmp ne i8 %24, 0
br i1 %25, label %26, label %36
26: ; preds = %19
%27 = load i8*, i8** %2
%28 = load i32, i32* %4
%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)
br label %33
33: ; preds = %26
%34 = load i32, i32* %4
%35 = add nsw i32 %34, -1
store i32 %35, i32* %4
br label %19
36: ; preds = %19
%37 = 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
}