#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__ floor(double);
double potm(double);
double potm_minute(double onday, int olddir) {
  double period = (24.0 * 60.0 * 60.0) / 2.0;
  double p1, p2;
  double before, after;
  int newdir;
  p1 = onday + (period / (24 * 60 * 60));
  period /= 2;
  while (period > 30) {
    p2 = p1 + (2.0 / (24 * 60 * 60));
    before = potm(p1);
    after = potm(p2);
    newdir = before < after ? -1 : +1;
    if (olddir != newdir)
      p1 += (period / (24 * 60 * 60));
    else
      p1 -= (period / (24 * 60 * 60));
    period /= 2;
  }
  p1 -= floor(p1);
  return (p1);
}


x86 assembly (clang, -O0):
<potm_minute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
movsd  0xed8(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xeb9(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe97(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe99(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    123d <potm_minute+0x11d>
movsd  0xe8f(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <potm@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <potm@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
mov    $0x1,%eax
mov    $0xffffffff,%ecx
ucomisd %xmm1,%xmm0
cmova  %ecx,%eax
mov    %eax,-0x3c(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x3c(%rbp),%eax
je     1203 <potm_minute+0xe3>
movsd  -0x18(%rbp),%xmm0
movsd  0xe18(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1222 <potm_minute+0x102>
movsd  -0x18(%rbp),%xmm1
movsd  0xdf8(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xdd1(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1172 <potm_minute+0x52>
movsd  -0x20(%rbp),%xmm0
call   1040 <floor@plt>
cvtsi2sd %rax,%xmm1
movsd  -0x20(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<potm_minute>:
push   %rbx
sub    $0x20,%rsp
mov    %edi,%ebx
addsd  0xed1(%rip),%xmm0
movsd  0xed1(%rip),%xmm2
jmp    115b <potm_minute+0x3b>
nopl   0x0(%rax)
movsd  (%rsp),%xmm0
addsd  %xmm1,%xmm0
mulsd  0xeaf(%rip),%xmm2
ucomisd 0xec7(%rip),%xmm2
jbe    11be <potm_minute+0x9e>
movsd  %xmm2,0x18(%rsp)
movapd %xmm0,%xmm1
addsd  0xea3(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
call   1030 <potm@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <potm@plt>
movsd  0x18(%rsp),%xmm2
xor    %eax,%eax
ucomisd 0x10(%rsp),%xmm0
setbe  %al
add    %eax,%eax
add    $0xffffffff,%eax
movapd %xmm2,%xmm1
divsd  0xe68(%rip),%xmm1
cmp    %ebx,%eax
jne    1140 <potm_minute+0x20>
xorpd  0xe74(%rip),%xmm1
jmp    1140 <potm_minute+0x20>
movsd  %xmm0,(%rsp)
call   1040 <floor@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
movsd  (%rsp),%xmm0
subsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @potm_minute(double %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i32
store double %0, double* %3
store i32 %1, i32* %4
store double 4.320000e+04, double* %5
%11 = load double, double* %3
%12 = load double, double* %5
%13 = fdiv double %12, 8.640000e+04
%14 = fadd double %11, %13
store double %14, double* %6
%15 = load double, double* %5
%16 = fdiv double %15, 2.000000e+00
store double %16, double* %5
br label %17
17: ; preds = %45, %2
%18 = load double, double* %5
%19 = fcmp ogt double %18, 3.000000e+01
br i1 %19, label %20, label %48
20: ; preds = %17
%21 = load double, double* %6
%22 = fadd double %21, 0x3EF845C8A0CE5129
store double %22, double* %7
%23 = load double, double* %6
%24 = call double @potm(double %23)
store double %24, double* %8
%25 = load double, double* %7
%26 = call double @potm(double %25)
store double %26, double* %9
%27 = load double, double* %8
%28 = load double, double* %9
%29 = fcmp olt double %27, %28
%30 = zext i1 %29 to i64
%31 = select i1 %29, i32 -1, i32 1
store i32 %31, i32* %10
%32 = load i32, i32* %4
%33 = load i32, i32* %10
%34 = icmp ne i32 %32, %33
br i1 %34, label %35, label %40
35: ; preds = %20
%36 = load double, double* %5
%37 = fdiv double %36, 8.640000e+04
%38 = load double, double* %6
%39 = fadd double %38, %37
store double %39, double* %6
br label %45
40: ; preds = %20
%41 = load double, double* %5
%42 = fdiv double %41, 8.640000e+04
%43 = load double, double* %6
%44 = fsub double %43, %42
store double %44, double* %6
br label %45
45: ; preds = %40, %35
%46 = load double, double* %5
%47 = fdiv double %46, 2.000000e+00
store double %47, double* %5
br label %17
48: ; preds = %17
%49 = load double, double* %6
%50 = call i64 @floor(double %49)
%51 = sitofp i64 %50 to double
%52 = load double, double* %6
%53 = fsub double %52, %51
store double %53, double* %6
%54 = load double, double* %6
ret double %54
}

LLVM IR (-O2):
define double @potm_minute(double %0, i32 %1) {
%3 = fadd double %0, 5.000000e-01
br label %4
4: ; preds = %2, %4
%5 = phi double [ 2.160000e+04, %2 ], [ %17, %4 ]
%6 = phi double [ %3, %2 ], [ %16, %4 ]
%7 = fadd double %6, 0x3EF845C8A0CE5129
%8 = tail call double @potm(double %6)
%9 = tail call double @potm(double %7)
%10 = fcmp olt double %8, %9
%11 = select i1 %10, i32 -1, i32 1
%12 = icmp eq i32 %11, %1
%13 = fdiv double %5, 8.640000e+04
%14 = fneg double %13
%15 = select i1 %12, double %14, double %13
%16 = fadd double %6, %15
%17 = fmul double %5, 5.000000e-01
%18 = fcmp ogt double %17, 3.000000e+01
br i1 %18, label %4, label %19
19: ; preds = %4
%20 = tail call i64 @floor(double %16)
%21 = sitofp i64 %20 to double
%22 = fsub double %16, %21
ret double %22
}