#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 *, char *);
size_t strlen(char *);
char *voltea(char *str) {
  long int i;
  char intermediate[strlen(str)];
  for (i = strlen(str); 0 <= i; i--) {
    *(intermediate + (strlen(str) - i)) = *(str + (i - 1));
  }
  intermediate[strlen(str)] = '\0';
  printf("%s\n", intermediate);
}


x86 assembly (clang, -O0):
<voltea>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rdx
mov    %rdx,%rax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jg     11b1 <voltea+0x91>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x31(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x31(%rbp),%dl
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
sub    -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1168 <voltea+0x48>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rsi
movb   $0x0,(%rsi,%rax,1)
lea    0xe37(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x8(%rbp),%rax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<voltea>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
mov    %rax,%r8
mov    %rsp,%rsi
lea    0xf(%rax),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rsi
mov    %rsi,%rsp
test   %rax,%rax
js     1294 <voltea+0x174>
lea    0x1(%rax),%r9
mov    %r8,%rcx
cmp    $0x8,%r9
jb     126a <voltea+0x14a>
cmp    $0x20,%r9
jae    116a <voltea+0x4a>
xor    %edi,%edi
jmp    120c <voltea+0xec>
mov    %r9,%rdi
and    $0xffffffffffffffe0,%rdi
lea    (%rax,%r14,1),%rcx
add    $0xfffffffffffffff0,%rcx
xor    %ebx,%ebx
pxor   %xmm0,%xmm0
nop
movdqu -0x10(%rcx),%xmm1
movdqu (%rcx),%xmm2
movdqa %xmm2,%xmm3
punpcklbw %xmm0,%xmm3
pshufd $0x4e,%xmm3,%xmm3
pshuflw $0x1b,%xmm3,%xmm3
pshufhw $0x1b,%xmm3,%xmm3
punpckhbw %xmm0,%xmm2
pshufd $0x4e,%xmm2,%xmm2
pshuflw $0x1b,%xmm2,%xmm2
pshufhw $0x1b,%xmm2,%xmm2
packuswb %xmm3,%xmm2
movdqa %xmm1,%xmm3
punpcklbw %xmm0,%xmm3
pshufd $0x4e,%xmm3,%xmm3
pshuflw $0x1b,%xmm3,%xmm3
pshufhw $0x1b,%xmm3,%xmm3
punpckhbw %xmm0,%xmm1
pshufd $0x4e,%xmm1,%xmm1
pshuflw $0x1b,%xmm1,%xmm1
pshufhw $0x1b,%xmm1,%xmm1
packuswb %xmm3,%xmm1
movdqa %xmm2,(%rsi,%rbx,1)
movdqa %xmm1,0x10(%rsi,%rbx,1)
add    $0x20,%rbx
add    $0xffffffffffffffe0,%rcx
cmp    %rbx,%rdi
jne    1180 <voltea+0x60>
cmp    %rdi,%r9
je     1294 <voltea+0x174>
test   $0x18,%r9b
je     1264 <voltea+0x144>
mov    %r9,%rdx
and    $0xfffffffffffffff8,%rdx
mov    %rax,%rcx
sub    %rdx,%rcx
mov    %rax,%rbx
sub    %rdi,%rbx
add    %r14,%rbx
add    $0xfffffffffffffff8,%rbx
pxor   %xmm0,%xmm0
nopw   0x0(%rax,%rax,1)
movq   (%rbx),%xmm1
punpcklbw %xmm0,%xmm1
pshufd $0x4e,%xmm1,%xmm1
pshuflw $0x1b,%xmm1,%xmm1
pshufhw $0x1b,%xmm1,%xmm1
packuswb %xmm1,%xmm1
movq   %xmm1,(%rsi,%rdi,1)
add    $0x8,%rdi
add    $0xfffffffffffffff8,%rbx
cmp    %rdi,%rdx
jne    1230 <voltea+0x110>
cmp    %rdx,%r9
jne    126a <voltea+0x14a>
jmp    1294 <voltea+0x174>
mov    %rax,%rcx
sub    %rdi,%rcx
add    %rsi,%rax
lea    (%rcx,%r14,1),%rdx
add    $0xffffffffffffffff,%rdx
neg    %rcx
nopl   0x0(%rax,%rax,1)
movzbl (%rdx),%ebx
mov    %bl,(%rax,%rcx,1)
add    $0x1,%rcx
add    $0xffffffffffffffff,%rdx
cmp    $0x1,%rcx
jne    1280 <voltea+0x160>
movb   $0x0,(%rsi,%r8,1)
lea    0xd60(%rip),%rdi
call   1040 <printf@plt>
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define i8* @voltea(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i64 @strlen(i8* %7)
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %5
%10 = alloca i8, i64 %8
store i64 %8, i64* %6
%11 = load i8*, i8** %3
%12 = call i64 @strlen(i8* %11)
store i64 %12, i64* %4
br label %13
13: ; preds = %27, %1
%14 = load i64, i64* %4
%15 = icmp sle i64 0, %14
br i1 %15, label %16, label %30
16: ; preds = %13
%17 = load i8*, i8** %3
%18 = load i64, i64* %4
%19 = sub nsw i64 %18, 1
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = load i8*, i8** %3
%23 = call i64 @strlen(i8* %22)
%24 = load i64, i64* %4
%25 = sub i64 %23, %24
%26 = getelementptr inbounds i8, i8* %10, i64 %25
store i8 %21, i8* %26
br label %27
27: ; preds = %16
%28 = load i64, i64* %4
%29 = add nsw i64 %28, -1
store i64 %29, i64* %4
br label %13
30: ; preds = %13
%31 = load i8*, i8** %3
%32 = call i64 @strlen(i8* %31)
%33 = getelementptr inbounds i8, i8* %10, i64 %32
store i8 0, i8* %33
%34 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %10)
%35 = load i8*, i8** %5
%36 = load i8*, i8** %2
ret i8* %36
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define noalias i8* @voltea(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = alloca i8, i64 %2
%4 = icmp sgt i64 %2, -1
br i1 %4, label %5, label %68
5: ; preds = %1
%6 = add i64 %2, 1
%7 = icmp ult i64 %6, 8
br i1 %7, label %58, label %8
8: ; preds = %5
%9 = icmp ult i64 %6, 32
br i1 %9, label %38, label %10
10: ; preds = %8
%11 = and i64 %6, -32
br label %12
12: ; preds = %12, %10
%13 = phi i64 [ 0, %10 ], [ %30, %12 ]
%14 = xor i64 %13, -1
%15 = add i64 %2, %14
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = getelementptr inbounds i8, i8* %16, i64 -15
%18 = bitcast i8* %17 to <16 x i8>*
%19 = load <16 x i8>, <16 x i8>* %18
%20 = shufflevector <16 x i8> %19, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%21 = getelementptr inbounds i8, i8* %16, i64 -16
%22 = getelementptr inbounds i8, i8* %21, i64 -15
%23 = bitcast i8* %22 to <16 x i8>*
%24 = load <16 x i8>, <16 x i8>* %23
%25 = shufflevector <16 x i8> %24, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%26 = getelementptr inbounds i8, i8* %3, i64 %13
%27 = bitcast i8* %26 to <16 x i8>*
store <16 x i8> %20, <16 x i8>* %27
%28 = getelementptr inbounds i8, i8* %26, i64 16
%29 = bitcast i8* %28 to <16 x i8>*
store <16 x i8> %25, <16 x i8>* %29
%30 = add nuw i64 %13, 32
%31 = icmp eq i64 %30, %11
br i1 %31, label %32, label %12
32: ; preds = %12
%33 = icmp eq i64 %6, %11
br i1 %33, label %68, label %34
34: ; preds = %32
%35 = sub i64 %2, %11
%36 = and i64 %6, 24
%37 = icmp eq i64 %36, 0
br i1 %37, label %58, label %38
38: ; preds = %8, %34
%39 = phi i64 [ %11, %34 ], [ 0, %8 ]
%40 = add i64 %2, 1
%41 = and i64 %40, -8
%42 = sub i64 %2, %41
%43 = getelementptr inbounds i8, i8* %0, i64 -7
br label %44
44: ; preds = %44, %38
%45 = phi i64 [ %39, %38 ], [ %54, %44 ]
%46 = xor i64 %45, -1
%47 = add i64 %2, %46
%48 = getelementptr inbounds i8, i8* %43, i64 %47
%49 = bitcast i8* %48 to <8 x i8>*
%50 = load <8 x i8>, <8 x i8>* %49
%51 = shufflevector <8 x i8> %50, <8 x i8> poison, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%52 = getelementptr inbounds i8, i8* %3, i64 %45
%53 = bitcast i8* %52 to <8 x i8>*
store <8 x i8> %51, <8 x i8>* %53
%54 = add nuw i64 %45, 8
%55 = icmp eq i64 %54, %41
br i1 %55, label %56, label %44
56: ; preds = %44
%57 = icmp eq i64 %40, %41
br i1 %57, label %68, label %58
58: ; preds = %5, %34, %56
%59 = phi i64 [ %2, %5 ], [ %35, %34 ], [ %42, %56 ]
br label %60
60: ; preds = %58, %60
%61 = phi i64 [ %62, %60 ], [ %59, %58 ]
%62 = add nsw i64 %61, -1
%63 = getelementptr inbounds i8, i8* %0, i64 %62
%64 = load i8, i8* %63
%65 = sub nuw nsw i64 %2, %61
%66 = getelementptr inbounds i8, i8* %3, i64 %65
store i8 %64, i8* %66
%67 = icmp eq i64 %61, 0
br i1 %67, label %68, label %60
68: ; preds = %60, %32, %56, %1
%69 = getelementptr inbounds i8, i8* %3, i64 %2
store i8 0, i8* %69
%70 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3)
ret i8* undef
}