#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*/ move_to_beginning(int *, int, size_t, size_t,
                                     int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int N = 20;
  int A[20];
  size_t size = 17;
  size_t begin = 15;
  size_t i;
  for (i = 0; i < size; ++i) {
    A[(begin + i) % N] = i;
  }
  move_to_beginning(A, N, begin, size, 0);
  for (i = 0; i < size; ++i) {
    printf("%d ", A[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x14,-0x8(%rbp)
movq   $0x11,-0x68(%rbp)
movq   $0xf,-0x70(%rbp)
movq   $0x0,-0x78(%rbp)
mov    -0x78(%rbp),%rax
cmp    -0x68(%rbp),%rax
jae    118f <main+0x6f>
mov    -0x78(%rbp),%rax
mov    %eax,-0x7c(%rbp)
mov    -0x70(%rbp),%rax
add    -0x78(%rbp),%rax
movslq -0x8(%rbp),%rcx
xor    %edx,%edx
div    %rcx
mov    -0x7c(%rbp),%eax
mov    %eax,-0x60(%rbp,%rdx,4)
mov    -0x78(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x78(%rbp)
jmp    1151 <main+0x31>
lea    -0x60(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x70(%rbp),%rdx
mov    -0x68(%rbp),%rcx
xor    %r8d,%r8d
call   1030 <move_to_beginning@plt>
movq   $0x0,-0x78(%rbp)
mov    -0x78(%rbp),%rax
cmp    -0x68(%rbp),%rax
jae    11e3 <main+0xc3>
mov    -0x78(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%esi
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x78(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x78(%rbp)
jmp    11ae <main+0x8e>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
lea    0x40(%rsp),%r8
lea    0x3c(%rsp),%r9
mov    $0x10,%ecx
mov    $0xe,%esi
xor    %ebx,%ebx
movabs $0xcccccccccccccccd,%r10
cc cc cc
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rcx,%rax
mul    %r10
mov    %rdx,%rdi
mov    %rsi,%rax
mul    %r10
and    $0xfffffffffffffff0,%rdx
lea    (%rdx,%rdx,4),%rax
mov    %r9,%rdx
sub    %rax,%rdx
mov    %ebx,(%rdx)
mov    %rbx,%rax
or     $0x1,%rax
cmp    $0x11,%rax
je     11b2 <main+0x82>
and    $0xfffffffffffffff0,%rdi
lea    (%rdi,%rdi,4),%rdx
mov    %r8,%rdi
sub    %rdx,%rdi
mov    %eax,(%rdi)
add    $0x2,%rbx
add    $0x8,%r8
add    $0x2,%rcx
add    $0x8,%r9
add    $0x2,%rsi
jmp    1160 <main+0x30>
mov    %rsp,%rdi
mov    $0xf,%edx
mov    $0x11,%ecx
mov    $0x14,%esi
xor    %r8d,%r8d
call   1040 <move_to_beginning@plt>
mov    (%rsp),%esi
lea    0xe2a(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x28(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x30(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x34(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x38(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x3c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x40(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [20 x i32]
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
store i32 20, i32* %2
store i64 17, i64* %4
store i64 15, i64* %5
store i64 0, i64* %6
br label %7
7: ; preds = %21, %0
%8 = load i64, i64* %6
%9 = load i64, i64* %4
%10 = icmp ult i64 %8, %9
br i1 %10, label %11, label %24
11: ; preds = %7
%12 = load i64, i64* %6
%13 = trunc i64 %12 to i32
%14 = load i64, i64* %5
%15 = load i64, i64* %6
%16 = add i64 %14, %15
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = urem i64 %16, %18
%20 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 %19
store i32 %13, i32* %20
br label %21
21: ; preds = %11
%22 = load i64, i64* %6
%23 = add i64 %22, 1
store i64 %23, i64* %6
br label %7
24: ; preds = %7
%25 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 0
%26 = load i32, i32* %2
%27 = load i64, i64* %5
%28 = load i64, i64* %4
%29 = call i32 @move_to_beginning(i32* %25, i32 %26, i64 %27, i64 %28, i32 0)
store i64 0, i64* %6
br label %30
30: ; preds = %39, %24
%31 = load i64, i64* %6
%32 = load i64, i64* %4
%33 = icmp ult i64 %31, %32
br i1 %33, label %34, label %42
34: ; preds = %30
%35 = load i64, i64* %6
%36 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %34
%40 = load i64, i64* %6
%41 = add i64 %40, 1
store i64 %41, i64* %6
br label %30
42: ; preds = %30
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca [20 x i32]
%2 = bitcast [20 x i32]* %1 to i8*
br label %3
3: ; preds = %13, %0
%4 = phi i64 [ 0, %0 ], [ %20, %13 ]
%5 = trunc i64 %4 to i32
%6 = trunc i64 %4 to i8
%7 = add nuw nsw i8 %6, 15
%8 = urem i8 %7, 20
%9 = zext i8 %8 to i64
%10 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %9
store i32 %5, i32* %10
%11 = or i64 %4, 1
%12 = icmp eq i64 %11, 17
br i1 %12, label %21, label %13
13: ; preds = %3
%14 = trunc i64 %11 to i32
%15 = trunc i64 %11 to i8
%16 = add nuw nsw i8 %15, 15
%17 = urem i8 %16, 20
%18 = zext i8 %17 to i64
%19 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %18
store i32 %14, i32* %19
%20 = add nuw nsw i64 %4, 2
br label %3
21: ; preds = %3
%22 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 0
%23 = call i32 @move_to_beginning(i32* %22, i32 20, i64 15, i64 17, i32 0)
%24 = load i32, i32* %22
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 1
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 2
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 3
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %33)
%35 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 4
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %36)
%38 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 5
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %39)
%41 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 6
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %42)
%44 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 7
%45 = load i32, i32* %44
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %45)
%47 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 8
%48 = load i32, i32* %47
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %48)
%50 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 9
%51 = load i32, i32* %50
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %51)
%53 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 10
%54 = load i32, i32* %53
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %54)
%56 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 11
%57 = load i32, i32* %56
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %57)
%59 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 12
%60 = load i32, i32* %59
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %60)
%62 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 13
%63 = load i32, i32* %62
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %63)
%65 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 14
%66 = load i32, i32* %65
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %66)
%68 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 15
%69 = load i32, i32* %68
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %69)
%71 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 16
%72 = load i32, i32* %71
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %72)
%74 = call i32 @putchar(i32 10)
ret i32 0
}