#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*/ printf(char *, double, double, double);
double find_shift(double slope, double offset) {
  double shift = slope - offset / 600.0;
  double shift2 = slope + 0.3 - offset / 6000.0;
  if (shift2 < shift)
    shift = shift2;
  if (0)
    printf("find_shift %f %f -> %f\n", slope, offset, shift);
  if (shift < 0)
    return 0.0;
  return shift;
}


x86 assembly (clang, -O0):
<find_shift>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xef0(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xed3(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xeb9(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1172 <find_shift+0x72>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    118d <find_shift+0x8d>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1197 <find_shift+0x97>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_shift>:
movsd  0xef8(%rip),%xmm2
addsd  %xmm0,%xmm2
unpcklpd %xmm1,%xmm1
divpd  0xef8(%rip),%xmm1
unpcklpd %xmm0,%xmm2
addpd  %xmm1,%xmm2
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
minsd  %xmm0,%xmm2
xorpd  %xmm0,%xmm0
maxsd  %xmm2,%xmm0
ret

LLVM IR (-O0):
define double @find_shift(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %4
store double %1, double* %5
%8 = load double, double* %4
%9 = load double, double* %5
%10 = fdiv double %9, 6.000000e+02
%11 = fsub double %8, %10
store double %11, double* %6
%12 = load double, double* %4
%13 = fadd double %12, 3.000000e-01
%14 = load double, double* %5
%15 = fdiv double %14, 6.000000e+03
%16 = fsub double %13, %15
store double %16, double* %7
%17 = load double, double* %7
%18 = load double, double* %6
%19 = fcmp olt double %17, %18
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = load double, double* %7
store double %21, double* %6
br label %22
22: ; preds = %20, %2
%23 = load double, double* %6
%24 = fcmp olt double %23, 0.000000e+00
br i1 %24, label %25, label %26
25: ; preds = %22
store double 0.000000e+00, double* %3
br label %28
26: ; preds = %22
%27 = load double, double* %6
store double %27, double* %3
br label %28
28: ; preds = %26, %25
%29 = load double, double* %3
ret double %29
}

LLVM IR (-O2):
define double @find_shift(double %0, double %1) {
%3 = fadd double %0, 3.000000e-01
%4 = insertelement <2 x double> poison, double %1, i64 0
%5 = shufflevector <2 x double> %4, <2 x double> poison, <2 x i32> zeroinitializer
%6 = fdiv <2 x double> %5, <double 6.000000e+03, double 6.000000e+02>
%7 = insertelement <2 x double> poison, double %0, i64 1
%8 = insertelement <2 x double> %7, double %3, i64 0
%9 = fsub <2 x double> %8, %6
%10 = extractelement <2 x double> %9, i64 0
%11 = extractelement <2 x double> %9, i64 1
%12 = fcmp olt double %10, %11
%13 = select i1 %12, double %10, double %11
%14 = fcmp olt double %13, 0.000000e+00
%15 = select i1 %14, double 0.000000e+00, double %13
ret double %15
}