#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*/ _IOC_DIR(unsigned int);
int _IOC_NR(unsigned int);
int /*<<< orphan*/ _IOC_READ;
int _IOC_SIZE(unsigned int);
int _IOC_TYPE(unsigned int);
int /*<<< orphan*/ _IOC_WRITE;
int evdev_decode_number(unsigned int);
int hiddev_decode_number(unsigned int);
int /*<<< orphan*/ tprintf(char *, int);
int ioctl_decode_command_number(unsigned int arg) {
  switch (_IOC_TYPE(arg)) {
  case 'E':
    return evdev_decode_number(arg);
  case 'H':
    return hiddev_decode_number(arg);
  case 'M':
    if (_IOC_DIR(arg) == _IOC_WRITE) {
      tprintf("MIXER_WRITE(%u)", _IOC_NR(arg));
      return 1;
    } else if (_IOC_DIR(arg) == _IOC_READ) {
      tprintf("MIXER_READ(%u)", _IOC_NR(arg));
      return 1;
    }
    return 0;
  case 'U':
    if (_IOC_DIR(arg) == _IOC_READ && _IOC_NR(arg) == 0x2c) {
      tprintf("UI_GET_SYSNAME(%u)", _IOC_SIZE(arg));
      return 1;
    }
    return 0;
  case 'j':
    if (_IOC_DIR(arg) == _IOC_READ && _IOC_NR(arg) == 0x13) {
      tprintf("JSIOCGNAME(%u)", _IOC_SIZE(arg));
      return 1;
    }
    return 0;
  case 'k':
    if (_IOC_DIR(arg) == _IOC_WRITE && _IOC_NR(arg) == 0) {
      tprintf("SPI_IOC_MESSAGE(%u)", _IOC_SIZE(arg));
      return 1;
    }
    return 0;
  default:
    return 0;
  }
}


x86 assembly (clang, -O0):
<ioctl_decode_command_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <_IOC_TYPE@plt>
add    $0xffffffbb,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x26,%eax
ja     134e <ioctl_decode_command_number+0x1de>
mov    -0x10(%rbp),%rax
lea    0xe60(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%edi
call   1030 <evdev_decode_number@plt>
mov    %eax,-0x4(%rbp)
jmp    1355 <ioctl_decode_command_number+0x1e5>
mov    -0x8(%rbp),%edi
call   1050 <hiddev_decode_number@plt>
mov    %eax,-0x4(%rbp)
jmp    1355 <ioctl_decode_command_number+0x1e5>
mov    -0x8(%rbp),%edi
call   1090 <_IOC_DIR@plt>
mov    0x2df8(%rip),%rcx
cmp    (%rcx),%eax
jne    1202 <ioctl_decode_command_number+0x92>
mov    -0x8(%rbp),%edi
call   1080 <_IOC_NR@plt>
mov    %eax,%esi
lea    0xeab(%rip),%rdi
call   1070 <tprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1355 <ioctl_decode_command_number+0x1e5>
mov    -0x8(%rbp),%edi
call   1090 <_IOC_DIR@plt>
mov    0x2dcf(%rip),%rcx
cmp    (%rcx),%eax
jne    123b <ioctl_decode_command_number+0xcb>
mov    -0x8(%rbp),%edi
call   1080 <_IOC_NR@plt>
mov    %eax,%esi
lea    0xe82(%rip),%rdi
call   1070 <tprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1355 <ioctl_decode_command_number+0x1e5>
jmp    1240 <ioctl_decode_command_number+0xd0>
movl   $0x0,-0x4(%rbp)
jmp    1355 <ioctl_decode_command_number+0x1e5>
mov    -0x8(%rbp),%edi
call   1090 <_IOC_DIR@plt>
mov    0x2d85(%rip),%rcx
cmp    (%rcx),%eax
jne    1296 <ioctl_decode_command_number+0x126>
mov    -0x8(%rbp),%edi
call   1080 <_IOC_NR@plt>
cmp    $0x2c,%eax
jne    1296 <ioctl_decode_command_number+0x126>
mov    -0x8(%rbp),%edi
call   1060 <_IOC_SIZE@plt>
mov    %eax,%esi
lea    0xe36(%rip),%rdi
call   1070 <tprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1355 <ioctl_decode_command_number+0x1e5>
movl   $0x0,-0x4(%rbp)
jmp    1355 <ioctl_decode_command_number+0x1e5>
mov    -0x8(%rbp),%edi
call   1090 <_IOC_DIR@plt>
mov    0x2d2f(%rip),%rcx
cmp    (%rcx),%eax
jne    12ec <ioctl_decode_command_number+0x17c>
mov    -0x8(%rbp),%edi
call   1080 <_IOC_NR@plt>
cmp    $0x13,%eax
jne    12ec <ioctl_decode_command_number+0x17c>
mov    -0x8(%rbp),%edi
call   1060 <_IOC_SIZE@plt>
mov    %eax,%esi
lea    0xdf3(%rip),%rdi
call   1070 <tprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1355 <ioctl_decode_command_number+0x1e5>
movl   $0x0,-0x4(%rbp)
jmp    1355 <ioctl_decode_command_number+0x1e5>
mov    -0x8(%rbp),%edi
call   1090 <_IOC_DIR@plt>
mov    0x2cc9(%rip),%rcx
cmp    (%rcx),%eax
jne    1342 <ioctl_decode_command_number+0x1d2>
mov    -0x8(%rbp),%edi
call   1080 <_IOC_NR@plt>
cmp    $0x0,%eax
jne    1342 <ioctl_decode_command_number+0x1d2>
mov    -0x8(%rbp),%edi
call   1060 <_IOC_SIZE@plt>
mov    %eax,%esi
lea    0xdac(%rip),%rdi
call   1070 <tprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1355 <ioctl_decode_command_number+0x1e5>
movl   $0x0,-0x4(%rbp)
jmp    1355 <ioctl_decode_command_number+0x1e5>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ioctl_decode_command_number>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
call   1040 <_IOC_TYPE@plt>
xor    %ebx,%ebx
add    $0xffffffbb,%eax
cmp    $0x26,%eax
ja     1298 <ioctl_decode_command_number+0x128>
lea    0xe71(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <evdev_decode_number@plt>
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <hiddev_decode_number@plt>
mov    %ebp,%edi
call   1090 <_IOC_DIR@plt>
mov    0x2e10(%rip),%rcx
cmp    (%rcx),%eax
jne    126c <ioctl_decode_command_number+0xfc>
mov    %ebp,%edi
call   1080 <_IOC_NR@plt>
lea    0xec6(%rip),%rdi
jmp    128c <ioctl_decode_command_number+0x11c>
mov    %ebp,%edi
call   1090 <_IOC_DIR@plt>
mov    0x2df7(%rip),%rcx
cmp    (%rcx),%eax
jne    1298 <ioctl_decode_command_number+0x128>
mov    %ebp,%edi
call   1080 <_IOC_NR@plt>
cmp    $0x2c,%eax
jne    1298 <ioctl_decode_command_number+0x128>
mov    %ebp,%edi
call   1060 <_IOC_SIZE@plt>
lea    0xeac(%rip),%rdi
jmp    128c <ioctl_decode_command_number+0x11c>
mov    %ebp,%edi
call   1090 <_IOC_DIR@plt>
mov    0x2dc1(%rip),%rcx
cmp    (%rcx),%eax
jne    1298 <ioctl_decode_command_number+0x128>
mov    %ebp,%edi
call   1080 <_IOC_NR@plt>
cmp    $0x13,%eax
jne    1298 <ioctl_decode_command_number+0x128>
mov    %ebp,%edi
call   1060 <_IOC_SIZE@plt>
lea    0xe91(%rip),%rdi
jmp    128c <ioctl_decode_command_number+0x11c>
mov    %ebp,%edi
call   1090 <_IOC_DIR@plt>
mov    0x2d83(%rip),%rcx
cmp    (%rcx),%eax
jne    1298 <ioctl_decode_command_number+0x128>
mov    %ebp,%edi
call   1080 <_IOC_NR@plt>
test   %eax,%eax
jne    1298 <ioctl_decode_command_number+0x128>
mov    %ebp,%edi
call   1060 <_IOC_SIZE@plt>
lea    0xe73(%rip),%rdi
jmp    128c <ioctl_decode_command_number+0x11c>
mov    %ebp,%edi
call   1090 <_IOC_DIR@plt>
mov    0x2d66(%rip),%rcx
cmp    (%rcx),%eax
jne    1298 <ioctl_decode_command_number+0x128>
mov    %ebp,%edi
call   1080 <_IOC_NR@plt>
lea    0xe20(%rip),%rdi
mov    %eax,%esi
call   1070 <tprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@_IOC_WRITE = global i32 0
@.str = [16 x i8] c"MIXER_WRITE(%u)\00"
@_IOC_READ = global i32 0
@.str.1 = [15 x i8] c"MIXER_READ(%u)\00"
@.str.2 = [19 x i8] c"UI_GET_SYSNAME(%u)\00"
@.str.3 = [15 x i8] c"JSIOCGNAME(%u)\00"
@.str.4 = [20 x i8] c"SPI_IOC_MESSAGE(%u)\00"
define i32 @ioctl_decode_command_number(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = call i32 @_IOC_TYPE(i32 %4)
switch i32 %5, label %74 [
i32 69, label %6
i32 72, label %9
i32 77, label %12
i32 85, label %32
i32 106, label %46
i32 107, label %60
]
6: ; preds = %1
%7 = load i32, i32* %3
%8 = call i32 @evdev_decode_number(i32 %7)
store i32 %8, i32* %2
br label %75
9: ; preds = %1
%10 = load i32, i32* %3
%11 = call i32 @hiddev_decode_number(i32 %10)
store i32 %11, i32* %2
br label %75
12: ; preds = %1
%13 = load i32, i32* %3
%14 = call i32 @_IOC_DIR(i32 %13)
%15 = load i32, i32* @_IOC_WRITE
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = load i32, i32* %3
%19 = call i32 @_IOC_NR(i32 %18)
%20 = call i32 @tprintf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %19)
store i32 1, i32* %2
br label %75
21: ; preds = %12
%22 = load i32, i32* %3
%23 = call i32 @_IOC_DIR(i32 %22)
%24 = load i32, i32* @_IOC_READ
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %30
26: ; preds = %21
%27 = load i32, i32* %3
%28 = call i32 @_IOC_NR(i32 %27)
%29 = call i32 @tprintf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %28)
store i32 1, i32* %2
br label %75
30: ; preds = %21
br label %31
31: ; preds = %30
store i32 0, i32* %2
br label %75
32: ; preds = %1
%33 = load i32, i32* %3
%34 = call i32 @_IOC_DIR(i32 %33)
%35 = load i32, i32* @_IOC_READ
%36 = icmp eq i32 %34, %35
br i1 %36, label %37, label %45
37: ; preds = %32
%38 = load i32, i32* %3
%39 = call i32 @_IOC_NR(i32 %38)
%40 = icmp eq i32 %39, 44
br i1 %40, label %41, label %45
41: ; preds = %37
%42 = load i32, i32* %3
%43 = call i32 @_IOC_SIZE(i32 %42)
%44 = call i32 @tprintf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %43)
store i32 1, i32* %2
br label %75
45: ; preds = %37, %32
store i32 0, i32* %2
br label %75
46: ; preds = %1
%47 = load i32, i32* %3
%48 = call i32 @_IOC_DIR(i32 %47)
%49 = load i32, i32* @_IOC_READ
%50 = icmp eq i32 %48, %49
br i1 %50, label %51, label %59
51: ; preds = %46
%52 = load i32, i32* %3
%53 = call i32 @_IOC_NR(i32 %52)
%54 = icmp eq i32 %53, 19
br i1 %54, label %55, label %59
55: ; preds = %51
%56 = load i32, i32* %3
%57 = call i32 @_IOC_SIZE(i32 %56)
%58 = call i32 @tprintf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %57)
store i32 1, i32* %2
br label %75
59: ; preds = %51, %46
store i32 0, i32* %2
br label %75
60: ; preds = %1
%61 = load i32, i32* %3
%62 = call i32 @_IOC_DIR(i32 %61)
%63 = load i32, i32* @_IOC_WRITE
%64 = icmp eq i32 %62, %63
br i1 %64, label %65, label %73
65: ; preds = %60
%66 = load i32, i32* %3
%67 = call i32 @_IOC_NR(i32 %66)
%68 = icmp eq i32 %67, 0
br i1 %68, label %69, label %73
69: ; preds = %65
%70 = load i32, i32* %3
%71 = call i32 @_IOC_SIZE(i32 %70)
%72 = call i32 @tprintf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %71)
store i32 1, i32* %2
br label %75
73: ; preds = %65, %60
store i32 0, i32* %2
br label %75
74: ; preds = %1
store i32 0, i32* %2
br label %75
75: ; preds = %74, %73, %69, %59, %55, %45, %41, %31, %26, %17, %9, %6
%76 = load i32, i32* %2
ret i32 %76
}

LLVM IR (-O2):
@_IOC_WRITE = global i32 0
@.str = [16 x i8] c"MIXER_WRITE(%u)\00"
@_IOC_READ = global i32 0
@.str.1 = [15 x i8] c"MIXER_READ(%u)\00"
@.str.2 = [19 x i8] c"UI_GET_SYSNAME(%u)\00"
@.str.3 = [15 x i8] c"JSIOCGNAME(%u)\00"
@.str.4 = [20 x i8] c"SPI_IOC_MESSAGE(%u)\00"
define i32 @ioctl_decode_command_number(i32 %0) {
%2 = tail call i32 @_IOC_TYPE(i32 %0)
switch i32 %2, label %51 [
i32 69, label %3
i32 72, label %5
i32 77, label %7
i32 85, label %21
i32 106, label %31
i32 107, label %41
]
3: ; preds = %1
%4 = tail call i32 @evdev_decode_number(i32 %0)
br label %51
5: ; preds = %1
%6 = tail call i32 @hiddev_decode_number(i32 %0)
br label %51
7: ; preds = %1
%8 = tail call i32 @_IOC_DIR(i32 %0)
%9 = load i32, i32* @_IOC_WRITE
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = tail call i32 @_IOC_NR(i32 %0)
%13 = tail call i32 @tprintf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %51
14: ; preds = %7
%15 = tail call i32 @_IOC_DIR(i32 %0)
%16 = load i32, i32* @_IOC_READ
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %51
18: ; preds = %14
%19 = tail call i32 @_IOC_NR(i32 %0)
%20 = tail call i32 @tprintf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %19)
br label %51
21: ; preds = %1
%22 = tail call i32 @_IOC_DIR(i32 %0)
%23 = load i32, i32* @_IOC_READ
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %51
25: ; preds = %21
%26 = tail call i32 @_IOC_NR(i32 %0)
%27 = icmp eq i32 %26, 44
br i1 %27, label %28, label %51
28: ; preds = %25
%29 = tail call i32 @_IOC_SIZE(i32 %0)
%30 = tail call i32 @tprintf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %29)
br label %51
31: ; preds = %1
%32 = tail call i32 @_IOC_DIR(i32 %0)
%33 = load i32, i32* @_IOC_READ
%34 = icmp eq i32 %32, %33
br i1 %34, label %35, label %51
35: ; preds = %31
%36 = tail call i32 @_IOC_NR(i32 %0)
%37 = icmp eq i32 %36, 19
br i1 %37, label %38, label %51
38: ; preds = %35
%39 = tail call i32 @_IOC_SIZE(i32 %0)
%40 = tail call i32 @tprintf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %39)
br label %51
41: ; preds = %1
%42 = tail call i32 @_IOC_DIR(i32 %0)
%43 = load i32, i32* @_IOC_WRITE
%44 = icmp eq i32 %42, %43
br i1 %44, label %45, label %51
45: ; preds = %41
%46 = tail call i32 @_IOC_NR(i32 %0)
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %45
%49 = tail call i32 @_IOC_SIZE(i32 %0)
%50 = tail call i32 @tprintf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %49)
br label %51
51: ; preds = %1, %41, %45, %31, %35, %21, %25, %14, %48, %38, %28, %18, %11, %5, %3
%52 = phi i32 [ 1, %48 ], [ 1, %38 ], [ 1, %28 ], [ 1, %11 ], [ 1, %18 ], [ %6, %5 ], [ %4, %3 ], [ 0, %14 ], [ 0, %25 ], [ 0, %21 ], [ 0, %35 ], [ 0, %31 ], [ 0, %45 ], [ 0, %41 ], [ 0, %1 ]
ret i32 %52
}