#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*/ memcpy(void *, char *, int);
int /*<<< orphan*/ memmove(void *, void *, int);
int rotate(void *start, void *middle, void *end) {
  int leftLength = (char *)middle - (char *)start;
  char buffer[leftLength];
  memcpy(buffer, start, leftLength);
  memmove(start, middle, (char *)end - (char *)middle);
  memcpy(end - leftLength, buffer, leftLength);
}


x86 assembly (clang, -O0):
<rotate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x40(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <memcpy@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1040 <memmove@plt>
mov    -0x40(%rbp),%rsi
mov    -0x20(%rbp),%rdi
movslq -0x24(%rbp),%rcx
xor    %eax,%eax
sub    %rcx,%rax
add    %rax,%rdi
mov    -0x24(%rbp),%edx
call   1030 <memcpy@plt>
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rotate>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    %rsi,%r13
sub    %rdi,%r13
mov    %r13d,%eax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13d,%edx
call   1030 <memcpy@plt>
mov    %r14d,%edx
sub    %r15d,%edx
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <memmove@plt>
movslq %r13d,%rdx
sub    %rdx,%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <memcpy@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @rotate(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%11 = load i8*, i8** %6
%12 = load i8*, i8** %5
%13 = ptrtoint i8* %11 to i64
%14 = ptrtoint i8* %12 to i64
%15 = sub i64 %13, %14
%16 = trunc i64 %15 to i32
store i32 %16, i32* %8
%17 = load i32, i32* %8
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %9
%20 = alloca i8, i64 %18
store i64 %18, i64* %10
%21 = load i8*, i8** %5
%22 = load i32, i32* %8
%23 = call i32 @memcpy(i8* %20, i8* %21, i32 %22)
%24 = load i8*, i8** %5
%25 = load i8*, i8** %6
%26 = load i8*, i8** %7
%27 = load i8*, i8** %6
%28 = ptrtoint i8* %26 to i64
%29 = ptrtoint i8* %27 to i64
%30 = sub i64 %28, %29
%31 = trunc i64 %30 to i32
%32 = call i32 @memmove(i8* %24, i8* %25, i32 %31)
%33 = load i8*, i8** %7
%34 = load i32, i32* %8
%35 = sext i32 %34 to i64
%36 = sub i64 0, %35
%37 = getelementptr i8, i8* %33, i64 %36
%38 = load i32, i32* %8
%39 = call i32 @memcpy(i8* %37, i8* %20, i32 %38)
%40 = load i8*, i8** %9
%41 = load i32, i32* %4
ret i32 %41
}

LLVM IR (-O2):
define i32 @rotate(i8* %0, i8* %1, i8* %2) {
%4 = ptrtoint i8* %1 to i64
%5 = ptrtoint i8* %0 to i64
%6 = sub i64 %4, %5
%7 = trunc i64 %6 to i32
%8 = and i64 %6, 4294967295
%9 = alloca i8, i64 %8
%10 = call i32 @memcpy(i8* %9, i8* %0, i32 %7)
%11 = ptrtoint i8* %2 to i64
%12 = sub i64 %11, %4
%13 = trunc i64 %12 to i32
%14 = call i32 @memmove(i8* %0, i8* %1, i32 %13)
%15 = shl i64 %6, 32
%16 = ashr exact i64 %15, 32
%17 = sub nsw i64 0, %16
%18 = getelementptr i8, i8* %2, i64 %17
%19 = call i32 @memcpy(i8* %18, i8* %9, i32 %7)
ret i32 undef
}