#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 */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ *memmove(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                            unsigned long);
void move_rest(uint8_t **bufferp, unsigned long *startp, unsigned long *endp) {
  uint8_t *buffer;
  unsigned long start, end, rest;
  buffer = *bufferp;
  start = *startp;
  end = *endp;
  rest = end - start;
  if (rest > 0)
    *bufferp = memmove(buffer, buffer + start, rest);
  *startp = 0;
  *endp = rest;
}


x86 assembly (clang, -O0):
<move_rest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
sub    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jbe    1182 <move_rest+0x72>
mov    -0x20(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x38(%rbp),%rdx
call   1030 <memmove@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x38(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<move_rest>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    (%rsi),%rax
mov    (%rdx),%rbx
sub    %rax,%rbx
je     114a <move_rest+0x3a>
mov    %rdi,%r12
mov    (%rdi),%r13
lea    0x0(,%rax,4),%rsi
add    %r13,%rsi
mov    %r13,%rdi
mov    %rbx,%rdx
call   1030 <memmove@plt>
mov    %r13,(%r12)
movq   $0x0,(%r15)
mov    %rbx,(%r14)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @move_rest(i32** %0, i64* %1, i64* %2) {
%4 = alloca i32**
%5 = alloca i64*
%6 = alloca i64*
%7 = alloca i32*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
store i32** %0, i32*** %4
store i64* %1, i64** %5
store i64* %2, i64** %6
%11 = load i32**, i32*** %4
%12 = load i32*, i32** %11
store i32* %12, i32** %7
%13 = load i64*, i64** %5
%14 = load i64, i64* %13
store i64 %14, i64* %8
%15 = load i64*, i64** %6
%16 = load i64, i64* %15
store i64 %16, i64* %9
%17 = load i64, i64* %9
%18 = load i64, i64* %8
%19 = sub i64 %17, %18
store i64 %19, i64* %10
%20 = load i64, i64* %10
%21 = icmp ugt i64 %20, 0
br i1 %21, label %22, label %30
22: ; preds = %3
%23 = load i32*, i32** %7
%24 = load i32*, i32** %7
%25 = load i64, i64* %8
%26 = getelementptr inbounds i32, i32* %24, i64 %25
%27 = load i64, i64* %10
%28 = call i32* @memmove(i32* %23, i32* %26, i64 %27)
%29 = load i32**, i32*** %4
store i32* %28, i32** %29
br label %30
30: ; preds = %22, %3
%31 = load i64*, i64** %5
store i64 0, i64* %31
%32 = load i64, i64* %10
%33 = load i64*, i64** %6
store i64 %32, i64* %33
ret void
}

LLVM IR (-O2):
define void @move_rest(i32** nocapture %0, i64* nocapture %1, i64* nocapture %2) {
%4 = load i32*, i32** %0
%5 = load i64, i64* %1
%6 = load i64, i64* %2
%7 = sub i64 %6, %5
%8 = icmp eq i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %3
%10 = getelementptr inbounds i32, i32* %4, i64 %5
%11 = bitcast i32* %4 to i8*
%12 = bitcast i32* %10 to i8*
tail call void @llvm.memmove.p0i8.p0i8.i64(i8* align 1 %11, i8* align 1 %12, i64 %7, i1 false)
store i32* %4, i32** %0
br label %13
13: ; preds = %9, %3
store i64 0, i64* %1
store i64 %7, i64* %2
ret void
}