#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*/ rotate(char *, char *);
int strlen(char *);
void leftrotate(char *p, int m) {
  if (p == NULL) {
    return;
  }
  int len = strlen(p);
  char *xstart, *xend;
  char *ystart, *yend;
  xstart = p;
  xend = p + m - 1;
  ystart = p + m;
  yend = p + len - 1;
  rotate(xstart, xend);
  rotate(ystart, yend);
  rotate(p, p + len - 1);
}


x86 assembly (clang, -O0):
<leftrotate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    113f <leftrotate+0x1f>
jmp    11ba <leftrotate+0x9a>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <rotate@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <rotate@plt>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x10(%rbp),%rax
add    %rax,%rsi
add    $0xffffffffffffffff,%rsi
call   1040 <rotate@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<leftrotate>:
test   %rdi,%rdi
je     116e <leftrotate+0x4e>
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <strlen@plt>
movslq %ebp,%rcx
lea    (%rbx,%rcx,1),%r14
lea    (%rbx,%rcx,1),%rsi
add    $0xffffffffffffffff,%rsi
cltq
lea    (%rbx,%rax,1),%rbp
add    $0xffffffffffffffff,%rbp
mov    %rbx,%rdi
call   1040 <rotate@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1040 <rotate@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <rotate@plt>
ret

LLVM IR (-O0):
define void @leftrotate(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%10 = load i8*, i8** %3
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %13
12: ; preds = %2
br label %44
13: ; preds = %2
%14 = load i8*, i8** %3
%15 = call i32 @strlen(i8* %14)
store i32 %15, i32* %5
%16 = load i8*, i8** %3
store i8* %16, i8** %6
%17 = load i8*, i8** %3
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = getelementptr inbounds i8, i8* %20, i64 -1
store i8* %21, i8** %7
%22 = load i8*, i8** %3
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
store i8* %25, i8** %8
%26 = load i8*, i8** %3
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = getelementptr inbounds i8, i8* %29, i64 -1
store i8* %30, i8** %9
%31 = load i8*, i8** %6
%32 = load i8*, i8** %7
%33 = call i32 @rotate(i8* %31, i8* %32)
%34 = load i8*, i8** %8
%35 = load i8*, i8** %9
%36 = call i32 @rotate(i8* %34, i8* %35)
%37 = load i8*, i8** %3
%38 = load i8*, i8** %3
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = getelementptr inbounds i8, i8* %41, i64 -1
%43 = call i32 @rotate(i8* %37, i8* %42)
br label %44
44: ; preds = %13, %12
ret void
}

LLVM IR (-O2):
define void @leftrotate(i8* %0, i32 %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %15, label %4
4: ; preds = %2
%5 = tail call i32 @strlen(i8* %0)
%6 = sext i32 %1 to i64
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = getelementptr inbounds i8, i8* %7, i64 -1
%9 = sext i32 %5 to i64
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = getelementptr inbounds i8, i8* %10, i64 -1
%12 = tail call i32 @rotate(i8* %0, i8* %8)
%13 = tail call i32 @rotate(i8* %7, i8* %11)
%14 = tail call i32 @rotate(i8* %0, i8* %11)
br label %15
15: ; preds = %2, %4
ret void
}