int rule_getoper(char *clause, int *op) {
  if (clause[1] == '=') {
    switch (clause[0]) {
    case '=':
      *op = 1;
      return 2;
    case '!':
      *op = 2;
      return 2;
    case '+':
      *op = 3;
      return 2;
    case ':':
      *op = 6;
      return 2;
    }
    return 0;
  }
  if (clause[0] == '=') {
    *op = 5;
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<rule_getoper>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x3d,%eax
jne    11ae <rule_getoper+0xae>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffdf,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x1c,%eax
ja     11a2 <rule_getoper+0xa2>
mov    -0x20(%rbp),%rax
lea    0xebf(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x2,-0x4(%rbp)
jmp    11db <rule_getoper+0xdb>
mov    -0x18(%rbp),%rax
movl   $0x2,(%rax)
movl   $0x2,-0x4(%rbp)
jmp    11db <rule_getoper+0xdb>
mov    -0x18(%rbp),%rax
movl   $0x3,(%rax)
movl   $0x2,-0x4(%rbp)
jmp    11db <rule_getoper+0xdb>
mov    -0x18(%rbp),%rax
movl   $0x6,(%rax)
movl   $0x2,-0x4(%rbp)
jmp    11db <rule_getoper+0xdb>
movl   $0x0,-0x4(%rbp)
jmp    11db <rule_getoper+0xdb>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3d,%eax
jne    11d4 <rule_getoper+0xd4>
mov    -0x18(%rbp),%rax
movl   $0x5,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11db <rule_getoper+0xdb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<rule_getoper>:
cmpb   $0x3d,0x1(%rdi)
movsbl (%rdi),%edi
jne    1139 <rule_getoper+0x39>
xor    %eax,%eax
add    $0xffffffdf,%edi
cmp    $0x1c,%edi
ja     115d <rule_getoper+0x5d>
mov    $0x2,%ecx
mov    $0x1,%edx
lea    0xedc(%rip),%r8
movslq (%r8,%rdi,4),%rdi
add    %r8,%rdi
jmp    *%rdi
mov    $0x2,%edx
mov    $0x2,%ecx
jmp    1159 <rule_getoper+0x59>
xor    %eax,%eax
cmp    $0x3d,%dil
jne    115d <rule_getoper+0x5d>
mov    $0x1,%ecx
mov    $0x5,%edx
jmp    1159 <rule_getoper+0x59>
mov    $0x3,%edx
jmp    1159 <rule_getoper+0x59>
mov    $0x6,%edx
mov    %edx,(%rsi)
mov    %ecx,%eax
ret

LLVM IR (-O0):
define i32 @rule_getoper(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
store i8* %0, i8** %4
store i32* %1, i32** %5
%6 = load i8*, i8** %4
%7 = getelementptr inbounds i8, i8* %6, i64 1
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 61
br i1 %10, label %11, label %25
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
switch i32 %15, label %24 [
i32 61, label %16
i32 33, label %18
i32 43, label %20
i32 58, label %22
]
16: ; preds = %11
%17 = load i32*, i32** %5
store i32 1, i32* %17
store i32 2, i32* %3
br label %34
18: ; preds = %11
%19 = load i32*, i32** %5
store i32 2, i32* %19
store i32 2, i32* %3
br label %34
20: ; preds = %11
%21 = load i32*, i32** %5
store i32 3, i32* %21
store i32 2, i32* %3
br label %34
22: ; preds = %11
%23 = load i32*, i32** %5
store i32 6, i32* %23
store i32 2, i32* %3
br label %34
24: ; preds = %11
store i32 0, i32* %3
br label %34
25: ; preds = %2
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i64 0
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 61
br i1 %30, label %31, label %33
31: ; preds = %25
%32 = load i32*, i32** %5
store i32 5, i32* %32
store i32 1, i32* %3
br label %34
33: ; preds = %25
store i32 0, i32* %3
br label %34
34: ; preds = %33, %31, %24, %22, %20, %18, %16
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
define i32 @rule_getoper(i8* nocapture %0, i32* nocapture writeonly %1) {
%3 = getelementptr inbounds i8, i8* %0, i64 1
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 61
%6 = load i8, i8* %0
br i1 %5, label %7, label %12
7: ; preds = %2
%8 = sext i8 %6 to i32
switch i32 %8, label %17 [
i32 61, label %14
i32 33, label %9
i32 43, label %10
i32 58, label %11
]
9: ; preds = %7
br label %14
10: ; preds = %7
br label %14
11: ; preds = %7
br label %14
12: ; preds = %2
%13 = icmp eq i8 %6, 61
br i1 %13, label %14, label %17
14: ; preds = %12, %7, %9, %10, %11
%15 = phi i32 [ 6, %11 ], [ 3, %10 ], [ 2, %9 ], [ 1, %7 ], [ 5, %12 ]
%16 = phi i32 [ 2, %11 ], [ 2, %10 ], [ 2, %9 ], [ 2, %7 ], [ 1, %12 ]
store i32 %15, i32* %1
br label %17
17: ; preds = %14, %12, %7
%18 = phi i32 [ 0, %7 ], [ 0, %12 ], [ %16, %14 ]
ret i32 %18
}