#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*/ usb_request_error();
int /*<<< orphan*/ usb_setup_clear_device_feature(unsigned char);
int /*<<< orphan*/ usb_setup_clear_endpoint_feature(unsigned char,
                                                    unsigned char);
int /*<<< orphan*/ usb_setup_get_configuration();
int /*<<< orphan*/ usb_setup_get_descriptor(unsigned char, unsigned char,
                                            unsigned char, unsigned char);
int /*<<< orphan*/ usb_setup_get_device_status();
int /*<<< orphan*/ usb_setup_get_endpoint_status(unsigned char);
int /*<<< orphan*/ usb_setup_get_interface(unsigned char);
int /*<<< orphan*/ usb_setup_get_interface_status(unsigned char);
int /*<<< orphan*/ usb_setup_set_address(unsigned char);
int /*<<< orphan*/ usb_setup_set_configuration(unsigned char);
int /*<<< orphan*/ usb_setup_set_device_feature(unsigned char);
int /*<<< orphan*/ usb_setup_set_endpoint_feature(unsigned char, unsigned char);
int /*<<< orphan*/ usb_setup_set_interface(unsigned char, unsigned char);
void usb_handle_setup_pkt(unsigned char *pkt) {
  switch ((pkt[0] << 8) | pkt[1]) {
  case 0x0005:;
    usb_setup_set_address(pkt[2]);
    break;
  case 0x8006:;
    usb_setup_get_descriptor(pkt[3], pkt[2], (pkt[5] << 8) | pkt[4],
                             (pkt[7] << 8) | pkt[6]);
    break;
  case 0x8008:
    usb_setup_get_configuration();
    break;
  case 0x0009:
    usb_setup_set_configuration(pkt[2]);
    break;
  case 0x8000:
    usb_setup_get_device_status();
    break;
  case 0x8100:
    usb_setup_get_interface_status(pkt[4]);
    break;
  case 0x8200:
    usb_setup_get_endpoint_status(pkt[4]);
    break;
  case 0x0001:
    usb_setup_clear_device_feature(pkt[2]);
    break;
  case 0x0201:
    usb_setup_clear_endpoint_feature(pkt[4], pkt[2]);
    break;
  case 0x0003:
    usb_setup_set_device_feature(pkt[2]);
    break;
  case 0x0203:
    usb_setup_set_endpoint_feature(pkt[4], pkt[2]);
    break;
  case 0x810a:
    usb_setup_get_interface(pkt[4]);
    break;
  case 0x010b:
    usb_setup_set_interface(pkt[4], pkt[2]);
    break;
  case 0x0103:
  case 0x0101:
  case 0x0007:
  case 0x820c:
  default:
    usb_request_error();
  }
}


x86 assembly (clang, -O0):
<usb_handle_setup_pkt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movzwl (%rax),%eax
shl    $0x10,%eax
bswap  %eax
mov    %eax,-0xc(%rbp)
sub    $0x1,%eax
je     13e3 <usb_handle_setup_pkt+0x203>
jmp    1209 <usb_handle_setup_pkt+0x29>
mov    -0xc(%rbp),%eax
sub    $0x3,%eax
je     1411 <usb_handle_setup_pkt+0x231>
jmp    121a <usb_handle_setup_pkt+0x3a>
mov    -0xc(%rbp),%eax
sub    $0x5,%eax
je     1331 <usb_handle_setup_pkt+0x151>
jmp    122b <usb_handle_setup_pkt+0x4b>
mov    -0xc(%rbp),%eax
sub    $0x7,%eax
je     146d <usb_handle_setup_pkt+0x28d>
jmp    123c <usb_handle_setup_pkt+0x5c>
mov    -0xc(%rbp),%eax
sub    $0x9,%eax
je     13a1 <usb_handle_setup_pkt+0x1c1>
jmp    124d <usb_handle_setup_pkt+0x6d>
mov    -0xc(%rbp),%eax
sub    $0x101,%eax
je     146d <usb_handle_setup_pkt+0x28d>
jmp    1260 <usb_handle_setup_pkt+0x80>
mov    -0xc(%rbp),%eax
sub    $0x103,%eax
je     146d <usb_handle_setup_pkt+0x28d>
jmp    1273 <usb_handle_setup_pkt+0x93>
mov    -0xc(%rbp),%eax
sub    $0x10b,%eax
je     1451 <usb_handle_setup_pkt+0x271>
jmp    1286 <usb_handle_setup_pkt+0xa6>
mov    -0xc(%rbp),%eax
sub    $0x201,%eax
je     13f5 <usb_handle_setup_pkt+0x215>
jmp    1299 <usb_handle_setup_pkt+0xb9>
mov    -0xc(%rbp),%eax
sub    $0x203,%eax
je     1423 <usb_handle_setup_pkt+0x243>
jmp    12ac <usb_handle_setup_pkt+0xcc>
mov    -0xc(%rbp),%eax
sub    $0x8000,%eax
je     13b3 <usb_handle_setup_pkt+0x1d3>
jmp    12bf <usb_handle_setup_pkt+0xdf>
mov    -0xc(%rbp),%eax
sub    $0x8006,%eax
je     1343 <usb_handle_setup_pkt+0x163>
jmp    12d2 <usb_handle_setup_pkt+0xf2>
mov    -0xc(%rbp),%eax
sub    $0x8008,%eax
je     1395 <usb_handle_setup_pkt+0x1b5>
jmp    12e5 <usb_handle_setup_pkt+0x105>
mov    -0xc(%rbp),%eax
sub    $0x8100,%eax
je     13bf <usb_handle_setup_pkt+0x1df>
jmp    12f8 <usb_handle_setup_pkt+0x118>
mov    -0xc(%rbp),%eax
sub    $0x810a,%eax
je     143f <usb_handle_setup_pkt+0x25f>
jmp    130b <usb_handle_setup_pkt+0x12b>
mov    -0xc(%rbp),%eax
sub    $0x8200,%eax
je     13d1 <usb_handle_setup_pkt+0x1f1>
jmp    131e <usb_handle_setup_pkt+0x13e>
mov    -0xc(%rbp),%eax
sub    $0x820c,%eax
je     146d <usb_handle_setup_pkt+0x28d>
jmp    1472 <usb_handle_setup_pkt+0x292>
mov    -0x8(%rbp),%rax
movzbl 0x2(%rax),%edi
call   1090 <usb_setup_set_address@plt>
jmp    1479 <usb_handle_setup_pkt+0x299>
mov    -0x8(%rbp),%rax
mov    0x3(%rax),%sil
mov    -0x8(%rbp),%rax
mov    0x2(%rax),%dl
mov    -0x8(%rbp),%rax
movzbl 0x5(%rax),%eax
shl    $0x8,%eax
mov    -0x8(%rbp),%rcx
movzbl 0x4(%rcx),%ecx
or     %ecx,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
movzbl 0x7(%rax),%eax
shl    $0x8,%eax
mov    -0x8(%rbp),%rdi
movzbl 0x6(%rdi),%edi
or     %edi,%eax
movzbl %sil,%edi
movzbl %dl,%esi
movzbl %cl,%edx
movzbl %al,%ecx
call   1040 <usb_setup_get_descriptor@plt>
jmp    1479 <usb_handle_setup_pkt+0x299>
mov    $0x0,%al
call   1100 <usb_setup_get_configuration@plt>
jmp    1479 <usb_handle_setup_pkt+0x299>
mov    -0x8(%rbp),%rax
movzbl 0x2(%rax),%edi
call   10b0 <usb_setup_set_configuration@plt>
jmp    1479 <usb_handle_setup_pkt+0x299>
mov    $0x0,%al
call   1050 <usb_setup_get_device_status@plt>
jmp    1479 <usb_handle_setup_pkt+0x299>
mov    -0x8(%rbp),%rax
movzbl 0x4(%rax),%edi
call   10d0 <usb_setup_get_interface_status@plt>
jmp    1479 <usb_handle_setup_pkt+0x299>
mov    -0x8(%rbp),%rax
movzbl 0x4(%rax),%edi
call   10c0 <usb_setup_get_endpoint_status@plt>
jmp    1479 <usb_handle_setup_pkt+0x299>
mov    -0x8(%rbp),%rax
movzbl 0x2(%rax),%edi
call   1030 <usb_setup_clear_device_feature@plt>
jmp    1479 <usb_handle_setup_pkt+0x299>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%cl
mov    -0x8(%rbp),%rax
movzbl %cl,%edi
movzbl 0x2(%rax),%esi
call   10f0 <usb_setup_clear_endpoint_feature@plt>
jmp    1479 <usb_handle_setup_pkt+0x299>
mov    -0x8(%rbp),%rax
movzbl 0x2(%rax),%edi
call   1080 <usb_setup_set_device_feature@plt>
jmp    1479 <usb_handle_setup_pkt+0x299>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%cl
mov    -0x8(%rbp),%rax
movzbl %cl,%edi
movzbl 0x2(%rax),%esi
call   10a0 <usb_setup_set_endpoint_feature@plt>
jmp    1479 <usb_handle_setup_pkt+0x299>
mov    -0x8(%rbp),%rax
movzbl 0x4(%rax),%edi
call   10e0 <usb_setup_get_interface@plt>
jmp    1479 <usb_handle_setup_pkt+0x299>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%cl
mov    -0x8(%rbp),%rax
movzbl %cl,%edi
movzbl 0x2(%rax),%esi
call   1070 <usb_setup_set_interface@plt>
jmp    1479 <usb_handle_setup_pkt+0x299>
jmp    1472 <usb_handle_setup_pkt+0x292>
mov    $0x0,%al
call   1060 <usb_request_error@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<usb_handle_setup_pkt>:
movzwl (%rdi),%eax
rol    $0x8,%ax
movswl %ax,%ecx
test   %ax,%ax
jle    1220 <usb_handle_setup_pkt+0x40>
cmp    $0x10a,%ecx
jg     1253 <usb_handle_setup_pkt+0x73>
add    $0xffffffff,%eax
cmp    $0x8,%ax
ja     1309 <usb_handle_setup_pkt+0x129>
movzwl %ax,%eax
lea    0xdf2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movzbl 0x2(%rdi),%edi
jmp    1030 <usb_setup_clear_device_feature@plt>
movzwl %ax,%eax
cmp    $0xffff80ff,%ecx
jg     1282 <usb_handle_setup_pkt+0xa2>
cmp    $0x8000,%eax
je     12bb <usb_handle_setup_pkt+0xdb>
cmp    $0x8006,%eax
je     12c2 <usb_handle_setup_pkt+0xe2>
cmp    $0x8008,%eax
jne    1309 <usb_handle_setup_pkt+0x129>
xor    %eax,%eax
jmp    1100 <usb_setup_get_configuration@plt>
movzwl %ax,%eax
cmp    $0x10b,%eax
je     12d9 <usb_handle_setup_pkt+0xf9>
cmp    $0x201,%eax
je     12e8 <usb_handle_setup_pkt+0x108>
cmp    $0x203,%eax
jne    1309 <usb_handle_setup_pkt+0x129>
movzbl 0x4(%rdi),%eax
movzbl 0x2(%rdi),%esi
mov    %eax,%edi
jmp    10a0 <usb_setup_set_endpoint_feature@plt>
cmp    $0x8100,%eax
je     12f7 <usb_handle_setup_pkt+0x117>
cmp    $0x810a,%eax
je     1300 <usb_handle_setup_pkt+0x120>
cmp    $0x8200,%eax
jne    1309 <usb_handle_setup_pkt+0x129>
movzbl 0x4(%rdi),%edi
jmp    10c0 <usb_setup_get_endpoint_status@plt>
movzbl 0x2(%rdi),%edi
jmp    1080 <usb_setup_set_device_feature@plt>
movzbl 0x2(%rdi),%edi
jmp    1090 <usb_setup_set_address@plt>
movzbl 0x2(%rdi),%edi
jmp    10b0 <usb_setup_set_configuration@plt>
xor    %eax,%eax
jmp    1050 <usb_setup_get_device_status@plt>
movzbl 0x3(%rdi),%eax
movzbl 0x2(%rdi),%esi
movzbl 0x4(%rdi),%edx
movzbl 0x6(%rdi),%ecx
mov    %eax,%edi
jmp    1040 <usb_setup_get_descriptor@plt>
movzbl 0x4(%rdi),%eax
movzbl 0x2(%rdi),%esi
mov    %eax,%edi
jmp    1070 <usb_setup_set_interface@plt>
movzbl 0x4(%rdi),%eax
movzbl 0x2(%rdi),%esi
mov    %eax,%edi
jmp    10f0 <usb_setup_clear_endpoint_feature@plt>
movzbl 0x4(%rdi),%edi
jmp    10d0 <usb_setup_get_interface_status@plt>
movzbl 0x4(%rdi),%edi
jmp    10e0 <usb_setup_get_interface@plt>
xor    %eax,%eax
jmp    1060 <usb_request_error@plt>

LLVM IR (-O0):
define void @usb_handle_setup_pkt(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = getelementptr inbounds i8, i8* %3, i64 0
%5 = load i8, i8* %4
%6 = zext i8 %5 to i32
%7 = shl i32 %6, 8
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = load i8, i8* %9
%11 = zext i8 %10 to i32
%12 = or i32 %7, %11
switch i32 %12, label %107 [
i32 5, label %13
i32 32774, label %18
i32 32776, label %48
i32 9, label %50
i32 32768, label %55
i32 33024, label %57
i32 33280, label %62
i32 1, label %67
i32 513, label %72
i32 3, label %80
i32 515, label %85
i32 33034, label %93
i32 267, label %98
i32 259, label %106
i32 257, label %106
i32 7, label %106
i32 33292, label %106
]
13: ; preds = %1
%14 = load i8*, i8** %2
%15 = getelementptr inbounds i8, i8* %14, i64 2
%16 = load i8, i8* %15
%17 = call i32 @usb_setup_set_address(i8 zeroext %16)
br label %109
18: ; preds = %1
%19 = load i8*, i8** %2
%20 = getelementptr inbounds i8, i8* %19, i64 3
%21 = load i8, i8* %20
%22 = load i8*, i8** %2
%23 = getelementptr inbounds i8, i8* %22, i64 2
%24 = load i8, i8* %23
%25 = load i8*, i8** %2
%26 = getelementptr inbounds i8, i8* %25, i64 5
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = shl i32 %28, 8
%30 = load i8*, i8** %2
%31 = getelementptr inbounds i8, i8* %30, i64 4
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = or i32 %29, %33
%35 = trunc i32 %34 to i8
%36 = load i8*, i8** %2
%37 = getelementptr inbounds i8, i8* %36, i64 7
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = shl i32 %39, 8
%41 = load i8*, i8** %2
%42 = getelementptr inbounds i8, i8* %41, i64 6
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
%45 = or i32 %40, %44
%46 = trunc i32 %45 to i8
%47 = call i32 @usb_setup_get_descriptor(i8 zeroext %21, i8 zeroext %24, i8 zeroext %35, i8 zeroext %46)
br label %109
48: ; preds = %1
%49 = call i32 (...) @usb_setup_get_configuration()
br label %109
50: ; preds = %1
%51 = load i8*, i8** %2
%52 = getelementptr inbounds i8, i8* %51, i64 2
%53 = load i8, i8* %52
%54 = call i32 @usb_setup_set_configuration(i8 zeroext %53)
br label %109
55: ; preds = %1
%56 = call i32 (...) @usb_setup_get_device_status()
br label %109
57: ; preds = %1
%58 = load i8*, i8** %2
%59 = getelementptr inbounds i8, i8* %58, i64 4
%60 = load i8, i8* %59
%61 = call i32 @usb_setup_get_interface_status(i8 zeroext %60)
br label %109
62: ; preds = %1
%63 = load i8*, i8** %2
%64 = getelementptr inbounds i8, i8* %63, i64 4
%65 = load i8, i8* %64
%66 = call i32 @usb_setup_get_endpoint_status(i8 zeroext %65)
br label %109
67: ; preds = %1
%68 = load i8*, i8** %2
%69 = getelementptr inbounds i8, i8* %68, i64 2
%70 = load i8, i8* %69
%71 = call i32 @usb_setup_clear_device_feature(i8 zeroext %70)
br label %109
72: ; preds = %1
%73 = load i8*, i8** %2
%74 = getelementptr inbounds i8, i8* %73, i64 4
%75 = load i8, i8* %74
%76 = load i8*, i8** %2
%77 = getelementptr inbounds i8, i8* %76, i64 2
%78 = load i8, i8* %77
%79 = call i32 @usb_setup_clear_endpoint_feature(i8 zeroext %75, i8 zeroext %78)
br label %109
80: ; preds = %1
%81 = load i8*, i8** %2
%82 = getelementptr inbounds i8, i8* %81, i64 2
%83 = load i8, i8* %82
%84 = call i32 @usb_setup_set_device_feature(i8 zeroext %83)
br label %109
85: ; preds = %1
%86 = load i8*, i8** %2
%87 = getelementptr inbounds i8, i8* %86, i64 4
%88 = load i8, i8* %87
%89 = load i8*, i8** %2
%90 = getelementptr inbounds i8, i8* %89, i64 2
%91 = load i8, i8* %90
%92 = call i32 @usb_setup_set_endpoint_feature(i8 zeroext %88, i8 zeroext %91)
br label %109
93: ; preds = %1
%94 = load i8*, i8** %2
%95 = getelementptr inbounds i8, i8* %94, i64 4
%96 = load i8, i8* %95
%97 = call i32 @usb_setup_get_interface(i8 zeroext %96)
br label %109
98: ; preds = %1
%99 = load i8*, i8** %2
%100 = getelementptr inbounds i8, i8* %99, i64 4
%101 = load i8, i8* %100
%102 = load i8*, i8** %2
%103 = getelementptr inbounds i8, i8* %102, i64 2
%104 = load i8, i8* %103
%105 = call i32 @usb_setup_set_interface(i8 zeroext %101, i8 zeroext %104)
br label %109
106: ; preds = %1, %1, %1, %1
br label %107
107: ; preds = %1, %106
%108 = call i32 (...) @usb_request_error()
br label %109
109: ; preds = %107, %98, %93, %85, %80, %72, %67, %62, %57, %55, %50, %48, %18, %13
ret void
}

LLVM IR (-O2):
define void @usb_handle_setup_pkt(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = zext i8 %2 to i16
%4 = shl nuw i16 %3, 8
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = load i8, i8* %5
%7 = zext i8 %6 to i16
%8 = or i16 %4, %7
switch i16 %8, label %69 [
i16 5, label %9
i16 -32762, label %13
i16 -32760, label %23
i16 9, label %25
i16 -32768, label %29
i16 -32512, label %31
i16 -32256, label %35
i16 1, label %39
i16 513, label %43
i16 3, label %49
i16 515, label %53
i16 -32502, label %59
i16 267, label %63
]
9: ; preds = %1
%10 = getelementptr inbounds i8, i8* %0, i64 2
%11 = load i8, i8* %10
%12 = tail call i32 @usb_setup_set_address(i8 zeroext %11)
br label %71
13: ; preds = %1
%14 = getelementptr inbounds i8, i8* %0, i64 3
%15 = load i8, i8* %14
%16 = getelementptr inbounds i8, i8* %0, i64 2
%17 = load i8, i8* %16
%18 = getelementptr inbounds i8, i8* %0, i64 4
%19 = load i8, i8* %18
%20 = getelementptr inbounds i8, i8* %0, i64 6
%21 = load i8, i8* %20
%22 = tail call i32 @usb_setup_get_descriptor(i8 zeroext %15, i8 zeroext %17, i8 zeroext %19, i8 zeroext %21)
br label %71
23: ; preds = %1
%24 = tail call i32 (...) @usb_setup_get_configuration()
br label %71
25: ; preds = %1
%26 = getelementptr inbounds i8, i8* %0, i64 2
%27 = load i8, i8* %26
%28 = tail call i32 @usb_setup_set_configuration(i8 zeroext %27)
br label %71
29: ; preds = %1
%30 = tail call i32 (...) @usb_setup_get_device_status()
br label %71
31: ; preds = %1
%32 = getelementptr inbounds i8, i8* %0, i64 4
%33 = load i8, i8* %32
%34 = tail call i32 @usb_setup_get_interface_status(i8 zeroext %33)
br label %71
35: ; preds = %1
%36 = getelementptr inbounds i8, i8* %0, i64 4
%37 = load i8, i8* %36
%38 = tail call i32 @usb_setup_get_endpoint_status(i8 zeroext %37)
br label %71
39: ; preds = %1
%40 = getelementptr inbounds i8, i8* %0, i64 2
%41 = load i8, i8* %40
%42 = tail call i32 @usb_setup_clear_device_feature(i8 zeroext %41)
br label %71
43: ; preds = %1
%44 = getelementptr inbounds i8, i8* %0, i64 4
%45 = load i8, i8* %44
%46 = getelementptr inbounds i8, i8* %0, i64 2
%47 = load i8, i8* %46
%48 = tail call i32 @usb_setup_clear_endpoint_feature(i8 zeroext %45, i8 zeroext %47)
br label %71
49: ; preds = %1
%50 = getelementptr inbounds i8, i8* %0, i64 2
%51 = load i8, i8* %50
%52 = tail call i32 @usb_setup_set_device_feature(i8 zeroext %51)
br label %71
53: ; preds = %1
%54 = getelementptr inbounds i8, i8* %0, i64 4
%55 = load i8, i8* %54
%56 = getelementptr inbounds i8, i8* %0, i64 2
%57 = load i8, i8* %56
%58 = tail call i32 @usb_setup_set_endpoint_feature(i8 zeroext %55, i8 zeroext %57)
br label %71
59: ; preds = %1
%60 = getelementptr inbounds i8, i8* %0, i64 4
%61 = load i8, i8* %60
%62 = tail call i32 @usb_setup_get_interface(i8 zeroext %61)
br label %71
63: ; preds = %1
%64 = getelementptr inbounds i8, i8* %0, i64 4
%65 = load i8, i8* %64
%66 = getelementptr inbounds i8, i8* %0, i64 2
%67 = load i8, i8* %66
%68 = tail call i32 @usb_setup_set_interface(i8 zeroext %65, i8 zeroext %67)
br label %71
69: ; preds = %1
%70 = tail call i32 (...) @usb_request_error()
br label %71
71: ; preds = %69, %63, %59, %53, %49, %43, %39, %35, %31, %29, %25, %23, %13, %9
ret void
}