#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);
int /*<<< orphan*/ printf(char *, int);
char *queue_state(int s) {
  switch (s) {
  case 42:
    return "PRODUCER_DONE";
  case 43:
    return "WORKER_NOT_STARTED";
  case 44:
    return "WORKER_DONE";
  case 45:
    return "WORKING";
  case 46:
    return "WANT_QUEUE";
  case 0:
    return "Q0";
  case 1:
    return "Q1";
  case 2:
    return "Q2";
  case 3:
    return "Q3";
  default:
    printf("Bad queue state %d\n", s);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<queue_state>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x2e,%rax
ja     11e0 <queue_state+0xc0>
mov    -0x18(%rbp),%rax
lea    0xeb9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf65(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f9 <queue_state+0xd9>
lea    0xf63(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f9 <queue_state+0xd9>
lea    0xf66(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f9 <queue_state+0xd9>
lea    0xf62(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f9 <queue_state+0xd9>
lea    0xf5a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f9 <queue_state+0xd9>
lea    0xf55(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f9 <queue_state+0xd9>
lea    0xf48(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f9 <queue_state+0xd9>
lea    0xf3b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f9 <queue_state+0xd9>
lea    0xf2e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f9 <queue_state+0xd9>
mov    -0xc(%rbp),%esi
lea    0xf1e(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<queue_state>:
push   %rax
mov    %edi,%esi
cmp    $0x2e,%edi
ja     1189 <queue_state+0x69>
lea    0xf8d(%rip),%rax
mov    %esi,%ecx
lea    0xec8(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
lea    0xfb4(%rip),%rax
pop    %rcx
ret
lea    0xfae(%rip),%rax
pop    %rcx
ret
lea    0xfa8(%rip),%rax
pop    %rcx
ret
lea    0xfa2(%rip),%rax
pop    %rcx
ret
lea    0xf5e(%rip),%rax
pop    %rcx
ret
lea    0xf68(%rip),%rax
pop    %rcx
ret
lea    0xf6b(%rip),%rax
pop    %rcx
ret
lea    0xf6a(%rip),%rax
pop    %rcx
ret
lea    0xf78(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"PRODUCER_DONE\00"
@.str.1 = [19 x i8] c"WORKER_NOT_STARTED\00"
@.str.2 = [12 x i8] c"WORKER_DONE\00"
@.str.3 = [8 x i8] c"WORKING\00"
@.str.4 = [11 x i8] c"WANT_QUEUE\00"
@.str.5 = [3 x i8] c"Q0\00"
@.str.6 = [3 x i8] c"Q1\00"
@.str.7 = [3 x i8] c"Q2\00"
@.str.8 = [3 x i8] c"Q3\00"
@.str.9 = [20 x i8] c"Bad queue state %d\0A\00"
define i8* @queue_state(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %14 [
i32 42, label %5
i32 43, label %6
i32 44, label %7
i32 45, label %8
i32 46, label %9
i32 0, label %10
i32 1, label %11
i32 2, label %12
i32 3, label %13
]
5: ; preds = %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %2
br label %18
6: ; preds = %1
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %18
7: ; preds = %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %18
8: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %18
9: ; preds = %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %18
10: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %18
11: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %18
12: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %18
13: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %18
14: ; preds = %1
%15 = load i32, i32* %3
%16 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i32 %15)
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %13, %12, %11, %10, %9, %8, %7, %6, %5
%19 = load i8*, i8** %2
ret i8* %19
}

LLVM IR (-O2):
@.str = [14 x i8] c"PRODUCER_DONE\00"
@.str.1 = [19 x i8] c"WORKER_NOT_STARTED\00"
@.str.2 = [12 x i8] c"WORKER_DONE\00"
@.str.3 = [8 x i8] c"WORKING\00"
@.str.4 = [11 x i8] c"WANT_QUEUE\00"
@.str.5 = [3 x i8] c"Q0\00"
@.str.6 = [3 x i8] c"Q1\00"
@.str.7 = [3 x i8] c"Q2\00"
@.str.8 = [3 x i8] c"Q3\00"
@.str.9 = [20 x i8] c"Bad queue state %d\0A\00"
define i8* @queue_state(i32 %0) {
switch i32 %0, label %10 [
i32 42, label %13
i32 43, label %2
i32 44, label %3
i32 45, label %4
i32 46, label %5
i32 0, label %6
i32 1, label %7
i32 2, label %8
i32 3, label %9
]
2: ; preds = %1
br label %13
3: ; preds = %1
br label %13
4: ; preds = %1
br label %13
5: ; preds = %1
br label %13
6: ; preds = %1
br label %13
7: ; preds = %1
br label %13
8: ; preds = %1
br label %13
9: ; preds = %1
br label %13
10: ; preds = %1
%11 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i32 %0)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %1, %9, %8, %7, %6, %5, %4, %3, %2
%14 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), %9 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), %8 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), %7 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), %6 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %14
}