#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 */
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
char toupper(char);
int string_relation(char *operator, char * s1, char *s2) {
  int t, l1, l2, i;
  char s3[255], s4[255];
  if (strcmp(operator, "=") == 0) {
    t = (strcmp(s1, s2) == 0);
  } else if (strcmp(operator, "==") == 0) {
    t = (strcmp(s1, s2) == 0);
  } else if (strcmp(operator, "!=") == 0) {
    t = (strcmp(s1, s2) != 0);
  } else if (strcmp(operator, "matches") == 0) {
    l1 = strlen(s1);
    l2 = strlen(s2);
    strcpy(s3, s1);
    strcpy(s4, s2);
    for (i = 0; i < l1; i++)
      s3[i] = toupper(s1[i]);
    for (i = 0; i < l2; i++)
      s4[i] = toupper(s2[i]);
    t = (strncmp(s3, s4, l2) == 0);
  } else
    t = 0;
  return (t);
}


x86 assembly (clang, -O0):
<string_relation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11a2 <string_relation+0x52>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
jmp    1328 <string_relation+0x1d8>
mov    -0x8(%rbp),%rdi
lea    0xe53(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11dd <string_relation+0x8d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
jmp    1323 <string_relation+0x1d3>
mov    -0x8(%rbp),%rdi
lea    0xe1b(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1218 <string_relation+0xc8>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
jmp    131e <string_relation+0x1ce>
mov    -0x8(%rbp),%rdi
lea    0xde3(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1312 <string_relation+0x1c2>
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x24(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x230(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    12a9 <string_relation+0x159>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <toupper@plt>
mov    %al,%cl
movslq -0x28(%rbp),%rax
mov    %cl,-0x130(%rbp,%rax,1)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1271 <string_relation+0x121>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12e8 <string_relation+0x198>
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <toupper@plt>
mov    %al,%cl
movslq -0x28(%rbp),%rax
mov    %cl,-0x230(%rbp,%rax,1)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    12b0 <string_relation+0x160>
lea    -0x130(%rbp),%rdi
lea    -0x230(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
jmp    1319 <string_relation+0x1c9>
movl   $0x0,-0x1c(%rbp)
jmp    131e <string_relation+0x1ce>
jmp    1323 <string_relation+0x1d3>
jmp    1328 <string_relation+0x1d8>
mov    -0x1c(%rbp),%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_relation>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x200,%rsp
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%rbp
lea    0xe95(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11b9 <string_relation+0x69>
lea    0xe80(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11b9 <string_relation+0x69>
lea    0xe6f(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11dd <string_relation+0x8d>
lea    0xe5e(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11f0 <string_relation+0xa0>
xor    %eax,%eax
jmp    11ca <string_relation+0x7a>
mov    %r12,%rdi
mov    %r14,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
sete   %al
movzbl %al,%eax
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r12,%rdi
mov    %r14,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
setne  %al
jmp    11ca <string_relation+0x7a>
mov    %r12,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %eax,%r15d
lea    0x100(%rsp),%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
mov    %rsp,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
test   %ebp,%ebp
jle    124a <string_relation+0xfa>
mov    %ebp,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsbl (%r12,%rbx,1),%edi
call   1050 <toupper@plt>
mov    %al,0x100(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1230 <string_relation+0xe0>
test   %r15d,%r15d
jle    1276 <string_relation+0x126>
mov    %r15d,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%r14,%rbp,1),%edi
call   1050 <toupper@plt>
mov    %al,(%rsp,%rbp,1)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1260 <string_relation+0x110>
lea    0x100(%rsp),%rdi
mov    %rsp,%rsi
mov    %r15d,%edx
call   1030 <strncmp@plt>
jmp    11c4 <string_relation+0x74>

LLVM IR (-O0):
@.str = [2 x i8] c"=\00"
@.str.1 = [3 x i8] c"==\00"
@.str.2 = [3 x i8] c"!=\00"
@.str.3 = [8 x i8] c"matches\00"
define i32 @string_relation(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [255 x i8]
%12 = alloca [255 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%13 = load i8*, i8** %4
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %3
%17 = load i8*, i8** %5
%18 = load i8*, i8** %6
%19 = call i64 @strcmp(i8* %17, i8* %18)
%20 = icmp eq i64 %19, 0
%21 = zext i1 %20 to i32
store i32 %21, i32* %7
br label %103
22: ; preds = %3
%23 = load i8*, i8** %4
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %32
26: ; preds = %22
%27 = load i8*, i8** %5
%28 = load i8*, i8** %6
%29 = call i64 @strcmp(i8* %27, i8* %28)
%30 = icmp eq i64 %29, 0
%31 = zext i1 %30 to i32
store i32 %31, i32* %7
br label %102
32: ; preds = %22
%33 = load i8*, i8** %4
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %42
36: ; preds = %32
%37 = load i8*, i8** %5
%38 = load i8*, i8** %6
%39 = call i64 @strcmp(i8* %37, i8* %38)
%40 = icmp ne i64 %39, 0
%41 = zext i1 %40 to i32
store i32 %41, i32* %7
br label %101
42: ; preds = %32
%43 = load i8*, i8** %4
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %99
46: ; preds = %42
%47 = load i8*, i8** %5
%48 = call i32 @strlen(i8* %47)
store i32 %48, i32* %8
%49 = load i8*, i8** %6
%50 = call i32 @strlen(i8* %49)
store i32 %50, i32* %9
%51 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%52 = load i8*, i8** %5
%53 = call i32 @strcpy(i8* %51, i8* %52)
%54 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%55 = load i8*, i8** %6
%56 = call i32 @strcpy(i8* %54, i8* %55)
store i32 0, i32* %10
br label %57
57: ; preds = %71, %46
%58 = load i32, i32* %10
%59 = load i32, i32* %8
%60 = icmp slt i32 %58, %59
br i1 %60, label %61, label %74
61: ; preds = %57
%62 = load i8*, i8** %5
%63 = load i32, i32* %10
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %62, i64 %64
%66 = load i8, i8* %65
%67 = call signext i8 @toupper(i8 signext %66)
%68 = load i32, i32* %10
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 %69
store i8 %67, i8* %70
br label %71
71: ; preds = %61
%72 = load i32, i32* %10
%73 = add nsw i32 %72, 1
store i32 %73, i32* %10
br label %57
74: ; preds = %57
store i32 0, i32* %10
br label %75
75: ; preds = %89, %74
%76 = load i32, i32* %10
%77 = load i32, i32* %9
%78 = icmp slt i32 %76, %77
br i1 %78, label %79, label %92
79: ; preds = %75
%80 = load i8*, i8** %6
%81 = load i32, i32* %10
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i8, i8* %80, i64 %82
%84 = load i8, i8* %83
%85 = call signext i8 @toupper(i8 signext %84)
%86 = load i32, i32* %10
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 %87
store i8 %85, i8* %88
br label %89
89: ; preds = %79
%90 = load i32, i32* %10
%91 = add nsw i32 %90, 1
store i32 %91, i32* %10
br label %75
92: ; preds = %75
%93 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%94 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%95 = load i32, i32* %9
%96 = call i64 @strncmp(i8* %93, i8* %94, i32 %95)
%97 = icmp eq i64 %96, 0
%98 = zext i1 %97 to i32
store i32 %98, i32* %7
br label %100
99: ; preds = %42
store i32 0, i32* %7
br label %100
100: ; preds = %99, %92
br label %101
101: ; preds = %100, %36
br label %102
102: ; preds = %101, %26
br label %103
103: ; preds = %102, %16
%104 = load i32, i32* %7
ret i32 %104
}

LLVM IR (-O2):
@.str = [2 x i8] c"=\00"
@.str.1 = [3 x i8] c"==\00"
@.str.2 = [3 x i8] c"!=\00"
@.str.3 = [8 x i8] c"matches\00"
define i32 @string_relation(i8* %0, i8* %1, i8* %2) {
%4 = alloca [255 x i8]
%5 = alloca [255 x i8]
%6 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%8 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = tail call i64 @strcmp(i8* %1, i8* %2)
%12 = icmp eq i64 %11, 0
br label %59
13: ; preds = %3
%14 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = tail call i64 @strcmp(i8* %1, i8* %2)
%18 = icmp eq i64 %17, 0
br label %59
19: ; preds = %13
%20 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = tail call i64 @strcmp(i8* %1, i8* %2)
%24 = icmp ne i64 %23, 0
br label %59
25: ; preds = %19
%26 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %59
28: ; preds = %25
%29 = tail call i32 @strlen(i8* %1)
%30 = tail call i32 @strlen(i8* %2)
%31 = call i32 @strcpy(i8* %6, i8* %1)
%32 = call i32 @strcpy(i8* %7, i8* %2)
%33 = icmp sgt i32 %29, 0
br i1 %33, label %34, label %36
34: ; preds = %28
%35 = zext i32 %29 to i64
br label %40
36: ; preds = %40, %28
%37 = icmp sgt i32 %30, 0
br i1 %37, label %38, label %56
38: ; preds = %36
%39 = zext i32 %30 to i64
br label %48
40: ; preds = %34, %40
%41 = phi i64 [ 0, %34 ], [ %46, %40 ]
%42 = getelementptr inbounds i8, i8* %1, i64 %41
%43 = load i8, i8* %42
%44 = call signext i8 @toupper(i8 signext %43)
%45 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 %41
store i8 %44, i8* %45
%46 = add nuw nsw i64 %41, 1
%47 = icmp eq i64 %46, %35
br i1 %47, label %36, label %40
48: ; preds = %38, %48
%49 = phi i64 [ 0, %38 ], [ %54, %48 ]
%50 = getelementptr inbounds i8, i8* %2, i64 %49
%51 = load i8, i8* %50
%52 = call signext i8 @toupper(i8 signext %51)
%53 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 %49
store i8 %52, i8* %53
%54 = add nuw nsw i64 %49, 1
%55 = icmp eq i64 %54, %39
br i1 %55, label %56, label %48
56: ; preds = %48, %36
%57 = call i64 @strncmp(i8* %6, i8* %7, i32 %30)
%58 = icmp eq i64 %57, 0
br label %59
59: ; preds = %25, %16, %56, %22, %10
%60 = phi i1 [ %12, %10 ], [ %18, %16 ], [ %24, %22 ], [ %58, %56 ], [ false, %25 ]
%61 = zext i1 %60 to i32
ret i32 %61
}