#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 compareStringAndStringProperty(char *leftFirst,
                                             unsigned short leftLength,
                                             char *rightFirst,
                                             unsigned short rightLength,
                                             unsigned char op) {
  char rightTemp = rightFirst[rightLength];
  rightFirst[rightLength] = '\0';
  char leftTemp = leftFirst[leftLength];
  leftFirst[leftLength] = '\0';
  int result = strcmp(leftFirst, rightFirst);
  rightFirst[rightLength] = rightTemp;
  leftFirst[leftLength] = leftTemp;
  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):
<compareStringAndStringProperty>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %r8b,%al
mov    %rdi,-0x10(%rbp)
mov    %si,-0x12(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %cx,-0x22(%rbp)
mov    %al,-0x23(%rbp)
mov    -0x20(%rbp),%rax
movzwl -0x22(%rbp),%ecx
mov    (%rax,%rcx,1),%al
mov    %al,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movzwl -0x22(%rbp),%ecx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
movzwl -0x12(%rbp),%ecx
mov    (%rax,%rcx,1),%al
mov    %al,-0x25(%rbp)
mov    -0x10(%rbp),%rax
movzwl -0x12(%rbp),%ecx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcmp@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%dl
mov    -0x20(%rbp),%rax
movzwl -0x22(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x25(%rbp),%dl
mov    -0x10(%rbp),%rax
movzwl -0x12(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
movzbl -0x23(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x5,%eax
ja     1230 <compareStringAndStringProperty+0x120>
mov    -0x38(%rbp),%rax
lea    0xe51(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x0,-0x2c(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x1(%rbp)
jmp    1234 <compareStringAndStringProperty+0x124>
cmpl   $0x0,-0x2c(%rbp)
setle  %al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x1(%rbp)
jmp    1234 <compareStringAndStringProperty+0x124>
cmpl   $0x0,-0x2c(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x1(%rbp)
jmp    1234 <compareStringAndStringProperty+0x124>
cmpl   $0x0,-0x2c(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x1(%rbp)
jmp    1234 <compareStringAndStringProperty+0x124>
cmpl   $0x0,-0x2c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x1(%rbp)
jmp    1234 <compareStringAndStringProperty+0x124>
cmpl   $0x0,-0x2c(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x1(%rbp)
jmp    1234 <compareStringAndStringProperty+0x124>
movb   $0x0,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compareStringAndStringProperty>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %rdx,%rbx
mov    %rdi,%rbp
mov    %ecx,%r15d
mov    (%rdx,%r15,1),%al
mov    %al,0x7(%rsp)
movb   $0x0,(%rdx,%r15,1)
mov    %esi,%r13d
mov    (%rdi,%r13,1),%r12b
movb   $0x0,(%rdi,%r13,1)
mov    %rdx,%rsi
call   1030 <strcmp@plt>
mov    0x7(%rsp),%cl
mov    %cl,(%rbx,%r15,1)
mov    %r12b,0x0(%rbp,%r13,1)
add    $0xff,%r14b
cmp    $0x5,%r14b
ja     1178 <compareStringAndStringProperty+0x68>
movzbl %r14b,%ecx
lea    0xe96(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
shr    $0x1f,%eax
jmp    119d <compareStringAndStringProperty+0x8d>
xor    %eax,%eax
jmp    119d <compareStringAndStringProperty+0x8d>
test   %eax,%eax
setle  %al
jmp    119d <compareStringAndStringProperty+0x8d>
test   %eax,%eax
setg   %al
jmp    119d <compareStringAndStringProperty+0x8d>
test   %eax,%eax
setns  %al
jmp    119d <compareStringAndStringProperty+0x8d>
test   %eax,%eax
sete   %al
jmp    119d <compareStringAndStringProperty+0x8d>
test   %eax,%eax
setne  %al
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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