#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*/ fill(int);
int /*<<< orphan*/ setvoxel(int, int, int);
void draw_positions_axis(char axis, unsigned char positions[64], int invert) {
  int x, y, p;
  fill(0x00);
  for (x = 0; x < 8; x++) {
    for (y = 0; y < 8; y++) {
      if (invert) {
        p = (7 - positions[(x * 8) + y]);
      } else {
        p = positions[(x * 8) + y];
      }
      if (axis == 3)
        setvoxel(x, y, p);
      if (axis == 2)
        setvoxel(x, p, y);
      if (axis == 1)
        setvoxel(p, y, x);
    }
  }
}


x86 assembly (clang, -O0):
<draw_positions_axis>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
xor    %edi,%edi
call   1030 <fill@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x8,-0x18(%rbp)
jge    1219 <draw_positions_axis+0xf9>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x8,-0x1c(%rbp)
jge    1206 <draw_positions_axis+0xe6>
cmpl   $0x0,-0x14(%rbp)
je     118b <draw_positions_axis+0x6b>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
shl    $0x3,%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%ecx
mov    $0x7,%eax
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
jmp    11a2 <draw_positions_axis+0x82>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
shl    $0x3,%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x20(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x3,%eax
jne    11bd <draw_positions_axis+0x9d>
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1040 <setvoxel@plt>
movsbl -0x1(%rbp),%eax
cmp    $0x2,%eax
jne    11d8 <draw_positions_axis+0xb8>
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1040 <setvoxel@plt>
movsbl -0x1(%rbp),%eax
cmp    $0x1,%eax
jne    11f3 <draw_positions_axis+0xd3>
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <setvoxel@plt>
jmp    11f8 <draw_positions_axis+0xd8>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1154 <draw_positions_axis+0x34>
jmp    120b <draw_positions_axis+0xeb>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1143 <draw_positions_axis+0x23>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_positions_axis>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %rsi,%r12
mov    %edi,%ebp
xor    %r15d,%r15d
xor    %edi,%edi
call   1030 <fill@plt>
jmp    114e <draw_positions_axis+0x2e>
nopl   0x0(%rax)
add    $0x1,%r15
add    $0x8,%r12
cmp    $0x8,%r15
je     11b9 <draw_positions_axis+0x99>
xor    %ebx,%ebx
jmp    1176 <draw_positions_axis+0x56>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15d,%edi
mov    %edx,%esi
mov    %ebx,%edx
call   1040 <setvoxel@plt>
add    $0x1,%rbx
cmp    $0x8,%rbx
je     1140 <draw_positions_axis+0x20>
movzbl (%r12,%rbx,1),%eax
mov    $0x7,%edx
sub    %eax,%edx
test   %r14d,%r14d
cmove  %eax,%edx
cmp    $0x1,%bpl
je     11b0 <draw_positions_axis+0x90>
cmp    $0x2,%bpl
je     1160 <draw_positions_axis+0x40>
cmp    $0x3,%bpl
jne    116c <draw_positions_axis+0x4c>
mov    %r15d,%edi
mov    %ebx,%esi
jmp    1167 <draw_positions_axis+0x47>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %edx,%edi
mov    %ebx,%esi
mov    %r15d,%edx
jmp    1167 <draw_positions_axis+0x47>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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