#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 *);
void voltea(void) {
  int i, j;
  extern char linea[], linea_max[];
  i = 0;
  j = strlen(linea) - 1;
  int alto = 1;
  while (alto) {
    linea_max[i] = linea[j];
    if (linea_max[i] == '\0')
      alto = 0;
    i++;
    j--;
  }
}


x86 assembly (clang, -O0):
<voltea>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2eca(%rip),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1194 <voltea+0x84>
movslq -0x8(%rbp),%rcx
mov    0x2ea3(%rip),%rax
mov    (%rax,%rcx,1),%dl
movslq -0x4(%rbp),%rcx
mov    0x2e7d(%rip),%rax
mov    %dl,(%rax,%rcx,1)
movslq -0x4(%rbp),%rcx
mov    0x2e6f(%rip),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    117d <voltea+0x6d>
movl   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1138 <voltea+0x28>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<voltea>:
push   %rbx
mov    0x2ed8(%rip),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
add    %rbx,%rax
add    $0xffffffffffffffff,%rax
mov    0x2ea8(%rip),%rcx
movzbl (%rax),%edx
mov    %dl,(%rcx)
add    $0x1,%rcx
add    $0xffffffffffffffff,%rax
test   %dl,%dl
jne    1130 <voltea+0x20>
pop    %rbx
ret

LLVM IR (-O0):
@linea = external global [0 x i8]
@linea_max = external global [0 x i8]
define void @voltea() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @strlen(i8* getelementptr inbounds ([0 x i8], [0 x i8]* @linea, i64 0, i64 0))
%5 = sub nsw i32 %4, 1
store i32 %5, i32* %2
store i32 1, i32* %3
br label %6
6: ; preds = %24, %0
%7 = load i32, i32* %3
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %29
9: ; preds = %6
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [0 x i8], [0 x i8]* @linea, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = load i32, i32* %1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [0 x i8], [0 x i8]* @linea_max, i64 0, i64 %15
store i8 %13, i8* %16
%17 = load i32, i32* %1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [0 x i8], [0 x i8]* @linea_max, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %9
store i32 0, i32* %3
br label %24
24: ; preds = %23, %9
%25 = load i32, i32* %1
%26 = add nsw i32 %25, 1
store i32 %26, i32* %1
%27 = load i32, i32* %2
%28 = add nsw i32 %27, -1
store i32 %28, i32* %2
br label %6
29: ; preds = %6
ret void
}

LLVM IR (-O2):
@linea = external global [0 x i8]
@linea_max = external global [0 x i8]
define void @voltea() {
%1 = tail call i32 @strlen(i8* getelementptr inbounds ([0 x i8], [0 x i8]* @linea, i64 0, i64 0))
%2 = sext i32 %1 to i64
br label %3
3: ; preds = %0, %3
%4 = phi i64 [ 0, %0 ], [ %11, %3 ]
%5 = phi i64 [ %2, %0 ], [ %6, %3 ]
%6 = add i64 %5, -1
%7 = getelementptr inbounds [0 x i8], [0 x i8]* @linea, i64 0, i64 %6
%8 = load i8, i8* %7
%9 = getelementptr inbounds [0 x i8], [0 x i8]* @linea_max, i64 0, i64 %4
store i8 %8, i8* %9
%10 = icmp eq i8 %8, 0
%11 = add nuw i64 %4, 1
br i1 %10, label %12, label %3
12: ; preds = %3
ret void
}