#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*/ abort_crypto_lib(char *);
int /*<<< orphan*/ parse_pair_item(char *, int);
void parse_item(char *message, int size) {
  char tag = *(message);
  switch (tag) {
  case 'a':
    break;
  case 'b':
    parse_pair_item(message, size);
    break;
  case 'c':
    if (size != 1 + 1 + 16)
      abort_crypto_lib("Could not parse nonce: illegal size");
    break;
  case 'd':
    if (size != 1 + 64)
      abort_crypto_lib("Could not parse hash: illegal size");
    break;
  case 'e':
    if (size != 1 + 32)
      abort_crypto_lib("Could not parse symmetric key: illegal size");
    break;
  case 'f':
    break;
  case 'g':
    break;
  case 'h':
    break;
  case 'i':
    if (size <= 1 + 32)
      abort_crypto_lib("Could not symmetric encrypted item: illegal size");
    break;
  case 'j':
    if (size <= 1 || size > 1 + (8 * 256))
      abort_crypto_lib("Could not asymmetric encrypted item: illegal size");
    break;
  case 'k':
    if (size <= 1 || size > 1 + (8 * 256))
      abort_crypto_lib("Could not asymmetric signature item: illegal size");
    break;
  default:
    abort_crypto_lib("Found illegal tag during deserialization");
  }
}


x86 assembly (clang, -O0):
<parse_item>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0xd(%rbp)
movsbl -0xd(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xa,%eax
ja     1243 <parse_item+0x123>
mov    -0x18(%rbp),%rax
lea    0xea7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    124f <parse_item+0x12f>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <parse_pair_item@plt>
jmp    124f <parse_item+0x12f>
cmpl   $0x12,-0xc(%rbp)
je     118e <parse_item+0x6e>
lea    0xea3(%rip),%rdi
call   1040 <abort_crypto_lib@plt>
jmp    124f <parse_item+0x12f>
cmpl   $0x41,-0xc(%rbp)
je     11a9 <parse_item+0x89>
lea    0xeac(%rip),%rdi
call   1040 <abort_crypto_lib@plt>
jmp    124f <parse_item+0x12f>
cmpl   $0x21,-0xc(%rbp)
je     11c4 <parse_item+0xa4>
lea    0xeb4(%rip),%rdi
call   1040 <abort_crypto_lib@plt>
jmp    124f <parse_item+0x12f>
jmp    124f <parse_item+0x12f>
jmp    124f <parse_item+0x12f>
jmp    124f <parse_item+0x12f>
cmpl   $0x21,-0xc(%rbp)
jg     11ee <parse_item+0xce>
lea    0xeb6(%rip),%rdi
call   1040 <abort_crypto_lib@plt>
jmp    124f <parse_item+0x12f>
cmpl   $0x1,-0xc(%rbp)
jle    120a <parse_item+0xea>
cmpl   $0x801,-0xc(%rbp)
jle    1216 <parse_item+0xf6>
lea    0xebf(%rip),%rdi
call   1040 <abort_crypto_lib@plt>
jmp    124f <parse_item+0x12f>
cmpl   $0x1,-0xc(%rbp)
jle    1232 <parse_item+0x112>
cmpl   $0x801,-0xc(%rbp)
jle    123e <parse_item+0x11e>
lea    0xec9(%rip),%rdi
call   1040 <abort_crypto_lib@plt>
jmp    124f <parse_item+0x12f>
lea    0xeea(%rip),%rdi
call   1040 <abort_crypto_lib@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_item>:
movsbl (%rdi),%eax
add    $0xffffff9f,%eax
cmp    $0xa,%eax
ja     11b8 <parse_item+0x98>
lea    0xeca(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
ret
cmp    $0x12,%esi
je     113f <parse_item+0x1f>
lea    0xee0(%rip),%rdi
jmp    1040 <abort_crypto_lib@plt>
cmp    $0x41,%esi
je     113f <parse_item+0x1f>
lea    0xef3(%rip),%rdi
jmp    1040 <abort_crypto_lib@plt>
cmp    $0x21,%esi
je     113f <parse_item+0x1f>
lea    0xf05(%rip),%rdi
jmp    1040 <abort_crypto_lib@plt>
cmp    $0x21,%esi
jg     113f <parse_item+0x1f>
lea    0xf20(%rip),%rdi
jmp    1040 <abort_crypto_lib@plt>
add    $0xfffff7fe,%esi
cmp    $0xfffff7ff,%esi
ja     113f <parse_item+0x1f>
lea    0xf37(%rip),%rdi
jmp    1040 <abort_crypto_lib@plt>
add    $0xfffff7fe,%esi
cmp    $0xfffff7ff,%esi
ja     113f <parse_item+0x1f>
lea    0xf4f(%rip),%rdi
jmp    1040 <abort_crypto_lib@plt>
lea    0xf75(%rip),%rdi
jmp    1040 <abort_crypto_lib@plt>
jmp    1030 <parse_pair_item@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"Could not parse nonce: illegal size\00"
@.str.1 = [35 x i8] c"Could not parse hash: illegal size\00"
@.str.2 = [44 x i8] c"Could not parse symmetric key: illegal size\00"
@.str.3 = [49 x i8] c"Could not symmetric encrypted item: illegal size\00"
@.str.4 = [50 x i8] c"Could not asymmetric encrypted item: illegal size\00"
@.str.5 = [50 x i8] c"Could not asymmetric signature item: illegal size\00"
@.str.6 = [41 x i8] c"Found illegal tag during deserialization\00"
define void @parse_item(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
store i8 %7, i8* %5
%8 = load i8, i8* %5
%9 = sext i8 %8 to i32
switch i32 %9, label %60 [
i32 97, label %10
i32 98, label %11
i32 99, label %15
i32 100, label %21
i32 101, label %27
i32 102, label %33
i32 103, label %34
i32 104, label %35
i32 105, label %36
i32 106, label %42
i32 107, label %51
]
10: ; preds = %2
br label %62
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = load i32, i32* %4
%14 = call i32 @parse_pair_item(i8* %12, i32 %13)
br label %62
15: ; preds = %2
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 18
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @abort_crypto_lib(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %18, %15
br label %62
21: ; preds = %2
%22 = load i32, i32* %4
%23 = icmp ne i32 %22, 65
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @abort_crypto_lib(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %24, %21
br label %62
27: ; preds = %2
%28 = load i32, i32* %4
%29 = icmp ne i32 %28, 33
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @abort_crypto_lib(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
br label %62
33: ; preds = %2
br label %62
34: ; preds = %2
br label %62
35: ; preds = %2
br label %62
36: ; preds = %2
%37 = load i32, i32* %4
%38 = icmp sle i32 %37, 33
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = call i32 @abort_crypto_lib(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0))
br label %41
41: ; preds = %39, %36
br label %62
42: ; preds = %2
%43 = load i32, i32* %4
%44 = icmp sle i32 %43, 1
br i1 %44, label %48, label %45
45: ; preds = %42
%46 = load i32, i32* %4
%47 = icmp sgt i32 %46, 2049
br i1 %47, label %48, label %50
48: ; preds = %45, %42
%49 = call i32 @abort_crypto_lib(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0))
br label %50
50: ; preds = %48, %45
br label %62
51: ; preds = %2
%52 = load i32, i32* %4
%53 = icmp sle i32 %52, 1
br i1 %53, label %57, label %54
54: ; preds = %51
%55 = load i32, i32* %4
%56 = icmp sgt i32 %55, 2049
br i1 %56, label %57, label %59
57: ; preds = %54, %51
%58 = call i32 @abort_crypto_lib(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0))
br label %59
59: ; preds = %57, %54
br label %62
60: ; preds = %2
%61 = call i32 @abort_crypto_lib(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0))
br label %62
62: ; preds = %60, %59, %50, %41, %35, %34, %33, %32, %26, %20, %11, %10
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"Could not parse nonce: illegal size\00"
@.str.1 = [35 x i8] c"Could not parse hash: illegal size\00"
@.str.2 = [44 x i8] c"Could not parse symmetric key: illegal size\00"
@.str.3 = [49 x i8] c"Could not symmetric encrypted item: illegal size\00"
@.str.4 = [50 x i8] c"Could not asymmetric encrypted item: illegal size\00"
@.str.5 = [50 x i8] c"Could not asymmetric signature item: illegal size\00"
@.str.6 = [41 x i8] c"Found illegal tag during deserialization\00"
define void @parse_item(i8* %0, i32 %1) {
%3 = load i8, i8* %0
%4 = sext i8 %3 to i32
switch i32 %4, label %33 [
i32 97, label %35
i32 98, label %5
i32 99, label %7
i32 100, label %11
i32 101, label %15
i32 102, label %35
i32 103, label %35
i32 104, label %35
i32 105, label %19
i32 106, label %23
i32 107, label %28
]
5: ; preds = %2
%6 = tail call i32 @parse_pair_item(i8* %0, i32 %1)
br label %35
7: ; preds = %2
%8 = icmp eq i32 %1, 18
br i1 %8, label %35, label %9
9: ; preds = %7
%10 = tail call i32 @abort_crypto_lib(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %35
11: ; preds = %2
%12 = icmp eq i32 %1, 65
br i1 %12, label %35, label %13
13: ; preds = %11
%14 = tail call i32 @abort_crypto_lib(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %35
15: ; preds = %2
%16 = icmp eq i32 %1, 33
br i1 %16, label %35, label %17
17: ; preds = %15
%18 = tail call i32 @abort_crypto_lib(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
br label %35
19: ; preds = %2
%20 = icmp slt i32 %1, 34
br i1 %20, label %21, label %35
21: ; preds = %19
%22 = tail call i32 @abort_crypto_lib(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0))
br label %35
23: ; preds = %2
%24 = add i32 %1, -2050
%25 = icmp ult i32 %24, -2048
br i1 %25, label %26, label %35
26: ; preds = %23
%27 = tail call i32 @abort_crypto_lib(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0))
br label %35
28: ; preds = %2
%29 = add i32 %1, -2050
%30 = icmp ult i32 %29, -2048
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = tail call i32 @abort_crypto_lib(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0))
br label %35
33: ; preds = %2
%34 = tail call i32 @abort_crypto_lib(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0))
br label %35
35: ; preds = %31, %28, %26, %23, %19, %21, %15, %17, %11, %13, %7, %9, %33, %2, %2, %2, %2, %5
ret void
}