#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 _strlen(char *);
int /*<<< orphan*/ printf(char *, char *);
void duasStrings(char s[]) {
  char aux[255];
  int i, j = 0;
  i = _strlen(s) - 1;
  while ((i >= 0) && (s[j] != '\0')) {
    aux[i] = s[j];
    --i;
    j++;
  }
  aux[j] = '\0';
  printf("\n\nA string normal: %s\n", s);
  printf("String de tras para frente: %s\n\n", aux);
}


x86 assembly (clang, -O0):
<duasStrings>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x118(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <_strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x114(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x114(%rbp)
mov    %al,-0x119(%rbp)
jl     117b <duasStrings+0x5b>
mov    -0x8(%rbp),%rax
movslq -0x118(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x119(%rbp)
mov    -0x119(%rbp),%al
test   $0x1,%al
jne    118e <duasStrings+0x6e>
jmp    11cd <duasStrings+0xad>
mov    -0x8(%rbp),%rax
movslq -0x118(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x114(%rbp),%rax
mov    %cl,-0x110(%rbp,%rax,1)
mov    -0x114(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x114(%rbp)
mov    -0x118(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x118(%rbp)
jmp    114b <duasStrings+0x2b>
movslq -0x118(%rbp),%rax
movb   $0x0,-0x110(%rbp,%rax,1)
mov    -0x8(%rbp),%rsi
lea    0xe19(%rip),%rdi
call   1040 <printf@plt>
lea    -0x110(%rbp),%rsi
lea    0xe1d(%rip),%rdi
call   1040 <printf@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<duasStrings>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%r14
call   1030 <_strlen@plt>
test   %eax,%eax
jle    1170 <duasStrings+0x50>
mov    %eax,%ecx
mov    %rcx,%rdx
neg    %rdx
add    $0xffffffffffffffff,%rcx
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%r14,%rsi,1),%ebx
test   %bl,%bl
je     1174 <duasStrings+0x54>
mov    %ecx,%edi
mov    %bl,(%rsp,%rdi,1)
add    $0x1,%rsi
add    $0xffffffffffffffff,%rcx
mov    %rdx,%rdi
add    %rsi,%rdi
jne    1150 <duasStrings+0x30>
jmp    1176 <duasStrings+0x56>
xor    %eax,%eax
jmp    1176 <duasStrings+0x56>
mov    %esi,%eax
mov    %eax,%eax
movb   $0x0,(%rsp,%rax,1)
lea    0xe7d(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
lea    0xe85(%rip),%rdi
mov    %rsp,%rsi
call   1040 <printf@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [23 x i8] c"\0A\0AA string normal: %s\0A\00"
@.str.1 = [33 x i8] c"String de tras para frente: %s\0A\0A\00"
define void @duasStrings(i8* %0) {
%2 = alloca i8*
%3 = alloca [255 x i8]
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %5
%6 = load i8*, i8** %2
%7 = call i32 @_strlen(i8* %6)
%8 = sub nsw i32 %7, 1
store i32 %8, i32* %4
br label %9
9: ; preds = %22, %1
%10 = load i32, i32* %4
%11 = icmp sge i32 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %9
%13 = load i8*, i8** %2
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 0
br label %20
20: ; preds = %12, %9
%21 = phi i1 [ false, %9 ], [ %19, %12 ]
br i1 %21, label %22, label %35
22: ; preds = %20
%23 = load i8*, i8** %2
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 %29
store i8 %27, i8* %30
%31 = load i32, i32* %4
%32 = add nsw i32 %31, -1
store i32 %32, i32* %4
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %9
35: ; preds = %20
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 %37
store i8 0, i8* %38
%39 = load i8*, i8** %2
%40 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %39)
%41 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%42 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %41)
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"\0A\0AA string normal: %s\0A\00"
@.str.1 = [33 x i8] c"String de tras para frente: %s\0A\0A\00"
define void @duasStrings(i8* %0) {
%2 = alloca [255 x i8]
%3 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @_strlen(i8* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %22
6: ; preds = %1
%7 = zext i32 %4 to i64
br label %8
8: ; preds = %6, %15
%9 = phi i64 [ 0, %6 ], [ %18, %15 ]
%10 = phi i64 [ %7, %6 ], [ %11, %15 ]
%11 = add nsw i64 %10, -1
%12 = getelementptr inbounds i8, i8* %0, i64 %9
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %20, label %15
15: ; preds = %8
%16 = and i64 %11, 4294967295
%17 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 %16
store i8 %13, i8* %17
%18 = add nuw nsw i64 %9, 1
%19 = icmp eq i64 %18, %7
br i1 %19, label %22, label %8
20: ; preds = %8
%21 = trunc i64 %9 to i32
br label %22
22: ; preds = %15, %20, %1
%23 = phi i32 [ 0, %1 ], [ %21, %20 ], [ %4, %15 ]
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 %24
store i8 0, i8* %25
%26 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %0)
%27 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %3)
ret void
}