#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 *, ...);
int strlen(char const *);
void imprimirCorretamente(const char *str) {
  int length, half, i;
  length = strlen(str) - 1;
  half = length / 2;
  for (i = half - 1; i >= 0; i--) {
    printf("%c", str[i]);
  }
  for (i = length - 1; i >= half; i--) {
    printf("%c", str[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<imprimirCorretamente>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1184 <imprimirCorretamente+0x64>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1152 <imprimirCorretamente+0x32>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jl     11c1 <imprimirCorretamente+0xa1>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    118d <imprimirCorretamente+0x6d>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<imprimirCorretamente>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r12
call   1040 <strlen@plt>
mov    %eax,%r14d
lea    -0x1(%r14),%eax
shr    $0x1f,%eax
lea    (%r14,%rax,1),%r15d
add    $0xffffffff,%r15d
sar    %r15d
cmp    $0x3,%r14d
jl     1174 <imprimirCorretamente+0x54>
lea    0x1(%r15),%ebp
lea    -0x1(%r15),%ebx
add    %r12,%rbx
cs nopw 0x0(%rax,%rax,1)
movsbl (%rbx),%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%ebp
jg     1160 <imprimirCorretamente+0x40>
add    $0xfffffffe,%r14d
cmp    %r15d,%r14d
jl     11a4 <imprimirCorretamente+0x84>
movslq %r14d,%rbx
movslq %r15d,%rbp
add    $0x1,%rbx
nopw   0x0(%rax,%rax,1)
movsbl -0x1(%r12,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0xffffffffffffffff,%rbx
cmp    %rbp,%rbx
jg     1190 <imprimirCorretamente+0x70>
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
define void @imprimirCorretamente(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, -1
%4 = sdiv i32 %3, 2
%5 = icmp sgt i32 %2, 2
br i1 %5, label %6, label %18
6: ; preds = %1
%7 = zext i32 %4 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ %7, %6 ], [ %10, %8 ]
%10 = add nsw i64 %9, -1
%11 = and i64 %10, 4294967295
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = tail call i32 @putchar(i32 %14)
%16 = trunc i64 %9 to i32
%17 = icmp sgt i32 %16, 1
br i1 %17, label %8, label %18
18: ; preds = %8, %1
%19 = add i32 %2, -2
%20 = icmp slt i32 %19, %4
br i1 %20, label %32, label %21
21: ; preds = %18
%22 = sext i32 %19 to i64
%23 = sext i32 %4 to i64
br label %24
24: ; preds = %21, %24
%25 = phi i64 [ %22, %21 ], [ %30, %24 ]
%26 = getelementptr inbounds i8, i8* %0, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = tail call i32 @putchar(i32 %28)
%30 = add nsw i64 %25, -1
%31 = icmp sgt i64 %25, %23
br i1 %31, label %24, label %32
32: ; preds = %24, %18
%33 = tail call i32 @putchar(i32 10)
ret void
}