#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_even(int *, int *, int *, int *, int *, int *);
int /*<<< orphan*/ move_odd(int *, int *, int *, int *);
int move_clockwise(int *A, int *len_a, int *B, int *len_b, int *C, int *len_c,
                   int m) {
  if (m % 2 == 0) {
    move_even(A, len_a, B, len_b, C, len_c);
  } else {
    int r = m % 6;
    if (r == 1) {
      move_odd(A, len_a, B, len_b);
    }
    if (r == 3) {
      move_odd(B, len_b, C, len_c);
    }
    if (r == 5) {
      move_odd(C, len_c, A, len_a);
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<move_clockwise>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1179 <move_clockwise+0x59>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
call   1030 <move_even@plt>
jmp    11e9 <move_clockwise+0xc9>
mov    0x10(%rbp),%eax
mov    $0x6,%ecx
cltd
idiv   %ecx
mov    %edx,-0x34(%rbp)
cmpl   $0x1,-0x34(%rbp)
jne    11a6 <move_clockwise+0x86>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1040 <move_odd@plt>
cmpl   $0x3,-0x34(%rbp)
jne    11c5 <move_clockwise+0xa5>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
call   1040 <move_odd@plt>
cmpl   $0x5,-0x34(%rbp)
jne    11e4 <move_clockwise+0xc4>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
call   1040 <move_odd@plt>
jmp    11e9 <move_clockwise+0xc9>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<move_clockwise>:
push   %rax
mov    %rsi,%r10
mov    %rdi,%r11
mov    0x10(%rsp),%esi
test   $0x1,%sil
jne    113e <move_clockwise+0x1e>
mov    %r11,%rdi
mov    %r10,%rsi
call   1030 <move_even@plt>
jmp    1192 <move_clockwise+0x72>
movslq %esi,%rdi
imul   $0x2aaaaaab,%rdi,%rdi
mov    %rdi,%rax
shr    $0x3f,%rax
shr    $0x20,%rdi
add    %eax,%edi
add    %edi,%edi
lea    (%rdi,%rdi,2),%eax
sub    %eax,%esi
cmp    $0x5,%esi
je     1173 <move_clockwise+0x53>
cmp    $0x3,%esi
je     1181 <move_clockwise+0x61>
cmp    $0x1,%esi
jne    1192 <move_clockwise+0x72>
mov    %r11,%rdi
mov    %r10,%rsi
jmp    118d <move_clockwise+0x6d>
mov    %r8,%rdi
mov    %r9,%rsi
mov    %r11,%rdx
mov    %r10,%rcx
jmp    118d <move_clockwise+0x6d>
mov    %rdx,%rdi
mov    %rcx,%rsi
mov    %r8,%rdx
mov    %r9,%rcx
call   1040 <move_odd@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @move_clockwise(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32 %6) {
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i32
store i32* %0, i32** %8
store i32* %1, i32** %9
store i32* %2, i32** %10
store i32* %3, i32** %11
store i32* %4, i32** %12
store i32* %5, i32** %13
store i32 %6, i32* %14
%16 = load i32, i32* %14
%17 = srem i32 %16, 2
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %27
19: ; preds = %7
%20 = load i32*, i32** %8
%21 = load i32*, i32** %9
%22 = load i32*, i32** %10
%23 = load i32*, i32** %11
%24 = load i32*, i32** %12
%25 = load i32*, i32** %13
%26 = call i32 @move_even(i32* %20, i32* %21, i32* %22, i32* %23, i32* %24, i32* %25)
br label %57
27: ; preds = %7
%28 = load i32, i32* %14
%29 = srem i32 %28, 6
store i32 %29, i32* %15
%30 = load i32, i32* %15
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %38
32: ; preds = %27
%33 = load i32*, i32** %8
%34 = load i32*, i32** %9
%35 = load i32*, i32** %10
%36 = load i32*, i32** %11
%37 = call i32 @move_odd(i32* %33, i32* %34, i32* %35, i32* %36)
br label %38
38: ; preds = %32, %27
%39 = load i32, i32* %15
%40 = icmp eq i32 %39, 3
br i1 %40, label %41, label %47
41: ; preds = %38
%42 = load i32*, i32** %10
%43 = load i32*, i32** %11
%44 = load i32*, i32** %12
%45 = load i32*, i32** %13
%46 = call i32 @move_odd(i32* %42, i32* %43, i32* %44, i32* %45)
br label %47
47: ; preds = %41, %38
%48 = load i32, i32* %15
%49 = icmp eq i32 %48, 5
br i1 %49, label %50, label %56
50: ; preds = %47
%51 = load i32*, i32** %12
%52 = load i32*, i32** %13
%53 = load i32*, i32** %8
%54 = load i32*, i32** %9
%55 = call i32 @move_odd(i32* %51, i32* %52, i32* %53, i32* %54)
br label %56
56: ; preds = %50, %47
br label %57
57: ; preds = %56, %19
ret i32 0
}

LLVM IR (-O2):
define i32 @move_clockwise(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32 %6) {
%8 = and i32 %6, 1
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @move_even(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5)
br label %20
12: ; preds = %7
%13 = srem i32 %6, 6
switch i32 %13, label %20 [
i32 1, label %14
i32 3, label %16
i32 5, label %18
]
14: ; preds = %12
%15 = tail call i32 @move_odd(i32* %0, i32* %1, i32* %2, i32* %3)
br label %20
16: ; preds = %12
%17 = tail call i32 @move_odd(i32* %2, i32* %3, i32* %4, i32* %5)
br label %20
18: ; preds = %12
%19 = tail call i32 @move_odd(i32* %4, i32* %5, i32* %0, i32* %1)
br label %20
20: ; preds = %16, %14, %18, %12, %10
ret i32 0
}