#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);
const char *pls_state(int state) {
  switch (state) {
  case 14:
    return "PLS_NEED_DATA";
  case 18:
    return "PLS_ALL_BUFFERS_READY";
  case 21:
    return "PLS_DONE";
  default:
    printf("\nerror: unknown pls_state %d\n", state);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<pls_state>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0xe,%eax
je     1161 <pls_state+0x41>
jmp    113f <pls_state+0x1f>
mov    -0x10(%rbp),%eax
sub    $0x12,%eax
je     1171 <pls_state+0x51>
jmp    1150 <pls_state+0x30>
mov    -0x10(%rbp),%eax
sub    $0x15,%eax
je     1181 <pls_state+0x61>
jmp    1191 <pls_state+0x71>
lea    0xe98(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11aa <pls_state+0x8a>
lea    0xe96(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11aa <pls_state+0x8a>
lea    0xe9c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11aa <pls_state+0x8a>
mov    -0xc(%rbp),%esi
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pls_state>:
cmp    $0xe,%edi
je     1139 <pls_state+0x19>
mov    %edi,%esi
cmp    $0x15,%edi
je     1141 <pls_state+0x21>
cmp    $0x12,%esi
jne    1149 <pls_state+0x29>
lea    0xed6(%rip),%rax
ret
lea    0xec0(%rip),%rax
ret
lea    0xedc(%rip),%rax
ret
push   %rax
lea    0xedc(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"PLS_NEED_DATA\00"
@.str.1 = [22 x i8] c"PLS_ALL_BUFFERS_READY\00"
@.str.2 = [9 x i8] c"PLS_DONE\00"
@.str.3 = [30 x i8] c"\0Aerror: unknown pls_state %d\0A\00"
define i8* @pls_state(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %8 [
i32 14, label %5
i32 18, label %6
i32 21, label %7
]
5: ; preds = %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %2
br label %12
6: ; preds = %1
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %12
7: ; preds = %1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %12
8: ; preds = %1
%9 = load i32, i32* %3
%10 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %9)
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %7, %6, %5
%13 = load i8*, i8** %2
ret i8* %13
}

LLVM IR (-O2):
@.str = [14 x i8] c"PLS_NEED_DATA\00"
@.str.1 = [22 x i8] c"PLS_ALL_BUFFERS_READY\00"
@.str.2 = [9 x i8] c"PLS_DONE\00"
@.str.3 = [30 x i8] c"\0Aerror: unknown pls_state %d\0A\00"
define i8* @pls_state(i32 %0) {
switch i32 %0, label %4 [
i32 14, label %7
i32 18, label %2
i32 21, label %3
]
2: ; preds = %1
br label %7
3: ; preds = %1
br label %7
4: ; preds = %1
%5 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %0)
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %1, %3, %2
%8 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([22 x i8], [22 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* %8
}