#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 *leftShift(char text[], int shiftValue) {
  char *shiftedText = malloc(sizeof(char) * 5);
  short i;
  for (i = 0; i < 5; i++) {
    shiftedText[i % 5] = text[(i + shiftValue) % 5];
  }
  shiftedText[i] = '\0';
  return shiftedText;
}


x86 assembly (clang, -O0):
<leftShift>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x5,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
movw   $0x0,-0x1a(%rbp)
movswl -0x1a(%rbp),%eax
cmp    $0x5,%eax
jge    1198 <leftShift+0x88>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
movswl -0x1a(%rbp),%eax
add    -0xc(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    -0x30(%rbp),%rax
movslq %edx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x1b(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
movswl -0x1a(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    -0x28(%rbp),%rax
mov    %edx,%ecx
mov    -0x1b(%rbp),%dl
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1a(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x1a(%rbp)
jmp    1133 <leftShift+0x23>
mov    -0x18(%rbp),%rax
movswq -0x1a(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<leftShift>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
mov    $0x5,%edi
call   1030 <malloc@plt>
movslq %ebp,%rcx
imul   $0x66666667,%rcx,%r8
mov    %r8,%rsi
shr    $0x3f,%rsi
sar    $0x21,%r8
add    %esi,%r8d
lea    0x1(%rcx),%esi
movslq %esi,%rsi
imul   $0x66666667,%rsi,%rsi
mov    %rsi,%rdi
shr    $0x3f,%rdi
sar    $0x21,%rsi
add    %edi,%esi
lea    0x2(%rcx),%edi
movslq %edi,%rdi
imul   $0x66666667,%rdi,%rbx
mov    %rbx,%rdi
shr    $0x3f,%rdi
sar    $0x21,%rbx
add    %edi,%ebx
lea    0x3(%rcx),%edi
movslq %edi,%rdi
imul   $0x66666667,%rdi,%rbp
mov    %rbp,%rdi
shr    $0x3f,%rdi
sar    $0x21,%rbp
add    %edi,%ebp
mov    %ecx,%edi
add    $0x4,%edi
movslq %edi,%rdi
imul   $0x66666667,%rdi,%rdi
mov    %rdi,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rdi
add    %edx,%edi
lea    (%r8,%r8,4),%edx
lea    (%rsi,%rsi,4),%esi
neg    %esi
add    %ecx,%esi
add    $0x1,%esi
lea    (%rbx,%rbx,4),%ebx
neg    %ebx
add    %ecx,%ebx
add    $0x2,%ebx
lea    0x0(%rbp,%rbp,4),%ebp
neg    %ebp
add    %ecx,%ebp
add    $0x3,%ebp
lea    (%rdi,%rdi,4),%edi
neg    %edi
add    %ecx,%edi
add    $0x4,%edi
sub    %edx,%ecx
movslq %ecx,%rcx
mov    (%r14,%rcx,1),%cl
mov    %cl,(%rax)
movslq %esi,%rcx
mov    (%r14,%rcx,1),%cl
mov    %cl,0x1(%rax)
movslq %ebx,%rcx
mov    (%r14,%rcx,1),%cl
mov    %cl,0x2(%rax)
movslq %ebp,%rcx
mov    (%r14,%rcx,1),%cl
mov    %cl,0x3(%rax)
movslq %edi,%rcx
mov    (%r14,%rcx,1),%cl
mov    %cl,0x4(%rax)
movb   $0x0,0x5(%rax)
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define noalias i8* @leftShift(i8* nocapture %0, i32 %1) {
%3 = tail call dereferenceable_or_null(5) i8* @malloc(i32 5)
%4 = srem i32 %1, 5
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
store i8 %7, i8* %3
%8 = add nsw i32 %1, 1
%9 = srem i32 %8, 5
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = getelementptr inbounds i8, i8* %3, i64 1
store i8 %12, i8* %13
%14 = add nsw i32 %1, 2
%15 = srem i32 %14, 5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %0, i64 %16
%18 = load i8, i8* %17
%19 = getelementptr inbounds i8, i8* %3, i64 2
store i8 %18, i8* %19
%20 = add nsw i32 %1, 3
%21 = srem i32 %20, 5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %0, i64 %22
%24 = load i8, i8* %23
%25 = getelementptr inbounds i8, i8* %3, i64 3
store i8 %24, i8* %25
%26 = add nsw i32 %1, 4
%27 = srem i32 %26, 5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %0, i64 %28
%30 = load i8, i8* %29
%31 = getelementptr inbounds i8, i8* %3, i64 4
store i8 %30, i8* %31
%32 = getelementptr inbounds i8, i8* %3, i64 5
store i8 0, i8* %32
ret i8* %3
}