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


x86 assembly (clang, -O0):
<search_platform_left>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
movsd  %xmm2,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xec9(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
cvtsi2sdl -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xea5(%rip),%xmm2
subsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    11ba <search_platform_left+0xaa>
mov    -0x2c(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
mov    -0x1c(%rbp),%esi
call   1030 <search_col@plt>
cmp    $0x0,%rax
je     11a3 <search_platform_left+0x93>
cvtsi2sdl -0x2c(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xe6b(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11c7 <search_platform_left+0xb7>
mov    -0x30(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2c(%rbp)
jmp    1149 <search_platform_left+0x39>
movsd  0xe3e(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search_platform_left>:
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 %xmm2,%xmm1
jbe    11b0 <search_platform_left+0xa0>
mov    %edi,%r14d
movsd  0xeb3(%rip),%xmm0
movsd  %xmm3,0x8(%rsp)
addsd  %xmm3,%xmm0
cvttsd2si %xmm0,%ebx
mov    $0xffffffff,%ebp
lea    (%rbx,%rbp,1),%edi
add    $0x1,%edi
movsd  0x18(%rsp),%xmm0
mov    %r14d,%esi
call   1030 <search_col@plt>
test   %rax,%rax
jne    1195 <search_platform_left+0x85>
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
add    $0xffffffff,%ebp
ucomisd 0x10(%rsp),%xmm0
ja     1160 <search_platform_left+0x50>
movsd  0xe75(%rip),%xmm0
jmp    11b0 <search_platform_left+0xa0>
lea    (%rbx,%rbp,1),%eax
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
subsd  0x8(%rsp),%xmm0
addsd  0xe58(%rip),%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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