#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__ search_col(int, double, int);
double search_platform_right(double x, double y, int height,
                             double max_distance) {
  int col;
  int cols_searched;
  col = x;
  cols_searched = 0;
  while (cols_searched < max_distance + 1) {
    if (search_col(col, y, height))
      return col - x;
    cols_searched++;
    col++;
  }
  return -1;
}


x86 assembly (clang, -O0):
<search_platform_right>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
movsd  %xmm2,-0x28(%rbp)
cvttsd2si -0x10(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
cvtsi2sdl -0x30(%rbp),%xmm1
movsd  0xeba(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    119a <search_platform_right+0x8a>
mov    -0x2c(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
mov    -0x1c(%rbp),%esi
call   1030 <search_col@plt>
cmp    $0x0,%rax
je     1183 <search_platform_right+0x73>
cvtsi2sdl -0x2c(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11a7 <search_platform_right+0x97>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1139 <search_platform_right+0x29>
movsd  0xe66(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search_platform_right>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
movsd  %xmm1,0x18(%rsp)
movapd %xmm0,%xmm3
addsd  0xed6(%rip),%xmm2
movsd  0xed6(%rip),%xmm0
xorpd  %xmm1,%xmm1
movsd  %xmm2,0x10(%rsp)
ucomisd %xmm1,%xmm2
jbe    11ac <search_platform_right+0x9c>
mov    %edi,%r14d
movsd  %xmm3,0x8(%rsp)
cvttsd2si %xmm3,%ebx
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    (%rbx,%rbp,1),%edi
add    $0xffffffff,%edi
movsd  0x18(%rsp),%xmm0
mov    %r14d,%esi
call   1030 <search_col@plt>
test   %rax,%rax
jne    1199 <search_platform_right+0x89>
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
add    $0x1,%ebp
movsd  0x10(%rsp),%xmm1
ucomisd %xmm0,%xmm1
ja     1160 <search_platform_right+0x50>
movsd  0xe71(%rip),%xmm0
jmp    11ac <search_platform_right+0x9c>
lea    (%rbx,%rbp,1),%eax
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
subsd  0x8(%rsp),%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @search_platform_right(double %0, double %1, i32 %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
store double %0, double* %6
store double %1, double* %7
store i32 %2, i32* %8
store double %3, double* %9
%12 = load double, double* %6
%13 = fptosi double %12 to i32
store i32 %13, i32* %10
store i32 0, i32* %11
br label %14
14: ; preds = %31, %4
%15 = load i32, i32* %11
%16 = sitofp i32 %15 to double
%17 = load double, double* %9
%18 = fadd double %17, 1.000000e+00
%19 = fcmp olt double %16, %18
br i1 %19, label %20, label %36
20: ; preds = %14
%21 = load i32, i32* %10
%22 = load double, double* %7
%23 = load i32, i32* %8
%24 = call i64 @search_col(i32 %21, double %22, i32 %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %20
%27 = load i32, i32* %10
%28 = sitofp i32 %27 to double
%29 = load double, double* %6
%30 = fsub double %28, %29
store double %30, double* %5
br label %37
31: ; preds = %20
%32 = load i32, i32* %11
%33 = add nsw i32 %32, 1
store i32 %33, i32* %11
%34 = load i32, i32* %10
%35 = add nsw i32 %34, 1
store i32 %35, i32* %10
br label %14
36: ; preds = %14
store double -1.000000e+00, double* %5
br label %37
37: ; preds = %36, %26
%38 = load double, double* %5
ret double %38
}

LLVM IR (-O2):
define double @search_platform_right(double %0, double %1, i32 %2, double %3) {
%5 = fadd double %3, 1.000000e+00
%6 = fcmp ogt double %5, 0.000000e+00
br i1 %6, label %7, label %22
7: ; preds = %4
%8 = fptosi double %0 to i32
br label %9
9: ; preds = %7, %17
%10 = phi i32 [ %18, %17 ], [ 0, %7 ]
%11 = phi i32 [ %19, %17 ], [ %8, %7 ]
%12 = tail call i64 @search_col(i32 %11, double %1, i32 %2)
%13 = icmp eq i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %9
%15 = sitofp i32 %11 to double
%16 = fsub double %15, %0
br label %22
17: ; preds = %9
%18 = add nuw nsw i32 %10, 1
%19 = add nsw i32 %11, 1
%20 = sitofp i32 %18 to double
%21 = fcmp ogt double %5, %20
br i1 %21, label %9, label %22
22: ; preds = %17, %4, %14
%23 = phi double [ %16, %14 ], [ -1.000000e+00, %4 ], [ -1.000000e+00, %17 ]
ret double %23
}