#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*/ reverse(int *, int, int);
void rotate(int *nums, int numsSize, int k) {
  int l = 0;
  int r = numsSize - 1;
  k = k % numsSize;
  reverse(nums, l, r);
  l = 0;
  r = k - 1;
  reverse(nums, l, r);
  l = k;
  r = numsSize - 1;
  reverse(nums, l, r);
  return;
}


x86 assembly (clang, -O0):
<rotate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1030 <reverse@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1030 <reverse@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1030 <reverse@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rotate>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%eax
mov    %rdi,%rbx
lea    -0x1(%rsi),%r14d
cltd
idiv   %esi
mov    %edx,%ebp
xor    %esi,%esi
mov    %r14d,%edx
call   1030 <reverse@plt>
lea    -0x1(%rbp),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <reverse@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <reverse@plt>

LLVM IR (-O0):
define void @rotate(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
%9 = load i32, i32* %5
%10 = sub nsw i32 %9, 1
store i32 %10, i32* %8
%11 = load i32, i32* %6
%12 = load i32, i32* %5
%13 = srem i32 %11, %12
store i32 %13, i32* %6
%14 = load i32*, i32** %4
%15 = load i32, i32* %7
%16 = load i32, i32* %8
%17 = call i32 @reverse(i32* %14, i32 %15, i32 %16)
store i32 0, i32* %7
%18 = load i32, i32* %6
%19 = sub nsw i32 %18, 1
store i32 %19, i32* %8
%20 = load i32*, i32** %4
%21 = load i32, i32* %7
%22 = load i32, i32* %8
%23 = call i32 @reverse(i32* %20, i32 %21, i32 %22)
%24 = load i32, i32* %6
store i32 %24, i32* %7
%25 = load i32, i32* %5
%26 = sub nsw i32 %25, 1
store i32 %26, i32* %8
%27 = load i32*, i32** %4
%28 = load i32, i32* %7
%29 = load i32, i32* %8
%30 = call i32 @reverse(i32* %27, i32 %28, i32 %29)
ret void
}

LLVM IR (-O2):
define void @rotate(i32* %0, i32 %1, i32 %2) {
%4 = add nsw i32 %1, -1
%5 = srem i32 %2, %1
%6 = tail call i32 @reverse(i32* %0, i32 0, i32 %4)
%7 = add nsw i32 %5, -1
%8 = tail call i32 @reverse(i32* %0, i32 0, i32 %7)
%9 = tail call i32 @reverse(i32* %0, i32 %5, i32 %4)
ret void
}