#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 */
float float_difference(float, float);
float clip_intersect_x(float p1x, float p1y, float p2x, float p2y,
                       float y_arg) {
  float a;
  float diff = float_difference(p1y, p2y);
  if (diff == 0.0f)
    return p2x;
  a = (y_arg - p2y) / diff;
  return p2x + (p1x - p2x) * a;
}


x86 assembly (clang, -O0):
<clip_intersect_x>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
movss  %xmm3,-0x14(%rbp)
movss  %xmm4,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
call   1030 <float_difference@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    116b <clip_intersect_x+0x5b>
jp     116b <clip_intersect_x+0x5b>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11a0 <clip_intersect_x+0x90>
movss  -0x18(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
divss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x10(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
subss  -0x10(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clip_intersect_x>:
sub    $0x18,%rsp
movss  %xmm4,0x14(%rsp)
movss  %xmm2,0x8(%rsp)
movss  %xmm0,0x10(%rsp)
movaps %xmm1,%xmm0
movss  %xmm3,0xc(%rsp)
movaps %xmm3,%xmm1
call   1030 <float_difference@plt>
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    114c <clip_intersect_x+0x3c>
jp     114c <clip_intersect_x+0x3c>
movss  0x8(%rsp),%xmm0
add    $0x18,%rsp
ret
movss  0x14(%rsp),%xmm1
subss  0xc(%rsp),%xmm1
divss  %xmm0,%xmm1
movss  0x8(%rsp),%xmm2
movss  0x10(%rsp),%xmm0
subss  %xmm2,%xmm0
mulss  %xmm1,%xmm0
addss  %xmm2,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define float @clip_intersect_x(float %0, float %1, float %2, float %3, float %4) {
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
store float %0, float* %7
store float %1, float* %8
store float %2, float* %9
store float %3, float* %10
store float %4, float* %11
%14 = load float, float* %8
%15 = load float, float* %10
%16 = call float @float_difference(float %14, float %15)
store float %16, float* %13
%17 = load float, float* %13
%18 = fcmp oeq float %17, 0.000000e+00
br i1 %18, label %19, label %21
19: ; preds = %5
%20 = load float, float* %9
store float %20, float* %6
br label %33
21: ; preds = %5
%22 = load float, float* %11
%23 = load float, float* %10
%24 = fsub float %22, %23
%25 = load float, float* %13
%26 = fdiv float %24, %25
store float %26, float* %12
%27 = load float, float* %9
%28 = load float, float* %7
%29 = load float, float* %9
%30 = fsub float %28, %29
%31 = load float, float* %12
%32 = call float @llvm.fmuladd.f32(float %30, float %31, float %27)
store float %32, float* %6
br label %33
33: ; preds = %21, %19
%34 = load float, float* %6
ret float %34
}

LLVM IR (-O2):
define float @clip_intersect_x(float %0, float %1, float %2, float %3, float %4) {
%6 = tail call float @float_difference(float %1, float %3)
%7 = fcmp oeq float %6, 0.000000e+00
br i1 %7, label %13, label %8
8: ; preds = %5
%9 = fsub float %4, %3
%10 = fdiv float %9, %6
%11 = fsub float %0, %2
%12 = tail call float @llvm.fmuladd.f32(float %11, float %10, float %2)
br label %13
13: ; preds = %5, %8
%14 = phi float [ %12, %8 ], [ %2, %5 ]
ret float %14
}