#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*/ StringsEqual(char *, char *);
char *SubstringBetween(char *, char, char);
int /*<<< orphan*/ free(char *);
int OperandModeType(char *operand) {
  char *actual;
  int isStackOp;
  switch (operand[0]) {
  case '~':
    return 0;
  case '(':
    actual = SubstringBetween(operand, '(', ')');
    isStackOp = StringsEqual("sp", actual) ? 1 : 0;
    free(actual);
    if (isStackOp)
      return 1;
    else
      return 4;
  case '[':
    return 5;
  case '{':
    return 6;
  default:
    return 3;
  }
}


x86 assembly (clang, -O0):
<OperandModeType>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x20(%rbp)
sub    $0x28,%eax
je     1193 <OperandModeType+0x63>
jmp    1154 <OperandModeType+0x24>
mov    -0x20(%rbp),%eax
sub    $0x5b,%eax
je     11f7 <OperandModeType+0xc7>
jmp    1165 <OperandModeType+0x35>
mov    -0x20(%rbp),%eax
sub    $0x7b,%eax
je     1203 <OperandModeType+0xd3>
jmp    1176 <OperandModeType+0x46>
mov    -0x20(%rbp),%eax
sub    $0x7e,%eax
jne    120f <OperandModeType+0xdf>
jmp    1187 <OperandModeType+0x57>
movl   $0x0,-0x4(%rbp)
jmp    1216 <OperandModeType+0xe6>
mov    -0x10(%rbp),%rdi
mov    $0x28,%esi
mov    $0x29,%edx
call   1040 <SubstringBetween@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe4b(%rip),%rdi
call   1050 <StringsEqual@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x1c(%rbp)
je     11eb <OperandModeType+0xbb>
movl   $0x1,-0x4(%rbp)
jmp    1216 <OperandModeType+0xe6>
movl   $0x4,-0x4(%rbp)
jmp    1216 <OperandModeType+0xe6>
movl   $0x5,-0x4(%rbp)
jmp    1216 <OperandModeType+0xe6>
movl   $0x6,-0x4(%rbp)
jmp    1216 <OperandModeType+0xe6>
movl   $0x3,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OperandModeType>:
push   %r14
push   %rbx
push   %rax
movsbl (%rdi),%ecx
cmp    $0x7a,%ecx
jg     114d <OperandModeType+0x1d>
cmp    $0x28,%ecx
je     1160 <OperandModeType+0x30>
cmp    $0x5b,%ecx
jne    1159 <OperandModeType+0x29>
mov    $0x5,%eax
jmp    119d <OperandModeType+0x6d>
cmp    $0x7b,%ecx
je     1198 <OperandModeType+0x68>
xor    %eax,%eax
cmp    $0x7e,%ecx
je     119d <OperandModeType+0x6d>
mov    $0x3,%eax
jmp    119d <OperandModeType+0x6d>
mov    $0x28,%esi
mov    $0x29,%edx
call   1040 <SubstringBetween@plt>
mov    %rax,%r14
lea    0xe87(%rip),%rdi
mov    %rax,%rsi
call   1050 <StringsEqual@plt>
xor    %ebx,%ebx
test   %eax,%eax
sete   %bl
mov    %r14,%rdi
call   1030 <free@plt>
lea    (%rbx,%rbx,2),%eax
add    $0x1,%eax
jmp    119d <OperandModeType+0x6d>
mov    $0x6,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"sp\00"
define i32 @OperandModeType(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
switch i32 %9, label %27 [
i32 126, label %10
i32 40, label %11
i32 91, label %25
i32 123, label %26
]
10: ; preds = %1
store i32 0, i32* %2
br label %28
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i8* @SubstringBetween(i8* %12, i8 signext 40, i8 signext 41)
store i8* %13, i8** %4
%14 = load i8*, i8** %4
%15 = call i32 @StringsEqual(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = icmp ne i32 %15, 0
%17 = zext i1 %16 to i64
%18 = select i1 %16, i32 1, i32 0
store i32 %18, i32* %5
%19 = load i8*, i8** %4
%20 = call i32 @free(i8* %19)
%21 = load i32, i32* %5
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %11
store i32 1, i32* %2
br label %28
24: ; preds = %11
store i32 4, i32* %2
br label %28
25: ; preds = %1
store i32 5, i32* %2
br label %28
26: ; preds = %1
store i32 6, i32* %2
br label %28
27: ; preds = %1
store i32 3, i32* %2
br label %28
28: ; preds = %27, %26, %25, %24, %23, %10
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@.str = [3 x i8] c"sp\00"
define i32 @OperandModeType(i8* %0) {
%2 = load i8, i8* %0
%3 = sext i8 %2 to i32
switch i32 %3, label %12 [
i32 126, label %13
i32 40, label %4
i32 91, label %10
i32 123, label %11
]
4: ; preds = %1
%5 = tail call i8* @SubstringBetween(i8* %0, i8 signext 40, i8 signext 41)
%6 = tail call i32 @StringsEqual(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = icmp eq i32 %6, 0
%8 = tail call i32 @free(i8* %5)
%9 = select i1 %7, i32 4, i32 1
br label %13
10: ; preds = %1
br label %13
11: ; preds = %1
br label %13
12: ; preds = %1
br label %13
13: ; preds = %4, %1, %12, %11, %10
%14 = phi i32 [ 3, %12 ], [ 6, %11 ], [ 5, %10 ], [ 0, %1 ], [ %9, %4 ]
ret i32 %14
}