#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*/ free(char *);
int /*<<< orphan*/ printf(char *, char *);
char *rotate(char *, int);
void test_rotate() {
  char message[] = "Hello";
  int i;
  for (i = 0; i <= 10; i++) {
    char *tmp = rotate(message, i);
    printf("%s\n", tmp);
    free(tmp);
  }
  for (i = -1; i >= -10; i--) {
    char *tmp = rotate(message, i);
    printf("%s\n", tmp);
    free(tmp);
  }
}


x86 assembly (clang, -O0):
<test_rotate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xec2(%rip),%eax
mov    %eax,-0x6(%rbp)
mov    0xebc(%rip),%ax
mov    %ax,-0x2(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jg     1194 <test_rotate+0x64>
lea    -0x6(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <rotate@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe8e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1153 <test_rotate+0x23>
movl   $0xffffffff,-0xc(%rbp)
cmpl   $0xfffffff6,-0xc(%rbp)
jl     11dc <test_rotate+0xac>
lea    -0x6(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <rotate@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe46(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    119b <test_rotate+0x6b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_rotate>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movw   $0x6f,0xc(%rsp)
movl   $0x6c6c6548,0x8(%rsp)
6c
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <rotate@plt>
mov    %rax,%rbx
lea    0xea5(%rip),%r15
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0x1,%esi
call   1050 <rotate@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0x2,%esi
call   1050 <rotate@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0x3,%esi
call   1050 <rotate@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0x4,%esi
call   1050 <rotate@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0x5,%esi
call   1050 <rotate@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0x6,%esi
call   1050 <rotate@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0x7,%esi
call   1050 <rotate@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0x8,%esi
call   1050 <rotate@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0x9,%esi
call   1050 <rotate@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1050 <rotate@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0xffffffff,%esi
call   1050 <rotate@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0xfffffffe,%esi
call   1050 <rotate@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0xfffffffd,%esi
call   1050 <rotate@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0xfffffffc,%esi
call   1050 <rotate@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0xfffffffb,%esi
call   1050 <rotate@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0xfffffffa,%esi
call   1050 <rotate@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0xfffffff9,%esi
call   1050 <rotate@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0xfffffff8,%esi
call   1050 <rotate@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0xfffffff7,%esi
call   1050 <rotate@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0xfffffff6,%esi
call   1050 <rotate@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@__const.test_rotate.message = [6 x i8] c"Hello\00"
@.str = [4 x i8] c"%s\0A\00"
define void @test_rotate() {
%1 = alloca [6 x i8]
%2 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%3 = call i8* @rotate(i8* %2, i32 0)
%4 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = call i32 @free(i8* %3)
%6 = call i8* @rotate(i8* %2, i32 1)
%7 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = call i32 @free(i8* %6)
%9 = call i8* @rotate(i8* %2, i32 2)
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = call i32 @free(i8* %9)
%12 = call i8* @rotate(i8* %2, i32 3)
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = call i32 @free(i8* %12)
%15 = call i8* @rotate(i8* %2, i32 4)
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = call i32 @free(i8* %15)
%18 = call i8* @rotate(i8* %2, i32 5)
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = call i32 @free(i8* %18)
%21 = call i8* @rotate(i8* %2, i32 6)
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = call i32 @free(i8* %21)
%24 = call i8* @rotate(i8* %2, i32 7)
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %24)
%26 = call i32 @free(i8* %24)
%27 = call i8* @rotate(i8* %2, i32 8)
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %27)
%29 = call i32 @free(i8* %27)
%30 = call i8* @rotate(i8* %2, i32 9)
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %30)
%32 = call i32 @free(i8* %30)
%33 = call i8* @rotate(i8* %2, i32 10)
%34 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %33)
%35 = call i32 @free(i8* %33)
%36 = call i8* @rotate(i8* %2, i32 -1)
%37 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %36)
%38 = call i32 @free(i8* %36)
%39 = call i8* @rotate(i8* %2, i32 -2)
%40 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %39)
%41 = call i32 @free(i8* %39)
%42 = call i8* @rotate(i8* %2, i32 -3)
%43 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %42)
%44 = call i32 @free(i8* %42)
%45 = call i8* @rotate(i8* %2, i32 -4)
%46 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %45)
%47 = call i32 @free(i8* %45)
%48 = call i8* @rotate(i8* %2, i32 -5)
%49 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %48)
%50 = call i32 @free(i8* %48)
%51 = call i8* @rotate(i8* %2, i32 -6)
%52 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %51)
%53 = call i32 @free(i8* %51)
%54 = call i8* @rotate(i8* %2, i32 -7)
%55 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %54)
%56 = call i32 @free(i8* %54)
%57 = call i8* @rotate(i8* %2, i32 -8)
%58 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %57)
%59 = call i32 @free(i8* %57)
%60 = call i8* @rotate(i8* %2, i32 -9)
%61 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %60)
%62 = call i32 @free(i8* %60)
%63 = call i8* @rotate(i8* %2, i32 -10)
%64 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %63)
%65 = call i32 @free(i8* %63)
ret void
}