int dirlist3d(long long itemp, int *dirlist) {
  if (itemp == 0) {
    dirlist[1] = 1;
    dirlist[2] = 2;
    dirlist[3] = 3;
  } else if (itemp == 1) {
    dirlist[1] = 3;
    dirlist[2] = 1;
    dirlist[3] = 2;
  } else if (itemp == 2) {
    dirlist[1] = 2;
    dirlist[2] = 3;
    dirlist[3] = 1;
  } else if (itemp == 3) {
    dirlist[1] = 3;
    dirlist[2] = 2;
    dirlist[3] = 1;
  } else if (itemp == 4) {
    dirlist[1] = 1;
    dirlist[2] = 3;
    dirlist[3] = 2;
  } else if (itemp == 5) {
    dirlist[1] = 2;
    dirlist[2] = 1;
    dirlist[3] = 3;
  }
  return (0);
}


x86 assembly (clang, -O0):
<dirlist3d>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    113d <dirlist3d+0x3d>
mov    -0x10(%rbp),%rax
movl   $0x1,0x4(%rax)
mov    -0x10(%rbp),%rax
movl   $0x2,0x8(%rax)
mov    -0x10(%rbp),%rax
movl   $0x3,0xc(%rax)
jmp    1246 <dirlist3d+0x146>
cmpq   $0x1,-0x8(%rbp)
jne    116e <dirlist3d+0x6e>
mov    -0x10(%rbp),%rax
movl   $0x3,0x4(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,0x8(%rax)
mov    -0x10(%rbp),%rax
movl   $0x2,0xc(%rax)
jmp    1241 <dirlist3d+0x141>
cmpq   $0x2,-0x8(%rbp)
jne    119f <dirlist3d+0x9f>
mov    -0x10(%rbp),%rax
movl   $0x2,0x4(%rax)
mov    -0x10(%rbp),%rax
movl   $0x3,0x8(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,0xc(%rax)
jmp    123c <dirlist3d+0x13c>
cmpq   $0x3,-0x8(%rbp)
jne    11d0 <dirlist3d+0xd0>
mov    -0x10(%rbp),%rax
movl   $0x3,0x4(%rax)
mov    -0x10(%rbp),%rax
movl   $0x2,0x8(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,0xc(%rax)
jmp    1237 <dirlist3d+0x137>
cmpq   $0x4,-0x8(%rbp)
jne    1201 <dirlist3d+0x101>
mov    -0x10(%rbp),%rax
movl   $0x1,0x4(%rax)
mov    -0x10(%rbp),%rax
movl   $0x3,0x8(%rax)
mov    -0x10(%rbp),%rax
movl   $0x2,0xc(%rax)
jmp    1232 <dirlist3d+0x132>
cmpq   $0x5,-0x8(%rbp)
jne    122d <dirlist3d+0x12d>
mov    -0x10(%rbp),%rax
movl   $0x2,0x4(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,0x8(%rax)
mov    -0x10(%rbp),%rax
movl   $0x3,0xc(%rax)
jmp    1232 <dirlist3d+0x132>
jmp    1237 <dirlist3d+0x137>
jmp    123c <dirlist3d+0x13c>
jmp    1241 <dirlist3d+0x141>
jmp    1246 <dirlist3d+0x146>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<dirlist3d>:
cmp    $0x5,%rdi
ja     112d <dirlist3d+0x2d>
lea    0xef3(%rip),%rax
mov    (%rax,%rdi,4),%eax
lea    0xf01(%rip),%rcx
mov    (%rcx,%rdi,4),%ecx
lea    0xf0f(%rip),%rdx
mov    (%rdx,%rdi,4),%edx
mov    %eax,0x4(%rsi)
mov    %ecx,0x8(%rsi)
mov    %edx,0xc(%rsi)
xor    %eax,%eax
ret

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

LLVM IR (-O2):
@switch.table.dirlist3d = [6 x i32] [i32 1, i32 3, i32 2, i32 3, i32 1, i32 2]
@switch.table.dirlist3d.1 = [6 x i32] [i32 2, i32 1, i32 3, i32 2, i32 3, i32 1]
@switch.table.dirlist3d.2 = [6 x i32] [i32 3, i32 2, i32 1, i32 1, i32 2, i32 3]
define i32 @dirlist3d(i64 %0, i32* nocapture writeonly %1) {
%3 = icmp ult i64 %0, 6
br i1 %3, label %4, label %14
4: ; preds = %2
%5 = getelementptr inbounds [6 x i32], [6 x i32]* @switch.table.dirlist3d, i64 0, i64 %0
%6 = load i32, i32* %5
%7 = getelementptr inbounds [6 x i32], [6 x i32]* @switch.table.dirlist3d.1, i64 0, i64 %0
%8 = load i32, i32* %7
%9 = getelementptr inbounds [6 x i32], [6 x i32]* @switch.table.dirlist3d.2, i64 0, i64 %0
%10 = load i32, i32* %9
%11 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %6, i32* %11
%12 = getelementptr inbounds i32, i32* %1, i64 2
store i32 %8, i32* %12
%13 = getelementptr inbounds i32, i32* %1, i64 3
store i32 %10, i32* %13
br label %14
14: ; preds = %2, %4
ret i32 0
}