#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 HID_REPORT_TYPE_FEATURE;
int HID_REPORT_TYPE_INPUT;
int HID_REPORT_TYPE_OUTPUT;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ parse_number(char *, int *);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void parse_control_arg(char *arg, int *type, int *id, int *field, int *usage,
                       int *value) {
  *field = 0;
  *usage = 0;
  if (value) {
    char *pos = strchr(arg, '=');
    if (!pos) {
      fprintf(stderr, "Missing VALUE in set command.\n");
      exit(2);
    }
    pos++;
    if (!parse_number(pos, value)) {
      fprintf(stderr, "Invalid value '%s'\n", pos);
      exit(2);
    }
  }
  int state = 0;
  while (arg != NULL && *arg != 0 && *arg != '=') {
    char *pos = strchr(arg, ',');
    if (!pos)
      pos = strchr(arg, '=');
    int len = (pos) ? pos - arg : (int)strlen(arg);
    char tmp[16];
    memset(tmp, 0, 16);
    strncpy(tmp, arg, (len < 16) ? len : 16);
    int i;
    if (state > 0) {
      if (!parse_number(tmp, &i)) {
        fprintf(stderr, "Invalid number '%s'\n", tmp);
        exit(2);
      }
    }
    switch (state) {
    case 0:
      if (len != 1) {
        fprintf(stderr, "Invalid type '%s'\n", tmp);
        exit(2);
      }
      switch (tmp[0]) {
      case 'F':
        *type = HID_REPORT_TYPE_FEATURE;
        break;
      case 'I':
        if (value) {
          fprintf(stderr, "Type I is invalid for set operation.\n");
          exit(2);
        }
        *type = HID_REPORT_TYPE_INPUT;
        break;
      case 'O':
        if (!value) {
          fprintf(stderr, "Type O is invalid for get operation.\n");
          exit(2);
        }
        *type = HID_REPORT_TYPE_OUTPUT;
        break;
      default:
        fprintf(stderr, "Invalid type '%s'\n", tmp);
        exit(2);
      }
      break;
    case 1:
      *id = i;
      break;
    case 2:
      *field = i;
      break;
    case 3:
      *usage = i;
      break;
    }
    state++;
    arg = strchr(arg, ',');
    if (arg)
      arg++;
  }
}


x86 assembly (clang, -O0):
<parse_control_arg>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
cmpq   $0x0,-0x30(%rbp)
je     123c <parse_control_arg+0xcc>
mov    -0x8(%rbp),%rdi
mov    $0x3d,%esi
call   1050 <strchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11f0 <parse_control_arg+0x80>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
lea    0xe31(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x2,%edi
call   1080 <exit@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1090 <parse_number@plt>
cmp    $0x0,%eax
jne    1237 <parse_control_arg+0xc7>
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xe09(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x2,%edi
call   1080 <exit@plt>
jmp    123c <parse_control_arg+0xcc>
movl   $0x0,-0x3c(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x65(%rbp)
je     1278 <parse_control_arg+0x108>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x65(%rbp)
je     1278 <parse_control_arg+0x108>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3d,%eax
setne  %al
mov    %al,-0x65(%rbp)
mov    -0x65(%rbp),%al
test   $0x1,%al
jne    1288 <parse_control_arg+0x118>
jmp    1545 <parse_control_arg+0x3d5>
mov    -0x8(%rbp),%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    12b7 <parse_control_arg+0x147>
mov    -0x8(%rbp),%rdi
mov    $0x3d,%esi
call   1050 <strchr@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     12d6 <parse_control_arg+0x166>
mov    -0x48(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x70(%rbp)
jmp    12e5 <parse_control_arg+0x175>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cltq
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
mov    %eax,-0x4c(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
lea    -0x60(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x78(%rbp)
cmpl   $0x10,-0x4c(%rbp)
jge    1324 <parse_control_arg+0x1b4>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x84(%rbp)
jmp    1334 <parse_control_arg+0x1c4>
mov    $0x10,%eax
mov    %eax,-0x84(%rbp)
jmp    1334 <parse_control_arg+0x1c4>
mov    -0x78(%rbp),%rsi
mov    -0x80(%rbp),%rdi
mov    -0x84(%rbp),%edx
call   1030 <strncpy@plt>
cmpl   $0x0,-0x3c(%rbp)
jle    1391 <parse_control_arg+0x221>
lea    -0x60(%rbp),%rdi
lea    -0x64(%rbp),%rsi
call   1090 <parse_number@plt>
cmp    $0x0,%eax
jne    138c <parse_control_arg+0x21c>
mov    0x2c5a(%rip),%rax
mov    (%rax),%edi
lea    -0x60(%rbp),%rdx
lea    0xcc8(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x2,%edi
call   1080 <exit@plt>
jmp    1391 <parse_control_arg+0x221>
mov    -0x3c(%rbp),%eax
mov    %rax,-0x90(%rbp)
sub    $0x3,%rax
ja     150e <parse_control_arg+0x39e>
mov    -0x90(%rbp),%rax
lea    0xc4d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x1,-0x4c(%rbp)
je     13eb <parse_control_arg+0x27b>
mov    0x2bfb(%rip),%rax
mov    (%rax),%edi
lea    -0x60(%rbp),%rdx
lea    0xc7e(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x2,%edi
call   1080 <exit@plt>
movsbl -0x60(%rbp),%eax
mov    %eax,-0x94(%rbp)
sub    $0x46,%eax
je     142b <parse_control_arg+0x2bb>
jmp    1403 <parse_control_arg+0x293>
mov    -0x94(%rbp),%eax
sub    $0x49,%eax
je     143f <parse_control_arg+0x2cf>
jmp    1417 <parse_control_arg+0x2a7>
mov    -0x94(%rbp),%eax
sub    $0x4f,%eax
je     147f <parse_control_arg+0x30f>
jmp    14bf <parse_control_arg+0x34f>
mov    0x2bae(%rip),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    14e4 <parse_control_arg+0x374>
cmpq   $0x0,-0x30(%rbp)
je     146b <parse_control_arg+0x2fb>
mov    0x2b77(%rip),%rax
mov    (%rax),%edi
lea    0xc11(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x2,%edi
call   1080 <exit@plt>
mov    0x2b66(%rip),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    14e4 <parse_control_arg+0x374>
cmpq   $0x0,-0x30(%rbp)
jne    14ab <parse_control_arg+0x33b>
mov    0x2b37(%rip),%rax
mov    (%rax),%edi
lea    0xbf7(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x2,%edi
call   1080 <exit@plt>
mov    0x2b36(%rip),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    14e4 <parse_control_arg+0x374>
mov    0x2b02(%rip),%rax
mov    (%rax),%edi
lea    -0x60(%rbp),%rdx
lea    0xb85(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x2,%edi
call   1080 <exit@plt>
jmp    150e <parse_control_arg+0x39e>
mov    -0x64(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    150e <parse_control_arg+0x39e>
mov    -0x64(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    150e <parse_control_arg+0x39e>
mov    -0x64(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1540 <parse_control_arg+0x3d0>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1243 <parse_control_arg+0xd3>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_control_arg>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,%r15
mov    %rdx,0x20(%rsp)
mov    %rsi,%r13
mov    %rdi,%rbp
mov    %rcx,0x28(%rsp)
movl   $0x0,(%rcx)
mov    %r8,0x30(%rsp)
movl   $0x0,(%r8)
test   %r9,%r9
je     11d8 <parse_control_arg+0x68>
mov    %rbp,%rdi
mov    $0x3d,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1395 <parse_control_arg+0x225>
mov    %rax,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1090 <parse_number@plt>
test   %eax,%eax
je     13b6 <parse_control_arg+0x246>
test   %rbp,%rbp
je     132a <parse_control_arg+0x1ba>
xor    %ebx,%ebx
lea    0x10(%rsp),%r12
jmp    1212 <parse_control_arg+0xa2>
mov    0xc(%rsp),%eax
mov    0x28(%rsp),%rcx
mov    %eax,(%rcx)
add    $0x1,%ebx
mov    %rbp,%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
lea    0x1(%rax),%rbp
test   %rax,%rax
je     132a <parse_control_arg+0x1ba>
movzbl 0x0(%rbp),%eax
test   %al,%al
je     132a <parse_control_arg+0x1ba>
cmp    $0x3d,%al
je     132a <parse_control_arg+0x1ba>
mov    %rbp,%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1254 <parse_control_arg+0xe4>
mov    %rbp,%rdi
mov    $0x3d,%esi
call   1050 <strchr@plt>
mov    %rax,%r14
test   %rax,%rax
je     12f5 <parse_control_arg+0x185>
sub    %rbp,%r14
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
cmp    $0x10,%r14d
mov    $0x10,%edx
cmovl  %r14d,%edx
mov    %r12,%rdi
mov    %rbp,%rsi
call   1030 <strncpy@plt>
test   %ebx,%ebx
je     12c0 <parse_control_arg+0x150>
mov    %r12,%rdi
lea    0xc(%rsp),%rsi
call   1090 <parse_number@plt>
test   %eax,%eax
je     1339 <parse_control_arg+0x1c9>
cmp    $0x1,%ebx
je     12e7 <parse_control_arg+0x177>
cmp    $0x2,%ebx
je     11ea <parse_control_arg+0x7a>
cmp    $0x3,%ebx
jne    11f5 <parse_control_arg+0x85>
mov    0xc(%rsp),%eax
mov    0x30(%rsp),%rcx
jmp    11f3 <parse_control_arg+0x83>
nopl   0x0(%rax)
cmp    $0x1,%r14d
jne    134b <parse_control_arg+0x1db>
movsbl 0x10(%rsp),%eax
cmp    $0x4f,%eax
je     1305 <parse_control_arg+0x195>
cmp    $0x49,%eax
je     1313 <parse_control_arg+0x1a3>
cmp    $0x46,%eax
jne    134b <parse_control_arg+0x1db>
mov    0x2cfb(%rip),%rax
jmp    131f <parse_control_arg+0x1af>
mov    0xc(%rsp),%eax
mov    0x20(%rsp),%rcx
jmp    11f3 <parse_control_arg+0x83>
mov    %rbp,%rdi
call   1040 <strlen@plt>
movslq %eax,%r14
jmp    1257 <parse_control_arg+0xe7>
test   %r15,%r15
je     1371 <parse_control_arg+0x201>
mov    0x2cd7(%rip),%rax
jmp    131f <parse_control_arg+0x1af>
test   %r15,%r15
jne    1383 <parse_control_arg+0x213>
mov    0x2cb9(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x0(%r13)
jmp    11f5 <parse_control_arg+0x85>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c88(%rip),%rax
mov    (%rax),%edi
lea    0xcea(%rip),%rsi
jmp    135b <parse_control_arg+0x1eb>
mov    0x2c76(%rip),%rax
mov    (%rax),%edi
lea    0xced(%rip),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x2,%edi
call   1080 <exit@plt>
mov    0x2c50(%rip),%rax
mov    (%rax),%edi
lea    0xd00(%rip),%rsi
jmp    13a5 <parse_control_arg+0x235>
mov    0x2c3e(%rip),%rax
mov    (%rax),%edi
lea    0xcc8(%rip),%rsi
jmp    13a5 <parse_control_arg+0x235>
mov    0x2c2c(%rip),%rax
mov    (%rax),%edi
lea    0xc5b(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x2,%edi
call   1080 <exit@plt>
mov    0x2c0b(%rip),%rax
mov    (%rax),%edi
lea    0xc59(%rip),%rsi
mov    %rbx,%rdx
jmp    1360 <parse_control_arg+0x1f0>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"Missing VALUE in set command.\0A\00"
@.str.1 = [20 x i8] c"Invalid value '%s'\0A\00"
@.str.2 = [21 x i8] c"Invalid number '%s'\0A\00"
@.str.3 = [19 x i8] c"Invalid type '%s'\0A\00"
@HID_REPORT_TYPE_FEATURE = global i32 0
@.str.4 = [38 x i8] c"Type I is invalid for set operation.\0A\00"
@HID_REPORT_TYPE_INPUT = global i32 0
@.str.5 = [38 x i8] c"Type O is invalid for get operation.\0A\00"
@HID_REPORT_TYPE_OUTPUT = global i32 0
define void @parse_control_arg(i8* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5) {
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i32
%17 = alloca [16 x i8]
%18 = alloca i32
store i8* %0, i8** %7
store i32* %1, i32** %8
store i32* %2, i32** %9
store i32* %3, i32** %10
store i32* %4, i32** %11
store i32* %5, i32** %12
%19 = load i32*, i32** %10
store i32 0, i32* %19
%20 = load i32*, i32** %11
store i32 0, i32* %20
%21 = load i32*, i32** %12
%22 = icmp ne i32* %21, null
br i1 %22, label %23, label %45
23: ; preds = %6
%24 = load i8*, i8** %7
%25 = call i8* @strchr(i8* %24, i8 signext 61)
store i8* %25, i8** %13
%26 = load i8*, i8** %13
%27 = icmp ne i8* %26, null
br i1 %27, label %32, label %28
28: ; preds = %23
%29 = load i32, i32* @stderr
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%31 = call i32 @exit(i32 2)
unreachable
32: ; preds = %23
%33 = load i8*, i8** %13
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %13
%35 = load i8*, i8** %13
%36 = load i32*, i32** %12
%37 = call i32 @parse_number(i8* %35, i32* %36)
%38 = icmp ne i32 %37, 0
br i1 %38, label %44, label %39
39: ; preds = %32
%40 = load i32, i32* @stderr
%41 = load i8*, i8** %13
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %41)
%43 = call i32 @exit(i32 2)
unreachable
44: ; preds = %32
br label %45
45: ; preds = %44, %6
store i32 0, i32* %14
br label %46
46: ; preds = %172, %45
%47 = load i8*, i8** %7
%48 = icmp ne i8* %47, null
br i1 %48, label %49, label %59
49: ; preds = %46
%50 = load i8*, i8** %7
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %59
54: ; preds = %49
%55 = load i8*, i8** %7
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp ne i32 %57, 61
br label %59
59: ; preds = %54, %49, %46
%60 = phi i1 [ false, %49 ], [ false, %46 ], [ %58, %54 ]
br i1 %60, label %61, label %173
61: ; preds = %59
%62 = load i8*, i8** %7
%63 = call i8* @strchr(i8* %62, i8 signext 44)
store i8* %63, i8** %15
%64 = load i8*, i8** %15
%65 = icmp ne i8* %64, null
br i1 %65, label %69, label %66
66: ; preds = %61
%67 = load i8*, i8** %7
%68 = call i8* @strchr(i8* %67, i8 signext 61)
store i8* %68, i8** %15
br label %69
69: ; preds = %66, %61
%70 = load i8*, i8** %15
%71 = icmp ne i8* %70, null
br i1 %71, label %72, label %78
72: ; preds = %69
%73 = load i8*, i8** %15
%74 = load i8*, i8** %7
%75 = ptrtoint i8* %73 to i64
%76 = ptrtoint i8* %74 to i64
%77 = sub i64 %75, %76
br label %83
78: ; preds = %69
%79 = load i8*, i8** %7
%80 = call i64 @strlen(i8* %79)
%81 = trunc i64 %80 to i32
%82 = sext i32 %81 to i64
br label %83
83: ; preds = %78, %72
%84 = phi i64 [ %77, %72 ], [ %82, %78 ]
%85 = trunc i64 %84 to i32
store i32 %85, i32* %16
%86 = getelementptr inbounds [16 x i8], [16 x i8]* %17, i64 0, i64 0
%87 = call i32 @memset(i8* %86, i32 0, i32 16)
%88 = getelementptr inbounds [16 x i8], [16 x i8]* %17, i64 0, i64 0
%89 = load i8*, i8** %7
%90 = load i32, i32* %16
%91 = icmp slt i32 %90, 16
br i1 %91, label %92, label %94
92: ; preds = %83
%93 = load i32, i32* %16
br label %95
94: ; preds = %83
br label %95
95: ; preds = %94, %92
%96 = phi i32 [ %93, %92 ], [ 16, %94 ]
%97 = call i32 @strncpy(i8* %88, i8* %89, i32 %96)
%98 = load i32, i32* %14
%99 = icmp sgt i32 %98, 0
br i1 %99, label %100, label %110
100: ; preds = %95
%101 = getelementptr inbounds [16 x i8], [16 x i8]* %17, i64 0, i64 0
%102 = call i32 @parse_number(i8* %101, i32* %18)
%103 = icmp ne i32 %102, 0
br i1 %103, label %109, label %104
104: ; preds = %100
%105 = load i32, i32* @stderr
%106 = getelementptr inbounds [16 x i8], [16 x i8]* %17, i64 0, i64 0
%107 = call i32 (i32, i8*, ...) @fprintf(i32 %105, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %106)
%108 = call i32 @exit(i32 2)
unreachable
109: ; preds = %100
br label %110
110: ; preds = %109, %95
%111 = load i32, i32* %14
switch i32 %111, label %162 [
i32 0, label %112
i32 1, label %153
i32 2, label %156
i32 3, label %159
]
112: ; preds = %110
%113 = load i32, i32* %16
%114 = icmp ne i32 %113, 1
br i1 %114, label %115, label %120
115: ; preds = %112
%116 = load i32, i32* @stderr
%117 = getelementptr inbounds [16 x i8], [16 x i8]* %17, i64 0, i64 0
%118 = call i32 (i32, i8*, ...) @fprintf(i32 %116, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %117)
%119 = call i32 @exit(i32 2)
unreachable
120: ; preds = %112
%121 = getelementptr inbounds [16 x i8], [16 x i8]* %17, i64 0, i64 0
%122 = load i8, i8* %121
%123 = sext i8 %122 to i32
switch i32 %123, label %147 [
i32 70, label %124
i32 73, label %127
i32 79, label %137
]
124: ; preds = %120
%125 = load i32, i32* @HID_REPORT_TYPE_FEATURE
%126 = load i32*, i32** %8
store i32 %125, i32* %126
br label %152
127: ; preds = %120
%128 = load i32*, i32** %12
%129 = icmp ne i32* %128, null
br i1 %129, label %130, label %134
130: ; preds = %127
%131 = load i32, i32* @stderr
%132 = call i32 (i32, i8*, ...) @fprintf(i32 %131, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%133 = call i32 @exit(i32 2)
unreachable
134: ; preds = %127
%135 = load i32, i32* @HID_REPORT_TYPE_INPUT
%136 = load i32*, i32** %8
store i32 %135, i32* %136
br label %152
137: ; preds = %120
%138 = load i32*, i32** %12
%139 = icmp ne i32* %138, null
br i1 %139, label %144, label %140
140: ; preds = %137
%141 = load i32, i32* @stderr
%142 = call i32 (i32, i8*, ...) @fprintf(i32 %141, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
%143 = call i32 @exit(i32 2)
unreachable
144: ; preds = %137
%145 = load i32, i32* @HID_REPORT_TYPE_OUTPUT
%146 = load i32*, i32** %8
store i32 %145, i32* %146
br label %152
147: ; preds = %120
%148 = load i32, i32* @stderr
%149 = getelementptr inbounds [16 x i8], [16 x i8]* %17, i64 0, i64 0
%150 = call i32 (i32, i8*, ...) @fprintf(i32 %148, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %149)
%151 = call i32 @exit(i32 2)
unreachable
152: ; preds = %144, %134, %124
br label %162
153: ; preds = %110
%154 = load i32, i32* %18
%155 = load i32*, i32** %9
store i32 %154, i32* %155
br label %162
156: ; preds = %110
%157 = load i32, i32* %18
%158 = load i32*, i32** %10
store i32 %157, i32* %158
br label %162
159: ; preds = %110
%160 = load i32, i32* %18
%161 = load i32*, i32** %11
store i32 %160, i32* %161
br label %162
162: ; preds = %110, %159, %156, %153, %152
%163 = load i32, i32* %14
%164 = add nsw i32 %163, 1
store i32 %164, i32* %14
%165 = load i8*, i8** %7
%166 = call i8* @strchr(i8* %165, i8 signext 44)
store i8* %166, i8** %7
%167 = load i8*, i8** %7
%168 = icmp ne i8* %167, null
br i1 %168, label %169, label %172
169: ; preds = %162
%170 = load i8*, i8** %7
%171 = getelementptr inbounds i8, i8* %170, i32 1
store i8* %171, i8** %7
br label %172
172: ; preds = %169, %162
br label %46
173: ; preds = %59
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"Missing VALUE in set command.\0A\00"
@.str.1 = [20 x i8] c"Invalid value '%s'\0A\00"
@.str.2 = [21 x i8] c"Invalid number '%s'\0A\00"
@.str.3 = [19 x i8] c"Invalid type '%s'\0A\00"
@HID_REPORT_TYPE_FEATURE = global i32 0
@.str.4 = [38 x i8] c"Type I is invalid for set operation.\0A\00"
@HID_REPORT_TYPE_INPUT = global i32 0
@.str.5 = [38 x i8] c"Type O is invalid for get operation.\0A\00"
@HID_REPORT_TYPE_OUTPUT = global i32 0
define void @parse_control_arg(i8* %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4, i32* %5) {
%7 = alloca [16 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 0, i32* %4
%9 = icmp eq i32* %5, null
br i1 %9, label %25, label %10
10: ; preds = %6
%11 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 61)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i32, i32* @stderr
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%16 = tail call i32 @exit(i32 2)
unreachable
17: ; preds = %10
%18 = getelementptr inbounds i8, i8* %11, i64 1
%19 = tail call i32 @parse_number(i8* %18, i32* %5)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i32, i32* @stderr
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%24 = tail call i32 @exit(i32 2)
unreachable
25: ; preds = %17, %6
%26 = icmp eq i8* %0, null
br i1 %26, label %105, label %27
27: ; preds = %25
%28 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%29 = bitcast i32* %8 to i8*
br label %30
30: ; preds = %27, %100
%31 = phi i8* [ %0, %27 ], [ %104, %100 ]
%32 = phi i32 [ 0, %27 ], [ %101, %100 ]
%33 = load i8, i8* %31
switch i8 %33, label %34 [
i8 0, label %105
i8 61, label %105
]
34: ; preds = %30
%35 = call i8* @strchr(i8* %31, i8 signext 44)
%36 = icmp eq i8* %35, null
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = call i8* @strchr(i8* %31, i8 signext 61)
%39 = icmp eq i8* %38, null
br i1 %39, label %45, label %40
40: ; preds = %34, %37
%41 = phi i8* [ %38, %37 ], [ %35, %34 ]
%42 = ptrtoint i8* %41 to i64
%43 = ptrtoint i8* %31 to i64
%44 = sub i64 %42, %43
br label %49
45: ; preds = %37
%46 = call i64 @strlen(i8* %31)
%47 = shl i64 %46, 32
%48 = ashr exact i64 %47, 32
br label %49
49: ; preds = %45, %40
%50 = phi i64 [ %44, %40 ], [ %48, %45 ]
%51 = trunc i64 %50 to i32
%52 = call i32 @memset(i8* %28, i32 0, i32 16)
%53 = icmp slt i32 %51, 16
%54 = select i1 %53, i32 %51, i32 16
%55 = call i32 @strncpy(i8* %28, i8* %31, i32 %54)
%56 = icmp eq i32 %32, 0
br i1 %56, label %65, label %57
57: ; preds = %49
%58 = call i32 @parse_number(i8* %28, i32* %8)
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %64
60: ; preds = %57
%61 = load i32, i32* @stderr
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%63 = call i32 @exit(i32 2)
unreachable
64: ; preds = %57
switch i32 %32, label %100 [
i32 3, label %98
i32 1, label %94
i32 2, label %96
]
65: ; preds = %49
%66 = icmp eq i32 %51, 1
br i1 %66, label %71, label %67
67: ; preds = %65
%68 = load i32, i32* @stderr
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %28)
%70 = call i32 @exit(i32 2)
unreachable
71: ; preds = %65
%72 = load i8, i8* %28
%73 = sext i8 %72 to i32
switch i32 %73, label %90 [
i32 70, label %74
i32 73, label %76
i32 79, label %83
]
74: ; preds = %71
%75 = load i32, i32* @HID_REPORT_TYPE_FEATURE
store i32 %75, i32* %1
br label %100
76: ; preds = %71
br i1 %9, label %81, label %77
77: ; preds = %76
%78 = load i32, i32* @stderr
%79 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%80 = call i32 @exit(i32 2)
unreachable
81: ; preds = %76
%82 = load i32, i32* @HID_REPORT_TYPE_INPUT
store i32 %82, i32* %1
br label %100
83: ; preds = %71
br i1 %9, label %84, label %88
84: ; preds = %83
%85 = load i32, i32* @stderr
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
%87 = call i32 @exit(i32 2)
unreachable
88: ; preds = %83
%89 = load i32, i32* @HID_REPORT_TYPE_OUTPUT
store i32 %89, i32* %1
br label %100
90: ; preds = %71
%91 = load i32, i32* @stderr
%92 = call i32 (i32, i8*, ...) @fprintf(i32 %91, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %28)
%93 = call i32 @exit(i32 2)
unreachable
94: ; preds = %64
%95 = load i32, i32* %8
store i32 %95, i32* %2
br label %100
96: ; preds = %64
%97 = load i32, i32* %8
store i32 %97, i32* %3
br label %100
98: ; preds = %64
%99 = load i32, i32* %8
store i32 %99, i32* %4
br label %100
100: ; preds = %74, %81, %88, %64, %98, %96, %94
%101 = add nuw nsw i32 %32, 1
%102 = call i8* @strchr(i8* %31, i8 signext 44)
%103 = icmp eq i8* %102, null
%104 = getelementptr inbounds i8, i8* %102, i64 1
br i1 %103, label %105, label %30
105: ; preds = %100, %30, %30, %25
ret void
}