#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 */
char *malloc(int);
char *_verlan(char *str, int len) {
  char *dst, *back;
  back = dst = malloc(len + 1);
  str += len - 1;
  while (len-- >= 0) {
    *dst++ = *str--;
  }
  *dst = '\0';
  return back;
}


x86 assembly (clang, -O0):
<_verlan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
add    $0x1,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
jl     1181 <_verlan+0x71>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    1146 <_verlan+0x36>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_verlan>:
push   %r15
push   %r14
push   %rbx
mov    %esi,%r15d
mov    %rdi,%r14
lea    0x1(%r15),%edi
call   1030 <malloc@plt>
mov    %rax,%rdx
test   %r15d,%r15d
js     1223 <_verlan+0x113>
movslq %r15d,%rdi
lea    (%r14,%rdi,1),%rcx
add    $0xffffffffffffffff,%rcx
cmp    $0x1f,%r15d
jae    1149 <_verlan+0x39>
mov    %rax,%rdx
jmp    1204 <_verlan+0xf4>
add    $0xffffffffffffffff,%rdi
mov    %r15d,%r8d
add    $0x1,%r8
mov    %r8,%r9
and    $0xffffffffffffffe0,%r9
mov    %r9,%r10
neg    %r10
sub    %r9,%rcx
lea    (%rax,%r9,1),%rdx
sub    %r9d,%r15d
mov    %rax,%rsi
add    $0x10,%rsi
lea    (%rdi,%r14,1),%r11
add    $0xfffffffffffffff1,%r11
xor    %edi,%edi
pxor   %xmm0,%xmm0
movdqu -0x10(%r11,%rdi,1),%xmm1
movdqu (%r11,%rdi,1),%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
movdqu %xmm2,-0x10(%rsi)
movdqu %xmm1,(%rsi)
add    $0x20,%rsi
add    $0xffffffffffffffe0,%rdi
cmp    %rdi,%r10
jne    1180 <_verlan+0x70>
cmp    %r9,%r8
je     1223 <_verlan+0x113>
add    $0x1,%r15d
nopl   0x0(%rax,%rax,1)
movzbl (%rcx),%ebx
add    $0xffffffffffffffff,%rcx
mov    %bl,(%rdx)
add    $0x1,%rdx
add    $0xffffffff,%r15d
jne    1210 <_verlan+0x100>
movb   $0x0,(%rdx)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @_verlan(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = add nsw i32 %7, 1
%9 = call i8* @malloc(i32 %8)
store i8* %9, i8** %5
store i8* %9, i8** %6
%10 = load i32, i32* %4
%11 = sub nsw i32 %10, 1
%12 = load i8*, i8** %3
%13 = sext i32 %11 to i64
%14 = getelementptr inbounds i8, i8* %12, i64 %13
store i8* %14, i8** %3
br label %15
15: ; preds = %19, %2
%16 = load i32, i32* %4
%17 = add nsw i32 %16, -1
store i32 %17, i32* %4
%18 = icmp sge i32 %16, 0
br i1 %18, label %19, label %25
19: ; preds = %15
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i32 -1
store i8* %21, i8** %3
%22 = load i8, i8* %20
%23 = load i8*, i8** %5
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %5
store i8 %22, i8* %23
br label %15
25: ; preds = %15
%26 = load i8*, i8** %5
store i8 0, i8* %26
%27 = load i8*, i8** %6
ret i8* %27
}

LLVM IR (-O2):
define noalias i8* @_verlan(i8* nocapture %0, i32 %1) {
%3 = add nsw i32 %1, 1
%4 = tail call i8* @malloc(i32 %3)
%5 = icmp sgt i32 %1, -1
br i1 %5, label %6, label %54
6: ; preds = %2
%7 = add nsw i32 %1, -1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = zext i32 %1 to i64
%11 = add nuw nsw i64 %10, 1
%12 = icmp ult i32 %1, 31
br i1 %12, label %41, label %13
13: ; preds = %6
%14 = and i64 %11, 8589934560
%15 = sub nsw i64 0, %14
%16 = getelementptr i8, i8* %9, i64 %15
%17 = getelementptr i8, i8* %4, i64 %14
%18 = trunc i64 %14 to i32
%19 = sub i32 %1, %18
br label %20
20: ; preds = %20, %13
%21 = phi i64 [ 0, %13 ], [ %37, %20 ]
%22 = sub i64 0, %21
%23 = getelementptr i8, i8* %9, i64 %22
%24 = getelementptr i8, i8* %4, i64 %21
%25 = getelementptr i8, i8* %23, i64 -15
%26 = bitcast i8* %25 to <16 x i8>*
%27 = load <16 x i8>, <16 x i8>* %26
%28 = shufflevector <16 x i8> %27, <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>
%29 = getelementptr i8, i8* %23, i64 -16
%30 = getelementptr i8, i8* %29, i64 -15
%31 = bitcast i8* %30 to <16 x i8>*
%32 = load <16 x i8>, <16 x i8>* %31
%33 = shufflevector <16 x i8> %32, <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>
%34 = bitcast i8* %24 to <16 x i8>*
store <16 x i8> %28, <16 x i8>* %34
%35 = getelementptr i8, i8* %24, i64 16
%36 = bitcast i8* %35 to <16 x i8>*
store <16 x i8> %33, <16 x i8>* %36
%37 = add nuw i64 %21, 32
%38 = icmp eq i64 %37, %14
br i1 %38, label %39, label %20
39: ; preds = %20
%40 = icmp eq i64 %11, %14
br i1 %40, label %54, label %41
41: ; preds = %6, %39
%42 = phi i8* [ %9, %6 ], [ %16, %39 ]
%43 = phi i8* [ %4, %6 ], [ %17, %39 ]
%44 = phi i32 [ %1, %6 ], [ %19, %39 ]
br label %45
45: ; preds = %41, %45
%46 = phi i8* [ %50, %45 ], [ %42, %41 ]
%47 = phi i8* [ %52, %45 ], [ %43, %41 ]
%48 = phi i32 [ %49, %45 ], [ %44, %41 ]
%49 = add nsw i32 %48, -1
%50 = getelementptr inbounds i8, i8* %46, i64 -1
%51 = load i8, i8* %46
%52 = getelementptr inbounds i8, i8* %47, i64 1
store i8 %51, i8* %47
%53 = icmp eq i32 %48, 0
br i1 %53, label %54, label %45
54: ; preds = %45, %39, %2
%55 = phi i8* [ %4, %2 ], [ %17, %39 ], [ %52, %45 ]
store i8 0, i8* %55
ret i8* %4
}