#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 char2byte(char);
char *strtok(int /*<<< orphan*/ *, char *);
unsigned short parse_SHL() {
  unsigned short instruction = 0x800E;
  char *arg;
  arg = strtok(NULL, " ,");
  if (arg[0] != 'V') {
    return 0xFFFF;
  }
  instruction |= (char2byte(arg[1]) & 0x0F) << 8;
  arg = strtok(NULL, " ,");
  arg = strtok(NULL, " ,");
  if (arg[0] != 'V') {
    return 0xFFFF;
  }
  instruction |= (char2byte(arg[1]) & 0x0F) << 4;
  return instruction;
}


x86 assembly (clang, -O0):
<parse_SHL>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movw   $0x800e,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xec7(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x56,%eax
je     115d <parse_SHL+0x3d>
movw   $0xffff,-0x2(%rbp)
jmp    11e6 <parse_SHL+0xc6>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <char2byte@plt>
mov    %eax,%ecx
and    $0xf,%ecx
shl    $0x8,%ecx
movzwl -0x4(%rbp),%eax
or     %ecx,%eax
mov    %ax,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe79(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe65(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x56,%eax
je     11bf <parse_SHL+0x9f>
movw   $0xffff,-0x2(%rbp)
jmp    11e6 <parse_SHL+0xc6>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <char2byte@plt>
mov    %eax,%ecx
and    $0xf,%ecx
shl    $0x4,%ecx
movzwl -0x4(%rbp),%eax
or     %ecx,%eax
mov    %ax,-0x4(%rbp)
mov    -0x4(%rbp),%ax
mov    %ax,-0x2(%rbp)
movzwl -0x2(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_SHL>:
push   %rbp
push   %r14
push   %rbx
lea    0xed5(%rip),%rsi
xor    %edi,%edi
call   1040 <strtok@plt>
mov    $0xffff,%bp
cmpb   $0x56,(%rax)
jne    1184 <parse_SHL+0x64>
movsbl 0x1(%rax),%edi
call   1030 <char2byte@plt>
mov    %eax,%ebx
lea    0xeb3(%rip),%r14
xor    %edi,%edi
mov    %r14,%rsi
call   1040 <strtok@plt>
xor    %edi,%edi
mov    %r14,%rsi
call   1040 <strtok@plt>
cmpb   $0x56,(%rax)
jne    1184 <parse_SHL+0x64>
and    $0xf,%ebx
shl    $0x8,%ebx
movsbl 0x1(%rax),%edi
call   1030 <char2byte@plt>
shl    $0x4,%eax
movzbl %al,%eax
lea    (%rax,%rbx,1),%ebp
add    $0x800e,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c" ,\00"
define zeroext i16 @parse_SHL() {
%1 = alloca i16
%2 = alloca i16
%3 = alloca i8*
store i16 -32754, i16* %2
%4 = call i8* @strtok(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %4, i8** %3
%5 = load i8*, i8** %3
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 86
br i1 %9, label %10, label %11
10: ; preds = %0
store i16 -1, i16* %1
br label %42
11: ; preds = %0
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %13
%15 = call i32 @char2byte(i8 signext %14)
%16 = and i32 %15, 15
%17 = shl i32 %16, 8
%18 = load i16, i16* %2
%19 = zext i16 %18 to i32
%20 = or i32 %19, %17
%21 = trunc i32 %20 to i16
store i16 %21, i16* %2
%22 = call i8* @strtok(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %22, i8** %3
%23 = call i8* @strtok(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %23, i8** %3
%24 = load i8*, i8** %3
%25 = getelementptr inbounds i8, i8* %24, i64 0
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 86
br i1 %28, label %29, label %30
29: ; preds = %11
store i16 -1, i16* %1
br label %42
30: ; preds = %11
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i64 1
%33 = load i8, i8* %32
%34 = call i32 @char2byte(i8 signext %33)
%35 = and i32 %34, 15
%36 = shl i32 %35, 4
%37 = load i16, i16* %2
%38 = zext i16 %37 to i32
%39 = or i32 %38, %36
%40 = trunc i32 %39 to i16
store i16 %40, i16* %2
%41 = load i16, i16* %2
store i16 %41, i16* %1
br label %42
42: ; preds = %30, %29, %10
%43 = load i16, i16* %1
ret i16 %43
}

LLVM IR (-O2):
@.str = [3 x i8] c" ,\00"
define zeroext i16 @parse_SHL() {
%1 = tail call i8* @strtok(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%2 = load i8, i8* %1
%3 = icmp eq i8 %2, 86
br i1 %3, label %4, label %23
4: ; preds = %0
%5 = getelementptr inbounds i8, i8* %1, i64 1
%6 = load i8, i8* %5
%7 = tail call i32 @char2byte(i8 signext %6)
%8 = tail call i8* @strtok(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = tail call i8* @strtok(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 86
br i1 %11, label %12, label %23
12: ; preds = %4
%13 = shl i32 %7, 8
%14 = and i32 %13, 3840
%15 = getelementptr inbounds i8, i8* %9, i64 1
%16 = load i8, i8* %15
%17 = tail call i32 @char2byte(i8 signext %16)
%18 = shl i32 %17, 4
%19 = and i32 %18, 240
%20 = or i32 %19, %14
%21 = trunc i32 %20 to i16
%22 = or i16 %21, -32754
br label %23
23: ; preds = %4, %0, %12
%24 = phi i16 [ %22, %12 ], [ -1, %0 ], [ -1, %4 ]
ret i16 %24
}