#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*/ get_current_time(void *, double *);
int /*<<< orphan*/ get_time_step(void *, double *);
int /*<<< orphan*/ update(void *);
int /*<<< orphan*/ update_frac(void *, double const);
int update_until(void *self, double t) {
  {
    double dt;
    double now;
    get_time_step(self, &dt);
    get_current_time(self, &now);
    {
      int n;
      const double n_steps = (t - now) / dt;
      const int n_full_steps = (int)n_steps;
      for (n = 0; n < n_full_steps; n++) {
        update(self);
      }
      update_frac(self, n_steps - n_full_steps);
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<update_until>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <get_time_step@plt>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <get_current_time@plt>
movsd  -0x10(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
cvttsd2si -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    11b1 <update_until+0x71>
mov    -0x8(%rbp),%rdi
call   1030 <update@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    118e <update_until+0x4e>
mov    -0x8(%rbp),%rdi
movsd  -0x30(%rbp),%xmm0
cvtsi2sdl -0x34(%rbp),%xmm1
subsd  %xmm1,%xmm0
call   1040 <update_frac@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_until>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
movsd  %xmm0,0x8(%rsp)
mov    %rdi,%rbx
lea    0x18(%rsp),%rsi
call   1050 <get_time_step@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <get_current_time@plt>
movsd  0x8(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
divsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
cvttsd2si %xmm0,%r14d
test   %r14d,%r14d
jle    119d <update_until+0x5d>
mov    %r14d,%ebp
nopl   (%rax)
mov    %rbx,%rdi
call   1030 <update@plt>
add    $0xffffffff,%ebp
jne    1190 <update_until+0x50>
cvtsi2sd %r14d,%xmm1
movsd  0x8(%rsp),%xmm0
subsd  %xmm1,%xmm0
mov    %rbx,%rdi
call   1040 <update_frac@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @update_until(i8* %0, double %1) {
%3 = alloca i8*
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca double
%9 = alloca i32
store i8* %0, i8** %3
store double %1, double* %4
%10 = load i8*, i8** %3
%11 = call i32 @get_time_step(i8* %10, double* %5)
%12 = load i8*, i8** %3
%13 = call i32 @get_current_time(i8* %12, double* %6)
%14 = load double, double* %4
%15 = load double, double* %6
%16 = fsub double %14, %15
%17 = load double, double* %5
%18 = fdiv double %16, %17
store double %18, double* %8
%19 = load double, double* %8
%20 = fptosi double %19 to i32
store i32 %20, i32* %9
store i32 0, i32* %7
br label %21
21: ; preds = %28, %2
%22 = load i32, i32* %7
%23 = load i32, i32* %9
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %31
25: ; preds = %21
%26 = load i8*, i8** %3
%27 = call i32 @update(i8* %26)
br label %28
28: ; preds = %25
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
br label %21
31: ; preds = %21
%32 = load i8*, i8** %3
%33 = load double, double* %8
%34 = load i32, i32* %9
%35 = sitofp i32 %34 to double
%36 = fsub double %33, %35
%37 = call i32 @update_frac(i8* %32, double %36)
ret i32 0
}

LLVM IR (-O2):
define i32 @update_until(i8* %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = bitcast double* %3 to i8*
%6 = bitcast double* %4 to i8*
%7 = call i32 @get_time_step(i8* %0, double* %3)
%8 = call i32 @get_current_time(i8* %0, double* %4)
%9 = load double, double* %4
%10 = fsub double %1, %9
%11 = load double, double* %3
%12 = fdiv double %10, %11
%13 = fptosi double %12 to i32
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %2, %15
%16 = phi i32 [ %18, %15 ], [ 0, %2 ]
%17 = call i32 @update(i8* %0)
%18 = add nuw nsw i32 %16, 1
%19 = icmp eq i32 %18, %13
br i1 %19, label %20, label %15
20: ; preds = %15, %2
%21 = sitofp i32 %13 to double
%22 = fsub double %12, %21
%23 = call i32 @update_frac(i8* %0, double %22)
ret i32 0
}