#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*/ exit(int);
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char *, char *);
int find_first(float *buf, int n, char *type, float val) {
  int i;
  for (i = 0; i < n; i++) {
    if (strcmp(type, ">") == 0) {
      if (buf[i] > val)
        return i;
    } else if (strcmp(type, "<") == 0) {
      if (buf[i] < val)
        return i;
    } else if (strcmp(type, ">=") == 0) {
      if (buf[i] >= val)
        return i;
    } else if (strcmp(type, "==") == 0) {
      if (buf[i] == val)
        return i;
    } else if (strcmp(type, "!=") == 0) {
      if (buf[i] != val)
        return i;
    } else {
      printf("Error: Invalid type. Exiting program.");
      exit(-1);
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<find_first>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
movss  %xmm0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12f2 <find_first+0x1c2>
mov    -0x20(%rbp),%rdi
lea    0xe9a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    119c <find_first+0x6c>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
ucomiss -0x24(%rbp),%xmm0
jbe    1197 <find_first+0x67>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12f9 <find_first+0x1c9>
jmp    12df <find_first+0x1af>
mov    -0x20(%rbp),%rdi
lea    0xe5b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11e1 <find_first+0xb1>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
movss  -0x24(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11dc <find_first+0xac>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12f9 <find_first+0x1c9>
jmp    12da <find_first+0x1aa>
mov    -0x20(%rbp),%rdi
lea    0xe18(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1222 <find_first+0xf2>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
ucomiss -0x24(%rbp),%xmm0
jb     121d <find_first+0xed>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12f9 <find_first+0x1c9>
jmp    12d5 <find_first+0x1a5>
mov    -0x20(%rbp),%rdi
lea    0xdda(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1269 <find_first+0x139>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
ucomiss -0x24(%rbp),%xmm0
jne    1264 <find_first+0x134>
jp     1264 <find_first+0x134>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12f9 <find_first+0x1c9>
jmp    12d0 <find_first+0x1a0>
mov    -0x20(%rbp),%rdi
lea    0xd96(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12b5 <find_first+0x185>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
ucomiss -0x24(%rbp),%xmm0
jne    12a5 <find_first+0x175>
jp     12a5 <find_first+0x175>
jmp    12b0 <find_first+0x180>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12f9 <find_first+0x1c9>
jmp    12cb <find_first+0x19b>
lea    0xd51(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
jmp    12d0 <find_first+0x1a0>
jmp    12d5 <find_first+0x1a5>
jmp    12da <find_first+0x1aa>
jmp    12df <find_first+0x1af>
jmp    12e4 <find_first+0x1b4>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    114f <find_first+0x1f>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_first>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movss  %xmm0,0x4(%rsp)
mov    $0xffffffff,%eax
test   %esi,%esi
jle    124a <find_first+0x11a>
mov    %rdx,%rbx
mov    %rdi,%rbp
mov    %esi,%r13d
xor    %r14d,%r14d
lea    0xe9f(%rip),%r15
lea    0xe9a(%rip),%r12
jmp    118f <find_first+0x5f>
nopw   0x0(%rax,%rax,1)
movss  0x0(%rbp,%r14,4),%xmm0
ucomiss 0x4(%rsp),%xmm0
ja     1240 <find_first+0x110>
add    $0x1,%r14
cmp    %r14,%r13
je     1245 <find_first+0x115>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1170 <find_first+0x40>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1200 <find_first+0xd0>
mov    %rbx,%rdi
lea    0xe4b(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1214 <find_first+0xe4>
mov    %rbx,%rdi
lea    0xe3a(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1228 <find_first+0xf8>
mov    %rbx,%rdi
lea    0xe29(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1259 <find_first+0x129>
movss  0x0(%rbp,%r14,4),%xmm0
ucomiss 0x4(%rsp),%xmm0
jne    1240 <find_first+0x110>
jnp    1182 <find_first+0x52>
jmp    1240 <find_first+0x110>
nopl   (%rax)
movss  0x4(%rsp),%xmm0
ucomiss 0x0(%rbp,%r14,4),%xmm0
jbe    1182 <find_first+0x52>
jmp    1240 <find_first+0x110>
movss  0x0(%rbp,%r14,4),%xmm0
ucomiss 0x4(%rsp),%xmm0
jb     1182 <find_first+0x52>
jmp    1240 <find_first+0x110>
movss  0x0(%rbp,%r14,4),%xmm0
ucomiss 0x4(%rsp),%xmm0
jne    1182 <find_first+0x52>
jp     1182 <find_first+0x52>
mov    %r14d,%eax
jmp    124a <find_first+0x11a>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdad(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>

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

LLVM IR (-O2):
@.str = [2 x i8] c">\00"
@.str.1 = [2 x i8] c"<\00"
@.str.2 = [3 x i8] c">=\00"
@.str.3 = [3 x i8] c"==\00"
@.str.4 = [3 x i8] c"!=\00"
@.str.5 = [38 x i8] c"Error: Invalid type. Exiting program.\00"
define i32 @find_first(float* nocapture %0, i32 %1, i8* %2, float %3) {
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %60
6: ; preds = %4
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %6, %47
%9 = phi i64 [ 0, %6 ], [ %48, %47 ]
%10 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = getelementptr inbounds float, float* %0, i64 %9
%14 = load float, float* %13
%15 = fcmp ogt float %14, %3
br i1 %15, label %58, label %47
16: ; preds = %8
%17 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = getelementptr inbounds float, float* %0, i64 %9
%21 = load float, float* %20
%22 = fcmp olt float %21, %3
br i1 %22, label %56, label %47
23: ; preds = %16
%24 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = getelementptr inbounds float, float* %0, i64 %9
%28 = load float, float* %27
%29 = fcmp ult float %28, %3
br i1 %29, label %47, label %54
30: ; preds = %23
%31 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = getelementptr inbounds float, float* %0, i64 %9
%35 = load float, float* %34
%36 = fcmp oeq float %35, %3
br i1 %36, label %52, label %47
37: ; preds = %30
%38 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %37
%41 = getelementptr inbounds float, float* %0, i64 %9
%42 = load float, float* %41
%43 = fcmp une float %42, %3
br i1 %43, label %50, label %47
44: ; preds = %37
%45 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
%46 = tail call i32 @exit(i32 -1)
unreachable
47: ; preds = %12, %26, %40, %33, %19
%48 = add nuw nsw i64 %9, 1
%49 = icmp eq i64 %48, %7
br i1 %49, label %60, label %8
50: ; preds = %40
%51 = trunc i64 %9 to i32
br label %60
52: ; preds = %33
%53 = trunc i64 %9 to i32
br label %60
54: ; preds = %26
%55 = trunc i64 %9 to i32
br label %60
56: ; preds = %19
%57 = trunc i64 %9 to i32
br label %60
58: ; preds = %12
%59 = trunc i64 %9 to i32
br label %60
60: ; preds = %47, %50, %52, %54, %56, %58, %4
%61 = phi i32 [ -1, %4 ], [ %51, %50 ], [ %53, %52 ], [ %55, %54 ], [ %57, %56 ], [ %59, %58 ], [ -1, %47 ]
ret i32 %61
}