#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*/ calculate_search_speed(int *);
void calculate_treshold(double sensors[4], int distance_threshold) {
  int i;
  int threshold_list[4];
  for (i = 0; i < 4; i++) {
    if (sensors[i] > distance_threshold) {
      threshold_list[i] = 1;
    } else {
      threshold_list[i] = 0;
    }
  }
  calculate_search_speed(threshold_list);
}


x86 assembly (clang, -O0):
<calculate_treshold>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    117c <calculate_treshold+0x6c>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    115d <calculate_treshold+0x4d>
movslq -0x10(%rbp),%rax
movl   $0x1,-0x20(%rbp,%rax,4)
jmp    1169 <calculate_treshold+0x59>
movslq -0x10(%rbp),%rax
movl   $0x0,-0x20(%rbp,%rax,4)
jmp    116e <calculate_treshold+0x5e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <calculate_treshold+0x16>
lea    -0x20(%rbp),%rdi
call   1030 <calculate_search_speed@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculate_treshold>:
sub    $0x18,%rsp
cvtsi2sd %esi,%xmm0
movupd (%rdi),%xmm1
movupd 0x10(%rdi),%xmm2
unpcklpd %xmm0,%xmm0
movapd %xmm0,%xmm3
cmpltpd %xmm2,%xmm3
cmpltpd %xmm1,%xmm0
shufps $0x88,%xmm3,%xmm0
andps  0xec2(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
call   1030 <calculate_search_speed@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
define void @calculate_treshold(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [4 x i32]
store double* %0, double** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %7
7: ; preds = %28, %2
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 4
br i1 %9, label %10, label %31
10: ; preds = %7
%11 = load double*, double** %3
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds double, double* %11, i64 %13
%15 = load double, double* %14
%16 = load i32, i32* %4
%17 = sitofp i32 %16 to double
%18 = fcmp ogt double %15, %17
br i1 %18, label %19, label %23
19: ; preds = %10
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 %21
store i32 1, i32* %22
br label %27
23: ; preds = %10
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 %25
store i32 0, i32* %26
br label %27
27: ; preds = %23, %19
br label %28
28: ; preds = %27
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %7
31: ; preds = %7
%32 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%33 = call i32 @calculate_search_speed(i32* %32)
ret void
}

LLVM IR (-O2):
define void @calculate_treshold(double* nocapture %0, i32 %1) {
%3 = alloca <4 x i32>
%4 = bitcast <4 x i32>* %3 to i8*
%5 = sitofp i32 %1 to double
%6 = getelementptr inbounds <4 x i32>, <4 x i32>* %3, i64 0, i64 0
%7 = bitcast double* %0 to <4 x double>*
%8 = load <4 x double>, <4 x double>* %7
%9 = insertelement <4 x double> poison, double %5, i64 0
%10 = shufflevector <4 x double> %9, <4 x double> poison, <4 x i32> zeroinitializer
%11 = fcmp ogt <4 x double> %8, %10
%12 = zext <4 x i1> %11 to <4 x i32>
store <4 x i32> %12, <4 x i32>* %3
%13 = call i32 @calculate_search_speed(i32* %6)
ret void
}