#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 strcmp(char *, char *);
unsigned char compareStringProperty(char *left, char *rightFirst,
                                    unsigned short rightLength,
                                    unsigned char op) {
  char temp = rightFirst[rightLength];
  rightFirst[rightLength] = '\0';
  int result = strcmp(left, rightFirst);
  rightFirst[rightLength] = temp;
  switch (op) {
  case 0x01:
    return (result < 0);
  case 0x02:
    return (result <= 0);
  case 0x03:
    return (result > 0);
  case 0x04:
    return (result >= 0);
  case 0x05:
    return (result == 0);
  case 0x06:
    return (result != 0);
  }
  return 0;
}


x86 assembly (clang, -O0):
<compareStringProperty>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %cl,%al
mov    %dx,%cx
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %cx,-0x1a(%rbp)
mov    %al,-0x1b(%rbp)
mov    -0x18(%rbp),%rax
movzwl -0x1a(%rbp),%ecx
mov    (%rax,%rcx,1),%al
mov    %al,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movzwl -0x1a(%rbp),%ecx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcmp@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%dl
mov    -0x18(%rbp),%rax
movzwl -0x1a(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
movzbl -0x1b(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x5,%eax
ja     1206 <compareStringProperty+0xf6>
mov    -0x28(%rbp),%rax
lea    0xe7b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x0,-0x20(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x1(%rbp)
jmp    120a <compareStringProperty+0xfa>
cmpl   $0x0,-0x20(%rbp)
setle  %al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x1(%rbp)
jmp    120a <compareStringProperty+0xfa>
cmpl   $0x0,-0x20(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x1(%rbp)
jmp    120a <compareStringProperty+0xfa>
cmpl   $0x0,-0x20(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x1(%rbp)
jmp    120a <compareStringProperty+0xfa>
cmpl   $0x0,-0x20(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x1(%rbp)
jmp    120a <compareStringProperty+0xfa>
cmpl   $0x0,-0x20(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x1(%rbp)
jmp    120a <compareStringProperty+0xfa>
movb   $0x0,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compareStringProperty>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rsi,%rbx
mov    %edx,%ebp
mov    (%rsi,%rbp,1),%r15b
movb   $0x0,(%rsi,%rbp,1)
call   1030 <strcmp@plt>
mov    %r15b,(%rbx,%rbp,1)
add    $0xff,%r14b
cmp    $0x5,%r14b
ja     1153 <compareStringProperty+0x43>
movzbl %r14b,%ecx
lea    0xebb(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
shr    $0x1f,%eax
jmp    1178 <compareStringProperty+0x68>
xor    %eax,%eax
jmp    1178 <compareStringProperty+0x68>
test   %eax,%eax
setle  %al
jmp    1178 <compareStringProperty+0x68>
test   %eax,%eax
setg   %al
jmp    1178 <compareStringProperty+0x68>
test   %eax,%eax
setns  %al
jmp    1178 <compareStringProperty+0x68>
test   %eax,%eax
sete   %al
jmp    1178 <compareStringProperty+0x68>
test   %eax,%eax
setne  %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define zeroext i8 @compareStringProperty(i8* %0, i8* %1, i16 zeroext %2, i8 zeroext %3) {
%5 = alloca i8
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i16
%9 = alloca i8
%10 = alloca i8
%11 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i16 %2, i16* %8
store i8 %3, i8* %9
%12 = load i8*, i8** %7
%13 = load i16, i16* %8
%14 = zext i16 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
store i8 %16, i8* %10
%17 = load i8*, i8** %7
%18 = load i16, i16* %8
%19 = zext i16 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
store i8 0, i8* %20
%21 = load i8*, i8** %6
%22 = load i8*, i8** %7
%23 = call i32 @strcmp(i8* %21, i8* %22)
store i32 %23, i32* %11
%24 = load i8, i8* %10
%25 = load i8*, i8** %7
%26 = load i16, i16* %8
%27 = zext i16 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
store i8 %24, i8* %28
%29 = load i8, i8* %9
%30 = zext i8 %29 to i32
switch i32 %30, label %61 [
i32 1, label %31
i32 2, label %36
i32 3, label %41
i32 4, label %46
i32 5, label %51
i32 6, label %56
]
31: ; preds = %4
%32 = load i32, i32* %11
%33 = icmp slt i32 %32, 0
%34 = zext i1 %33 to i32
%35 = trunc i32 %34 to i8
store i8 %35, i8* %5
br label %62
36: ; preds = %4
%37 = load i32, i32* %11
%38 = icmp sle i32 %37, 0
%39 = zext i1 %38 to i32
%40 = trunc i32 %39 to i8
store i8 %40, i8* %5
br label %62
41: ; preds = %4
%42 = load i32, i32* %11
%43 = icmp sgt i32 %42, 0
%44 = zext i1 %43 to i32
%45 = trunc i32 %44 to i8
store i8 %45, i8* %5
br label %62
46: ; preds = %4
%47 = load i32, i32* %11
%48 = icmp sge i32 %47, 0
%49 = zext i1 %48 to i32
%50 = trunc i32 %49 to i8
store i8 %50, i8* %5
br label %62
51: ; preds = %4
%52 = load i32, i32* %11
%53 = icmp eq i32 %52, 0
%54 = zext i1 %53 to i32
%55 = trunc i32 %54 to i8
store i8 %55, i8* %5
br label %62
56: ; preds = %4
%57 = load i32, i32* %11
%58 = icmp ne i32 %57, 0
%59 = zext i1 %58 to i32
%60 = trunc i32 %59 to i8
store i8 %60, i8* %5
br label %62
61: ; preds = %4
store i8 0, i8* %5
br label %62
62: ; preds = %61, %56, %51, %46, %41, %36, %31
%63 = load i8, i8* %5
ret i8 %63
}

LLVM IR (-O2):
define zeroext i8 @compareStringProperty(i8* nocapture %0, i8* nocapture %1, i16 zeroext %2, i8 zeroext %3) {
%5 = zext i16 %2 to i64
%6 = getelementptr inbounds i8, i8* %1, i64 %5
%7 = load i8, i8* %6
store i8 0, i8* %6
%8 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(1) %1)
store i8 %7, i8* %6
switch i8 %3, label %28 [
i8 1, label %9
i8 2, label %12
i8 3, label %15
i8 4, label %18
i8 5, label %22
i8 6, label %25
]
9: ; preds = %4
%10 = lshr i32 %8, 31
%11 = trunc i32 %10 to i8
br label %28
12: ; preds = %4
%13 = icmp slt i32 %8, 1
%14 = zext i1 %13 to i8
br label %28
15: ; preds = %4
%16 = icmp sgt i32 %8, 0
%17 = zext i1 %16 to i8
br label %28
18: ; preds = %4
%19 = lshr i32 %8, 31
%20 = trunc i32 %19 to i8
%21 = xor i8 %20, 1
br label %28
22: ; preds = %4
%23 = icmp eq i32 %8, 0
%24 = zext i1 %23 to i8
br label %28
25: ; preds = %4
%26 = icmp ne i32 %8, 0
%27 = zext i1 %26 to i8
br label %28
28: ; preds = %4, %25, %22, %18, %15, %12, %9
%29 = phi i8 [ %27, %25 ], [ %24, %22 ], [ %21, %18 ], [ %17, %15 ], [ %14, %12 ], [ %11, %9 ], [ 0, %4 ]
ret i8 %29
}