#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stdout;
void determineAvailableColours(int usedColour, int *availableColours) {
  switch (usedColour) {
  case 1:
    availableColours[0] = 2;
    availableColours[1] = 3;
    break;
  case 2:
    availableColours[0] = 1;
    availableColours[1] = 3;
    break;
  case 3:
    availableColours[0] = 1;
    availableColours[1] = 2;
    break;
  default:
    fprintf(stdout, "Invalid previous colour");
    exit(0);
  }
}


x86 assembly (clang, -O0):
<determineAvailableColours>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x1,%eax
je     1165 <determineAvailableColours+0x45>
jmp    1143 <determineAvailableColours+0x23>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     117f <determineAvailableColours+0x5f>
jmp    1154 <determineAvailableColours+0x34>
mov    -0x14(%rbp),%eax
sub    $0x3,%eax
je     1199 <determineAvailableColours+0x79>
jmp    11b3 <determineAvailableColours+0x93>
mov    -0x10(%rbp),%rax
movl   $0x2,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x3,0x4(%rax)
jmp    11cf <determineAvailableColours+0xaf>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x3,0x4(%rax)
jmp    11cf <determineAvailableColours+0xaf>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x2,0x4(%rax)
jmp    11cf <determineAvailableColours+0xaf>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
lea    0xe3d(%rip),%rsi
call   1030 <fprintf@plt>
xor    %edi,%edi
call   1040 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<determineAvailableColours>:
push   %rax
add    $0xffffffff,%edi
cmp    $0x3,%edi
jae    1147 <determineAvailableColours+0x27>
movslq %edi,%rax
lea    0xee5(%rip),%rcx
mov    (%rcx,%rax,4),%ecx
lea    0xee7(%rip),%rdx
mov    (%rdx,%rax,4),%eax
mov    %ecx,(%rsi)
mov    %eax,0x4(%rsi)
pop    %rax
ret
mov    0x2e92(%rip),%rax
mov    (%rax),%edi
lea    0xea9(%rip),%rsi
call   1030 <fprintf@plt>
xor    %edi,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [24 x i8] c"Invalid previous colour\00"
define void @determineAvailableColours(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
store i32 %0, i32* %3
store i32* %1, i32** %4
%5 = load i32, i32* %3
switch i32 %5, label %21 [
i32 1, label %6
i32 2, label %11
i32 3, label %16
]
6: ; preds = %2
%7 = load i32*, i32** %4
%8 = getelementptr inbounds i32, i32* %7, i64 0
store i32 2, i32* %8
%9 = load i32*, i32** %4
%10 = getelementptr inbounds i32, i32* %9, i64 1
store i32 3, i32* %10
br label %25
11: ; preds = %2
%12 = load i32*, i32** %4
%13 = getelementptr inbounds i32, i32* %12, i64 0
store i32 1, i32* %13
%14 = load i32*, i32** %4
%15 = getelementptr inbounds i32, i32* %14, i64 1
store i32 3, i32* %15
br label %25
16: ; preds = %2
%17 = load i32*, i32** %4
%18 = getelementptr inbounds i32, i32* %17, i64 0
store i32 1, i32* %18
%19 = load i32*, i32** %4
%20 = getelementptr inbounds i32, i32* %19, i64 1
store i32 2, i32* %20
br label %25
21: ; preds = %2
%22 = load i32, i32* @stdout
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%24 = call i32 @exit(i32 0)
unreachable
25: ; preds = %16, %11, %6
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [24 x i8] c"Invalid previous colour\00"
@switch.table.determineAvailableColours = [3 x i32] [i32 2, i32 1, i32 1]
@switch.table.determineAvailableColours.1 = [3 x i32] [i32 3, i32 3, i32 2]
define void @determineAvailableColours(i32 %0, i32* nocapture writeonly %1) {
%3 = add i32 %0, -1
%4 = icmp ult i32 %3, 3
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = load i32, i32* @stdout
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 0)
unreachable
9: ; preds = %2
%10 = sext i32 %3 to i64
%11 = getelementptr inbounds [3 x i32], [3 x i32]* @switch.table.determineAvailableColours, i64 0, i64 %10
%12 = load i32, i32* %11
%13 = sext i32 %3 to i64
%14 = getelementptr inbounds [3 x i32], [3 x i32]* @switch.table.determineAvailableColours.1, i64 0, i64 %13
%15 = load i32, i32* %14
store i32 %12, i32* %1
%16 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %15, i32* %16
ret void
}