#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;
    for (n = 0; n < (int)n_steps; n++) {
      Update(self);
    }
    Update_frac(self, n_steps - (int)n_steps);
  }
  return (0);
}


x86 assembly (clang, -O0):
<Update_until>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cvttsd2si -0x30(%rbp),%ecx
cmp    %ecx,%eax
jge    11ad <Update_until+0x6d>
mov    -0x8(%rbp),%rdi
call   1030 <Update@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1186 <Update_until+0x46>
mov    -0x8(%rbp),%rdi
movsd  -0x30(%rbp),%xmm0
cvttsd2si -0x30(%rbp),%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
call   1040 <Update_frac@plt>
xor    %eax,%eax
add    $0x30,%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
store i8* %0, i8** %3
store double %1, double* %4
%9 = load i8*, i8** %3
%10 = call i32 @Get_time_step(i8* %9, double* %5)
%11 = load i8*, i8** %3
%12 = call i32 @Get_current_time(i8* %11, double* %6)
%13 = load double, double* %4
%14 = load double, double* %6
%15 = fsub double %13, %14
%16 = load double, double* %5
%17 = fdiv double %15, %16
store double %17, double* %8
store i32 0, i32* %7
br label %18
18: ; preds = %26, %2
%19 = load i32, i32* %7
%20 = load double, double* %8
%21 = fptosi double %20 to i32
%22 = icmp slt i32 %19, %21
br i1 %22, label %23, label %29
23: ; preds = %18
%24 = load i8*, i8** %3
%25 = call i32 @Update(i8* %24)
br label %26
26: ; preds = %23
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %18
29: ; preds = %18
%30 = load i8*, i8** %3
%31 = load double, double* %8
%32 = load double, double* %8
%33 = fptosi double %32 to i32
%34 = sitofp i32 %33 to double
%35 = fsub double %31, %34
%36 = call i32 @Update_frac(i8* %30, double %35)
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
}