#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 int16_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
void rpe_grid_positioning(int16_t Mc, int16_t xMp[13], int16_t ep[40]) {
  int i = 13;
  assert(0 <= Mc && Mc <= 3);
  switch (Mc) {
  case 3:
    *ep++ = 0;
  case 2:
    do {
      *ep++ = 0;
    case 1:
      *ep++ = 0;
    case 0:
      *ep++ = *xMp++;
    } while (--i);
  }
  while (++Mc < 4)
    *ep++ = 0;
}


x86 assembly (clang, -O0):
<rpe_grid_positioning>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0xd,-0x1c(%rbp)
xor    %eax,%eax
xor    %ecx,%ecx
cmp    -0x4(%rbp),%ecx
mov    %al,-0x1d(%rbp)
jg     1144 <rpe_grid_positioning+0x34>
cmpl   $0x3,-0x4(%rbp)
setle  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
movzbl %al,%edi
and    $0x1,%edi
call   1030 <assert@plt>
mov    -0x4(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x3,%rax
ja     11f4 <rpe_grid_positioning+0xe4>
mov    -0x28(%rbp),%rax
lea    0xe92(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x18(%rbp)
movl   $0x0,(%rax)
jmp    1191 <rpe_grid_positioning+0x81>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x18(%rbp)
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x18(%rbp)
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x18(%rbp)
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jne    1191 <rpe_grid_positioning+0x81>
jmp    11f4 <rpe_grid_positioning+0xe4>
jmp    11f9 <rpe_grid_positioning+0xe9>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
cmp    $0x4,%eax
jge    1225 <rpe_grid_positioning+0x115>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x18(%rbp)
movl   $0x0,(%rax)
jmp    11f9 <rpe_grid_positioning+0xe9>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rpe_grid_positioning>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %edi,%r14d
xor    %edi,%edi
cmp    $0x4,%r14d
setb   %dil
call   1040 <assert@plt>
mov    $0xd,%eax
mov    %r14d,%ecx
cmp    $0x3,%r14d
ja     118a <rpe_grid_positioning+0x6a>
lea    0xeaf(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
movl   $0x0,(%rbx)
add    $0x4,%rbx
movl   $0x0,(%rbx)
add    $0x4,%rbx
movl   $0x0,(%rbx)
add    $0x4,%rbx
mov    0x0(%rbp),%ecx
add    $0x4,%rbp
mov    %ecx,(%rbx)
add    $0x4,%rbx
add    $0xffffffff,%eax
jne    1164 <rpe_grid_positioning+0x44>
cmp    $0x2,%r14d
jg     11aa <rpe_grid_positioning+0x8a>
mov    $0x2,%eax
sub    %r14d,%eax
lea    0x4(,%rax,4),%rdx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @rpe_grid_positioning(i32 %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32* %2, i32** %6
store i32 13, i32* %7
%8 = load i32, i32* %4
%9 = icmp sle i32 0, %8
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = load i32, i32* %4
%12 = icmp sle i32 %11, 3
br label %13
13: ; preds = %10, %3
%14 = phi i1 [ false, %3 ], [ %12, %10 ]
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load i32, i32* %4
switch i32 %17, label %39 [
i32 3, label %18
i32 2, label %21
i32 1, label %25
i32 0, label %28
]
18: ; preds = %13
%19 = load i32*, i32** %6
%20 = getelementptr inbounds i32, i32* %19, i32 1
store i32* %20, i32** %6
store i32 0, i32* %19
br label %21
21: ; preds = %13, %18
br label %22
22: ; preds = %34, %21
%23 = load i32*, i32** %6
%24 = getelementptr inbounds i32, i32* %23, i32 1
store i32* %24, i32** %6
store i32 0, i32* %23
br label %25
25: ; preds = %13, %22
%26 = load i32*, i32** %6
%27 = getelementptr inbounds i32, i32* %26, i32 1
store i32* %27, i32** %6
store i32 0, i32* %26
br label %28
28: ; preds = %13, %25
%29 = load i32*, i32** %5
%30 = getelementptr inbounds i32, i32* %29, i32 1
store i32* %30, i32** %5
%31 = load i32, i32* %29
%32 = load i32*, i32** %6
%33 = getelementptr inbounds i32, i32* %32, i32 1
store i32* %33, i32** %6
store i32 %31, i32* %32
br label %34
34: ; preds = %28
%35 = load i32, i32* %7
%36 = add nsw i32 %35, -1
store i32 %36, i32* %7
%37 = icmp ne i32 %36, 0
br i1 %37, label %22, label %38
38: ; preds = %34
br label %39
39: ; preds = %38, %13
br label %40
40: ; preds = %44, %39
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
%43 = icmp slt i32 %42, 4
br i1 %43, label %44, label %47
44: ; preds = %40
%45 = load i32*, i32** %6
%46 = getelementptr inbounds i32, i32* %45, i32 1
store i32* %46, i32** %6
store i32 0, i32* %45
br label %40
47: ; preds = %40
ret void
}

LLVM IR (-O2):
define void @rpe_grid_positioning(i32 %0, i32* nocapture %1, i32* nocapture writeonly %2) {
%4 = icmp ult i32 %0, 4
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
switch i32 %0, label %28 [
i32 3, label %7
i32 2, label %9
i32 1, label %14
i32 0, label %19
]
7: ; preds = %3
%8 = getelementptr inbounds i32, i32* %2, i64 1
store i32 0, i32* %2
br label %9
9: ; preds = %7, %3, %19
%10 = phi i32* [ %23, %19 ], [ %1, %3 ], [ %1, %7 ]
%11 = phi i32* [ %25, %19 ], [ %2, %3 ], [ %8, %7 ]
%12 = phi i32 [ %26, %19 ], [ 13, %3 ], [ 13, %7 ]
%13 = getelementptr inbounds i32, i32* %11, i64 1
store i32 0, i32* %11
br label %14
14: ; preds = %3, %9
%15 = phi i32* [ %10, %9 ], [ %1, %3 ]
%16 = phi i32* [ %13, %9 ], [ %2, %3 ]
%17 = phi i32 [ %12, %9 ], [ 13, %3 ]
%18 = getelementptr inbounds i32, i32* %16, i64 1
store i32 0, i32* %16
br label %19
19: ; preds = %3, %14
%20 = phi i32* [ %1, %3 ], [ %15, %14 ]
%21 = phi i32* [ %2, %3 ], [ %18, %14 ]
%22 = phi i32 [ 13, %3 ], [ %17, %14 ]
%23 = getelementptr inbounds i32, i32* %20, i64 1
%24 = load i32, i32* %20
%25 = getelementptr inbounds i32, i32* %21, i64 1
store i32 %24, i32* %21
%26 = add nsw i32 %22, -1
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %9
28: ; preds = %19, %3
%29 = phi i32* [ %2, %3 ], [ %25, %19 ]
%30 = icmp slt i32 %0, 3
br i1 %30, label %31, label %37
31: ; preds = %28
%32 = bitcast i32* %29 to i8*
%33 = sub i32 2, %0
%34 = zext i32 %33 to i64
%35 = shl nuw nsw i64 %34, 2
%36 = add nuw nsw i64 %35, 4
br label %37
37: ; preds = %31, %28
ret void
}