#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*/ altervoxel(unsigned char, unsigned char, int, unsigned char);
int /*<<< orphan*/ clrvoxel(unsigned char, unsigned char, int);
unsigned char getvoxel(unsigned char, unsigned char, int);
void pathmove(unsigned char *path, int length) {
  int i, z;
  unsigned char state;
  for (i = (length - 1); i >= 1; i--) {
    for (z = 0; z < 8; z++) {
      state =
          getvoxel(((path[(i - 1)] >> 4) & 0x0f), (path[(i - 1)] & 0x0f), z);
      altervoxel(((path[i] >> 4) & 0x0f), (path[i] & 0x0f), z, state);
    }
  }
  for (i = 0; i < 8; i++)
    clrvoxel(((path[0] >> 4) & 0x0f), (path[0] & 0x0f), i);
}


x86 assembly (clang, -O0):
<pathmove>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jl     11f7 <pathmove+0xc7>
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    11e4 <pathmove+0xb4>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
sar    $0x4,%eax
and    $0xf,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%edx
sub    $0x1,%edx
movslq %edx,%rdx
movzbl (%rax,%rdx,1),%eax
and    $0xf,%eax
mov    -0x14(%rbp),%edx
movzbl %cl,%edi
movzbl %al,%esi
call   1040 <getvoxel@plt>
mov    %al,-0x15(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
sar    $0x4,%eax
and    $0xf,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rdx
movzbl (%rax,%rdx,1),%eax
and    $0xf,%eax
mov    -0x14(%rbp),%edx
movzbl %cl,%edi
movzbl %al,%esi
movzbl -0x15(%rbp),%ecx
call   1050 <altervoxel@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1159 <pathmove+0x29>
jmp    11e9 <pathmove+0xb9>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1148 <pathmove+0x18>
movl   $0x0,-0x10(%rbp)
cmpl   $0x8,-0x10(%rbp)
jge    123d <pathmove+0x10d>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
sar    $0x4,%eax
and    $0xf,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
and    $0xf,%eax
mov    -0x10(%rbp),%edx
movzbl %cl,%edi
movzbl %al,%esi
call   1030 <clrvoxel@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11fe <pathmove+0xce>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pathmove>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
cmp    $0x2,%esi
jl     1320 <pathmove+0x1f0>
mov    %esi,%ebx
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
movzbl -0x3(%r14,%rbx,1),%esi
mov    %esi,%eax
shr    $0x4,%al
and    $0xf,%esi
movzbl %al,%edi
xor    %edx,%edx
call   1040 <getvoxel@plt>
movzbl -0x2(%r14,%rbx,1),%esi
mov    %esi,%edx
shr    $0x4,%dl
movzbl %al,%ecx
and    $0xf,%esi
movzbl %dl,%edi
xor    %edx,%edx
call   1050 <altervoxel@plt>
movzbl -0x3(%r14,%rbx,1),%esi
mov    %esi,%eax
shr    $0x4,%al
and    $0xf,%esi
movzbl %al,%edi
mov    $0x1,%edx
call   1040 <getvoxel@plt>
movzbl -0x2(%r14,%rbx,1),%esi
mov    %esi,%edx
shr    $0x4,%dl
movzbl %al,%ecx
and    $0xf,%esi
movzbl %dl,%edi
mov    $0x1,%edx
call   1050 <altervoxel@plt>
movzbl -0x3(%r14,%rbx,1),%esi
mov    %esi,%eax
shr    $0x4,%al
and    $0xf,%esi
movzbl %al,%edi
mov    $0x2,%edx
call   1040 <getvoxel@plt>
movzbl -0x2(%r14,%rbx,1),%esi
mov    %esi,%edx
shr    $0x4,%dl
movzbl %al,%ecx
and    $0xf,%esi
movzbl %dl,%edi
mov    $0x2,%edx
call   1050 <altervoxel@plt>
movzbl -0x3(%r14,%rbx,1),%esi
mov    %esi,%eax
shr    $0x4,%al
and    $0xf,%esi
movzbl %al,%edi
mov    $0x3,%edx
call   1040 <getvoxel@plt>
movzbl -0x2(%r14,%rbx,1),%esi
mov    %esi,%edx
shr    $0x4,%dl
movzbl %al,%ecx
and    $0xf,%esi
movzbl %dl,%edi
mov    $0x3,%edx
call   1050 <altervoxel@plt>
movzbl -0x3(%r14,%rbx,1),%esi
mov    %esi,%eax
shr    $0x4,%al
and    $0xf,%esi
movzbl %al,%edi
mov    $0x4,%edx
call   1040 <getvoxel@plt>
movzbl -0x2(%r14,%rbx,1),%esi
mov    %esi,%edx
shr    $0x4,%dl
movzbl %al,%ecx
and    $0xf,%esi
movzbl %dl,%edi
mov    $0x4,%edx
call   1050 <altervoxel@plt>
movzbl -0x3(%r14,%rbx,1),%esi
mov    %esi,%eax
shr    $0x4,%al
and    $0xf,%esi
movzbl %al,%edi
mov    $0x5,%edx
call   1040 <getvoxel@plt>
movzbl -0x2(%r14,%rbx,1),%esi
mov    %esi,%edx
shr    $0x4,%dl
movzbl %al,%ecx
and    $0xf,%esi
movzbl %dl,%edi
mov    $0x5,%edx
call   1050 <altervoxel@plt>
movzbl -0x3(%r14,%rbx,1),%esi
mov    %esi,%eax
shr    $0x4,%al
and    $0xf,%esi
movzbl %al,%edi
mov    $0x6,%edx
call   1040 <getvoxel@plt>
movzbl -0x2(%r14,%rbx,1),%esi
mov    %esi,%edx
shr    $0x4,%dl
movzbl %al,%ecx
and    $0xf,%esi
movzbl %dl,%edi
mov    $0x6,%edx
call   1050 <altervoxel@plt>
movzbl -0x3(%r14,%rbx,1),%esi
mov    %esi,%eax
shr    $0x4,%al
and    $0xf,%esi
movzbl %al,%edi
mov    $0x7,%edx
call   1040 <getvoxel@plt>
movzbl -0x2(%r14,%rbx,1),%esi
mov    %esi,%edx
shr    $0x4,%dl
movzbl %al,%ecx
and    $0xf,%esi
movzbl %dl,%edi
mov    $0x7,%edx
call   1050 <altervoxel@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x2,%rbx
ja     1150 <pathmove+0x20>
movzbl (%r14),%esi
mov    %esi,%eax
shr    $0x4,%al
and    $0xf,%esi
movzbl %al,%edi
xor    %edx,%edx
call   1030 <clrvoxel@plt>
movzbl (%r14),%esi
mov    %esi,%eax
shr    $0x4,%al
and    $0xf,%esi
movzbl %al,%edi
mov    $0x1,%edx
call   1030 <clrvoxel@plt>
movzbl (%r14),%esi
mov    %esi,%eax
shr    $0x4,%al
and    $0xf,%esi
movzbl %al,%edi
mov    $0x2,%edx
call   1030 <clrvoxel@plt>
movzbl (%r14),%esi
mov    %esi,%eax
shr    $0x4,%al
and    $0xf,%esi
movzbl %al,%edi
mov    $0x3,%edx
call   1030 <clrvoxel@plt>
movzbl (%r14),%esi
mov    %esi,%eax
shr    $0x4,%al
and    $0xf,%esi
movzbl %al,%edi
mov    $0x4,%edx
call   1030 <clrvoxel@plt>
movzbl (%r14),%esi
mov    %esi,%eax
shr    $0x4,%al
and    $0xf,%esi
movzbl %al,%edi
mov    $0x5,%edx
call   1030 <clrvoxel@plt>
movzbl (%r14),%esi
mov    %esi,%eax
shr    $0x4,%al
and    $0xf,%esi
movzbl %al,%edi
mov    $0x6,%edx
call   1030 <clrvoxel@plt>
movzbl (%r14),%esi
mov    %esi,%eax
shr    $0x4,%al
and    $0xf,%esi
movzbl %al,%edi
mov    $0x7,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <clrvoxel@plt>

LLVM IR (-O0):
define void @pathmove(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = load i32, i32* %4
%9 = sub nsw i32 %8, 1
store i32 %9, i32* %5
br label %10
10: ; preds = %63, %2
%11 = load i32, i32* %5
%12 = icmp sge i32 %11, 1
br i1 %12, label %13, label %66
13: ; preds = %10
store i32 0, i32* %6
br label %14
14: ; preds = %59, %13
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 8
br i1 %16, label %17, label %62
17: ; preds = %14
%18 = load i8*, i8** %3
%19 = load i32, i32* %5
%20 = sub nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %18, i64 %21
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = ashr i32 %24, 4
%26 = and i32 %25, 15
%27 = trunc i32 %26 to i8
%28 = load i8*, i8** %3
%29 = load i32, i32* %5
%30 = sub nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %28, i64 %31
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = and i32 %34, 15
%36 = trunc i32 %35 to i8
%37 = load i32, i32* %6
%38 = call zeroext i8 @getvoxel(i8 zeroext %27, i8 zeroext %36, i32 %37)
store i8 %38, i8* %7
%39 = load i8*, i8** %3
%40 = load i32, i32* %5
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
%45 = ashr i32 %44, 4
%46 = and i32 %45, 15
%47 = trunc i32 %46 to i8
%48 = load i8*, i8** %3
%49 = load i32, i32* %5
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = load i8, i8* %51
%53 = zext i8 %52 to i32
%54 = and i32 %53, 15
%55 = trunc i32 %54 to i8
%56 = load i32, i32* %6
%57 = load i8, i8* %7
%58 = call i32 @altervoxel(i8 zeroext %47, i8 zeroext %55, i32 %56, i8 zeroext %57)
br label %59
59: ; preds = %17
%60 = load i32, i32* %6
%61 = add nsw i32 %60, 1
store i32 %61, i32* %6
br label %14
62: ; preds = %14
br label %63
63: ; preds = %62
%64 = load i32, i32* %5
%65 = add nsw i32 %64, -1
store i32 %65, i32* %5
br label %10
66: ; preds = %10
store i32 0, i32* %5
br label %67
67: ; preds = %86, %66
%68 = load i32, i32* %5
%69 = icmp slt i32 %68, 8
br i1 %69, label %70, label %89
70: ; preds = %67
%71 = load i8*, i8** %3
%72 = getelementptr inbounds i8, i8* %71, i64 0
%73 = load i8, i8* %72
%74 = zext i8 %73 to i32
%75 = ashr i32 %74, 4
%76 = and i32 %75, 15
%77 = trunc i32 %76 to i8
%78 = load i8*, i8** %3
%79 = getelementptr inbounds i8, i8* %78, i64 0
%80 = load i8, i8* %79
%81 = zext i8 %80 to i32
%82 = and i32 %81, 15
%83 = trunc i32 %82 to i8
%84 = load i32, i32* %5
%85 = call i32 @clrvoxel(i8 zeroext %77, i8 zeroext %83, i32 %84)
br label %86
86: ; preds = %70
%87 = load i32, i32* %5
%88 = add nsw i32 %87, 1
store i32 %88, i32* %5
br label %67
89: ; preds = %67
ret void
}

LLVM IR (-O2):
define void @pathmove(i8* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 1
br i1 %3, label %4, label %77
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ %5, %4 ], [ %8, %6 ]
%8 = add nsw i64 %7, -1
%9 = add nsw i64 %7, -2
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = getelementptr inbounds i8, i8* %0, i64 %8
%12 = load i8, i8* %10
%13 = lshr i8 %12, 4
%14 = and i8 %12, 15
%15 = tail call zeroext i8 @getvoxel(i8 zeroext %13, i8 zeroext %14, i32 0)
%16 = load i8, i8* %11
%17 = lshr i8 %16, 4
%18 = and i8 %16, 15
%19 = tail call i32 @altervoxel(i8 zeroext %17, i8 zeroext %18, i32 0, i8 zeroext %15)
%20 = load i8, i8* %10
%21 = lshr i8 %20, 4
%22 = and i8 %20, 15
%23 = tail call zeroext i8 @getvoxel(i8 zeroext %21, i8 zeroext %22, i32 1)
%24 = load i8, i8* %11
%25 = lshr i8 %24, 4
%26 = and i8 %24, 15
%27 = tail call i32 @altervoxel(i8 zeroext %25, i8 zeroext %26, i32 1, i8 zeroext %23)
%28 = load i8, i8* %10
%29 = lshr i8 %28, 4
%30 = and i8 %28, 15
%31 = tail call zeroext i8 @getvoxel(i8 zeroext %29, i8 zeroext %30, i32 2)
%32 = load i8, i8* %11
%33 = lshr i8 %32, 4
%34 = and i8 %32, 15
%35 = tail call i32 @altervoxel(i8 zeroext %33, i8 zeroext %34, i32 2, i8 zeroext %31)
%36 = load i8, i8* %10
%37 = lshr i8 %36, 4
%38 = and i8 %36, 15
%39 = tail call zeroext i8 @getvoxel(i8 zeroext %37, i8 zeroext %38, i32 3)
%40 = load i8, i8* %11
%41 = lshr i8 %40, 4
%42 = and i8 %40, 15
%43 = tail call i32 @altervoxel(i8 zeroext %41, i8 zeroext %42, i32 3, i8 zeroext %39)
%44 = load i8, i8* %10
%45 = lshr i8 %44, 4
%46 = and i8 %44, 15
%47 = tail call zeroext i8 @getvoxel(i8 zeroext %45, i8 zeroext %46, i32 4)
%48 = load i8, i8* %11
%49 = lshr i8 %48, 4
%50 = and i8 %48, 15
%51 = tail call i32 @altervoxel(i8 zeroext %49, i8 zeroext %50, i32 4, i8 zeroext %47)
%52 = load i8, i8* %10
%53 = lshr i8 %52, 4
%54 = and i8 %52, 15
%55 = tail call zeroext i8 @getvoxel(i8 zeroext %53, i8 zeroext %54, i32 5)
%56 = load i8, i8* %11
%57 = lshr i8 %56, 4
%58 = and i8 %56, 15
%59 = tail call i32 @altervoxel(i8 zeroext %57, i8 zeroext %58, i32 5, i8 zeroext %55)
%60 = load i8, i8* %10
%61 = lshr i8 %60, 4
%62 = and i8 %60, 15
%63 = tail call zeroext i8 @getvoxel(i8 zeroext %61, i8 zeroext %62, i32 6)
%64 = load i8, i8* %11
%65 = lshr i8 %64, 4
%66 = and i8 %64, 15
%67 = tail call i32 @altervoxel(i8 zeroext %65, i8 zeroext %66, i32 6, i8 zeroext %63)
%68 = load i8, i8* %10
%69 = lshr i8 %68, 4
%70 = and i8 %68, 15
%71 = tail call zeroext i8 @getvoxel(i8 zeroext %69, i8 zeroext %70, i32 7)
%72 = load i8, i8* %11
%73 = lshr i8 %72, 4
%74 = and i8 %72, 15
%75 = tail call i32 @altervoxel(i8 zeroext %73, i8 zeroext %74, i32 7, i8 zeroext %71)
%76 = icmp ugt i64 %7, 2
br i1 %76, label %6, label %77
77: ; preds = %6, %2
%78 = load i8, i8* %0
%79 = lshr i8 %78, 4
%80 = and i8 %78, 15
%81 = tail call i32 @clrvoxel(i8 zeroext %79, i8 zeroext %80, i32 0)
%82 = load i8, i8* %0
%83 = lshr i8 %82, 4
%84 = and i8 %82, 15
%85 = tail call i32 @clrvoxel(i8 zeroext %83, i8 zeroext %84, i32 1)
%86 = load i8, i8* %0
%87 = lshr i8 %86, 4
%88 = and i8 %86, 15
%89 = tail call i32 @clrvoxel(i8 zeroext %87, i8 zeroext %88, i32 2)
%90 = load i8, i8* %0
%91 = lshr i8 %90, 4
%92 = and i8 %90, 15
%93 = tail call i32 @clrvoxel(i8 zeroext %91, i8 zeroext %92, i32 3)
%94 = load i8, i8* %0
%95 = lshr i8 %94, 4
%96 = and i8 %94, 15
%97 = tail call i32 @clrvoxel(i8 zeroext %95, i8 zeroext %96, i32 4)
%98 = load i8, i8* %0
%99 = lshr i8 %98, 4
%100 = and i8 %98, 15
%101 = tail call i32 @clrvoxel(i8 zeroext %99, i8 zeroext %100, i32 5)
%102 = load i8, i8* %0
%103 = lshr i8 %102, 4
%104 = and i8 %102, 15
%105 = tail call i32 @clrvoxel(i8 zeroext %103, i8 zeroext %104, i32 6)
%106 = load i8, i8* %0
%107 = lshr i8 %106, 4
%108 = and i8 %106, 15
%109 = tail call i32 @clrvoxel(i8 zeroext %107, i8 zeroext %108, i32 7)
ret void
}