#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 */
typedef int /*<<< orphan*/ line;

/* Variables and functions */
int contemplate_data(int, double, double, int);
int /*<<< orphan*/ exit(int);
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, double, int, ...);
int sscanf(char *, char *, int *, float *, float *, float *, double *, float *,
           int *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
void do_replay(void) {
  char line[100];
  int n, day, freq, absolute;
  float sec, el_time, st_time, disp;
  double skew, errorbar;
  int simulated_freq = 0;
  unsigned int last_fake_time = 0;
  double fake_delta_time = 0.0;
  while (fgets(line, sizeof(line), stdin)) {
    n = sscanf(line, "%d %f %f %f %lf %f %d", &day, &sec, &el_time, &st_time,
               &skew, &disp, &freq);
    if (n == 7) {
      fputs(line, stdout);
      absolute = day * 86400 + (int)sec;
      errorbar = el_time + disp;
      if (0)
        printf("contemplate %u %.1f %.1f %d\n", absolute, skew, errorbar, freq);
      if (last_fake_time == 0)
        simulated_freq = freq;
      fake_delta_time += (absolute - last_fake_time) *
                         ((double)(freq - simulated_freq)) / 65536;
      if (0)
        printf("fake %f %d \n", fake_delta_time, simulated_freq);
      skew += fake_delta_time;
      freq = simulated_freq;
      last_fake_time = absolute;
      simulated_freq = contemplate_data(absolute, skew, errorbar, freq);
    } else {
      fprintf(stderr, "Replay input error\n");
      exit(2);
    }
  }
}


x86 assembly (clang, -O0):
<do_replay>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0xa4(%rbp)
movl   $0x0,-0xa8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
lea    -0x70(%rbp),%rdi
mov    0x2e53(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     130a <do_replay+0x1aa>
lea    -0x70(%rbp),%rdi
lea    0xe52(%rip),%rsi
lea    -0x78(%rbp),%rdx
lea    -0x84(%rbp),%rcx
lea    -0x88(%rbp),%r8
lea    -0x8c(%rbp),%r9
lea    -0x98(%rbp),%r11
lea    -0x90(%rbp),%r10
lea    -0x7c(%rbp),%rax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1060 <sscanf@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0x7,-0x74(%rbp)
jne    12e6 <do_replay+0x186>
lea    -0x70(%rbp),%rdi
mov    0x2dc4(%rip),%rax
mov    (%rax),%esi
call   1030 <fputs@plt>
imul   $0x15180,-0x78(%rbp),%eax
cvttss2si -0x84(%rbp),%ecx
ff
add    %ecx,%eax
mov    %eax,-0x80(%rbp)
movss  -0x88(%rbp),%xmm0
ff
addss  -0x90(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
cmpl   $0x0,-0xa8(%rbp)
jne    1259 <do_replay+0xf9>
mov    -0x7c(%rbp),%eax
mov    %eax,-0xa4(%rbp)
mov    -0x80(%rbp),%eax
mov    -0xa8(%rbp),%ecx
sub    %ecx,%eax
cvtsi2sd %rax,%xmm0
mov    -0x7c(%rbp),%eax
sub    -0xa4(%rbp),%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd7e(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  -0xb0(%rbp),%xmm0
ff
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0xb0(%rbp),%xmm0
ff
addsd  -0x98(%rbp),%xmm0
ff
movsd  %xmm0,-0x98(%rbp)
ff
mov    -0xa4(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x80(%rbp),%eax
mov    %eax,-0xa8(%rbp)
mov    -0x80(%rbp),%edi
movsd  -0x98(%rbp),%xmm0
ff
movsd  -0xa0(%rbp),%xmm1
ff
mov    -0x7c(%rbp),%esi
call   1070 <contemplate_data@plt>
mov    %eax,-0xa4(%rbp)
jmp    1305 <do_replay+0x1a5>
mov    0x2ceb(%rip),%rax
mov    (%rax),%edi
lea    0xd28(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x2,%edi
call   1080 <exit@plt>
jmp    118a <do_replay+0x2a>
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_replay>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    0x2e70(%rip),%rax
mov    (%rax),%edx
lea    0x30(%rsp),%rdi
mov    $0x64,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     12b9 <do_replay+0x159>
xor    %r13d,%r13d
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x18(%rsp)
lea    0x30(%rsp),%rbx
lea    0x2c(%rsp),%rbp
mov    0x2e20(%rip),%r12
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
sub    $0x8,%rsp
mov    %rbx,%rdi
lea    0xe3a(%rip),%rsi
lea    0x1c(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0x14(%rsp),%r8
mov    %rbp,%r9
lea    0xc(%rsp),%rax
push   %rax
lea    0x18(%rsp),%rax
push   %rax
lea    0x38(%rsp),%rax
push   %rax
call   1060 <sscanf@plt>
add    $0x20,%rsp
cmp    $0x7,%eax
jne    12cb <do_replay+0x16b>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1030 <fputs@plt>
imul   $0x15180,0x14(%rsp),%eax
cvttss2si 0x10(%rsp),%r15d
add    %eax,%r15d
movss  0xc(%rsp),%xmm0
addss  0x8(%rsp),%xmm0
test   %r13d,%r13d
mov    0x4(%rsp),%eax
cmove  %eax,%r14d
mov    %r15d,%ecx
sub    %r13d,%ecx
xorps  %xmm2,%xmm2
cvtsi2sd %rcx,%xmm2
sub    %r14d,%eax
xorps  %xmm3,%xmm3
cvtsi2sd %eax,%xmm3
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
mulsd  %xmm2,%xmm3
mulsd  0xd9c(%rip),%xmm3
movsd  0x18(%rsp),%xmm2
addsd  %xmm3,%xmm2
movsd  0x20(%rsp),%xmm0
movsd  %xmm2,0x18(%rsp)
addsd  %xmm2,%xmm0
movsd  %xmm0,0x20(%rsp)
mov    %r14d,0x4(%rsp)
mov    %r15d,%edi
mov    %r14d,%esi
call   1070 <contemplate_data@plt>
mov    %eax,%r14d
mov    0x2d4a(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1040 <fgets@plt>
mov    %r15d,%r13d
test   %rax,%rax
jne    11c0 <do_replay+0x60>
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d06(%rip),%rax
mov    (%rax),%edi
lea    0xd43(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x2,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stdin = global i32 0
@.str = [22 x i8] c"%d %f %f %f %lf %f %d\00"
@stdout = global i32 0
@stderr = global i32 0
@.str.1 = [20 x i8] c"Replay input error\0A\00"
define void @do_replay() {
%1 = alloca [100 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca double
%11 = alloca double
%12 = alloca i32
%13 = alloca i32
%14 = alloca double
store i32 0, i32* %12
store i32 0, i32* %13
store double 0.000000e+00, double* %14
br label %15
15: ; preds = %69, %0
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%17 = load i32, i32* @stdin
%18 = call i64 @fgets(i8* %16, i32 100, i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %70
20: ; preds = %15
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%22 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32* %3, float* %6, float* %7, float* %8, double* %10, float* %9, i32* %4)
store i32 %22, i32* %2
%23 = load i32, i32* %2
%24 = icmp eq i32 %23, 7
br i1 %24, label %25, label %65
25: ; preds = %20
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%27 = load i32, i32* @stdout
%28 = call i32 @fputs(i8* %26, i32 %27)
%29 = load i32, i32* %3
%30 = mul nsw i32 %29, 86400
%31 = load float, float* %6
%32 = fptosi float %31 to i32
%33 = add nsw i32 %30, %32
store i32 %33, i32* %5
%34 = load float, float* %7
%35 = load float, float* %9
%36 = fadd float %34, %35
%37 = fpext float %36 to double
store double %37, double* %11
%38 = load i32, i32* %13
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %25
%41 = load i32, i32* %4
store i32 %41, i32* %12
br label %42
42: ; preds = %40, %25
%43 = load i32, i32* %5
%44 = load i32, i32* %13
%45 = sub i32 %43, %44
%46 = uitofp i32 %45 to double
%47 = load i32, i32* %4
%48 = load i32, i32* %12
%49 = sub nsw i32 %47, %48
%50 = sitofp i32 %49 to double
%51 = fmul double %46, %50
%52 = fdiv double %51, 6.553600e+04
%53 = load double, double* %14
%54 = fadd double %53, %52
store double %54, double* %14
%55 = load double, double* %14
%56 = load double, double* %10
%57 = fadd double %56, %55
store double %57, double* %10
%58 = load i32, i32* %12
store i32 %58, i32* %4
%59 = load i32, i32* %5
store i32 %59, i32* %13
%60 = load i32, i32* %5
%61 = load double, double* %10
%62 = load double, double* %11
%63 = load i32, i32* %4
%64 = call i32 @contemplate_data(i32 %60, double %61, double %62, i32 %63)
store i32 %64, i32* %12
br label %69
65: ; preds = %20
%66 = load i32, i32* @stderr
%67 = call i32 @fprintf(i32 %66, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%68 = call i32 @exit(i32 2)
unreachable
69: ; preds = %42
br label %15
70: ; preds = %15
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [22 x i8] c"%d %f %f %f %lf %f %d\00"
@stdout = global i32 0
@stderr = global i32 0
@.str.1 = [20 x i8] c"Replay input error\0A\00"
define void @do_replay() {
%1 = alloca [100 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca double
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%10 = bitcast i32* %2 to i8*
%11 = bitcast i32* %3 to i8*
%12 = bitcast float* %4 to i8*
%13 = bitcast float* %5 to i8*
%14 = bitcast float* %6 to i8*
%15 = bitcast float* %7 to i8*
%16 = bitcast double* %8 to i8*
%17 = load i32, i32* @stdin
%18 = call i64 @fgets(i8* %9, i32 100, i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %58, label %20
20: ; preds = %0, %26
%21 = phi double [ %47, %26 ], [ 0.000000e+00, %0 ]
%22 = phi i32 [ %33, %26 ], [ 0, %0 ]
%23 = phi i32 [ %50, %26 ], [ 0, %0 ]
%24 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32* %2, float* %4, float* %5, float* %6, double* %8, float* %7, i32* %3)
%25 = icmp eq i32 %24, 7
br i1 %25, label %26, label %54
26: ; preds = %20
%27 = load i32, i32* @stdout
%28 = call i32 @fputs(i8* %9, i32 %27)
%29 = load i32, i32* %2
%30 = mul nsw i32 %29, 86400
%31 = load float, float* %4
%32 = fptosi float %31 to i32
%33 = add nsw i32 %30, %32
%34 = load float, float* %5
%35 = load float, float* %7
%36 = fadd float %34, %35
%37 = fpext float %36 to double
%38 = icmp eq i32 %22, 0
%39 = load i32, i32* %3
%40 = select i1 %38, i32 %39, i32 %23
%41 = sub i32 %33, %22
%42 = uitofp i32 %41 to double
%43 = sub nsw i32 %39, %40
%44 = sitofp i32 %43 to double
%45 = fmul double %42, %44
%46 = fmul double %45, 0x3EF0000000000000
%47 = fadd double %21, %46
%48 = load double, double* %8
%49 = fadd double %48, %47
store double %49, double* %8
store i32 %40, i32* %3
%50 = call i32 @contemplate_data(i32 %33, double %49, double %37, i32 %40)
%51 = load i32, i32* @stdin
%52 = call i64 @fgets(i8* %9, i32 100, i32 %51)
%53 = icmp eq i64 %52, 0
br i1 %53, label %58, label %20
54: ; preds = %20
%55 = load i32, i32* @stderr
%56 = call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%57 = call i32 @exit(i32 2)
unreachable
58: ; preds = %26, %0
ret void
}