#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 */
double floor(double);
double trans(double *v, int luord, double vv) {
  double g;
  int ord;
  for (ord = 0; ord < luord; ord++) {
    int nsec;
    double sec;
    g = v[ord];
    nsec = ord + 1;
    vv *= (double)nsec;
    sec = floor(vv);
    if (((int)sec) & 1)
      g = -g;
    vv -= sec;
    if (g >= 0.0) {
      vv = vv / (g - g * vv + 1.0);
    } else {
      vv = (vv - g * vv) / (1.0 - g * vv);
    }
    vv += sec;
    vv /= (double)nsec;
  }
  return vv;
}


x86 assembly (clang, -O0):
<trans>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12ac <trans+0x19c>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
cvtsi2sdl -0x28(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <floor@plt>
movsd  %xmm0,-0x30(%rbp)
cvttsd2si -0x30(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11a2 <trans+0x92>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1214 <trans+0x104>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm3
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  0xdfe(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    127c <trans+0x16c>
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
movsd  0xd91(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
cvtsi2sdl -0x28(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    112b <trans+0x1b>
movsd  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trans>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movapd %xmm0,%xmm1
test   %esi,%esi
jle    11d3 <trans+0xc3>
mov    %rdi,%r14
mov    %esi,%r15d
xor    %ebx,%ebx
jmp    1156 <trans+0x46>
nop
addsd  %xmm1,%xmm2
addsd  0xed4(%rip),%xmm1
divsd  %xmm1,%xmm2
addsd  %xmm2,%xmm0
divsd  (%rsp),%xmm0
movapd %xmm0,%xmm1
cmp    %rbx,%r15
je     11d7 <trans+0xc7>
movsd  (%r14,%rbx,8),%xmm0
movaps %xmm0,0x10(%rsp)
add    $0x1,%rbx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  %xmm0,(%rsp)
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
call   1030 <floor@plt>
cvttsd2si %xmm0,%eax
movapd 0xe70(%rip),%xmm3
test   $0x1,%al
je     11a0 <trans+0x90>
movapd 0x10(%rsp),%xmm4
xorpd  %xmm3,%xmm4
jmp    11a6 <trans+0x96>
movapd 0x10(%rsp),%xmm4
movsd  0x8(%rsp),%xmm2
subsd  %xmm0,%xmm2
ucomisd 0xe60(%rip),%xmm4
movapd %xmm4,%xmm1
xorpd  %xmm3,%xmm1
mulsd  %xmm2,%xmm1
jb     1130 <trans+0x20>
addsd  %xmm4,%xmm1
jmp    1134 <trans+0x24>
movapd %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @trans(double* %0, i32 %1, double %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
store double* %0, double** %4
store i32 %1, i32* %5
store double %2, double* %6
store i32 0, i32* %8
br label %11
11: ; preds = %70, %3
%12 = load i32, i32* %8
%13 = load i32, i32* %5
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %73
15: ; preds = %11
%16 = load double*, double** %4
%17 = load i32, i32* %8
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double, double* %16, i64 %18
%20 = load double, double* %19
store double %20, double* %7
%21 = load i32, i32* %8
%22 = add nsw i32 %21, 1
store i32 %22, i32* %9
%23 = load i32, i32* %9
%24 = sitofp i32 %23 to double
%25 = load double, double* %6
%26 = fmul double %25, %24
store double %26, double* %6
%27 = load double, double* %6
%28 = call double @llvm.floor.f64(double %27)
store double %28, double* %10
%29 = load double, double* %10
%30 = fptosi double %29 to i32
%31 = and i32 %30, 1
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %15
%34 = load double, double* %7
%35 = fneg double %34
store double %35, double* %7
br label %36
36: ; preds = %33, %15
%37 = load double, double* %10
%38 = load double, double* %6
%39 = fsub double %38, %37
store double %39, double* %6
%40 = load double, double* %7
%41 = fcmp oge double %40, 0.000000e+00
br i1 %41, label %42, label %51
42: ; preds = %36
%43 = load double, double* %6
%44 = load double, double* %7
%45 = load double, double* %7
%46 = load double, double* %6
%47 = fneg double %45
%48 = call double @llvm.fmuladd.f64(double %47, double %46, double %44)
%49 = fadd double %48, 1.000000e+00
%50 = fdiv double %43, %49
store double %50, double* %6
br label %62
51: ; preds = %36
%52 = load double, double* %6
%53 = load double, double* %7
%54 = load double, double* %6
%55 = fneg double %53
%56 = call double @llvm.fmuladd.f64(double %55, double %54, double %52)
%57 = load double, double* %7
%58 = load double, double* %6
%59 = fneg double %57
%60 = call double @llvm.fmuladd.f64(double %59, double %58, double 1.000000e+00)
%61 = fdiv double %56, %60
store double %61, double* %6
br label %62
62: ; preds = %51, %42
%63 = load double, double* %10
%64 = load double, double* %6
%65 = fadd double %64, %63
store double %65, double* %6
%66 = load i32, i32* %9
%67 = sitofp i32 %66 to double
%68 = load double, double* %6
%69 = fdiv double %68, %67
store double %69, double* %6
br label %70
70: ; preds = %62
%71 = load i32, i32* %8
%72 = add nsw i32 %71, 1
store i32 %72, i32* %8
br label %11
73: ; preds = %11
%74 = load double, double* %6
ret double %74
}

LLVM IR (-O2):
define double @trans(double* nocapture %0, i32 %1, double %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %38
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %5, %33
%8 = phi i64 [ 0, %5 ], [ %12, %33 ]
%9 = phi double [ %2, %5 ], [ %36, %33 ]
%10 = getelementptr inbounds double, double* %0, i64 %8
%11 = load double, double* %10
%12 = add nuw nsw i64 %8, 1
%13 = trunc i64 %12 to i32
%14 = sitofp i32 %13 to double
%15 = fmul double %9, %14
%16 = tail call double @llvm.floor.f64(double %15)
%17 = fptosi double %16 to i32
%18 = and i32 %17, 1
%19 = icmp eq i32 %18, 0
%20 = fneg double %11
%21 = select i1 %19, double %11, double %20
%22 = fsub double %15, %16
%23 = fcmp ult double %21, 0.000000e+00
%24 = fneg double %21
br i1 %23, label %29, label %25
25: ; preds = %7
%26 = tail call double @llvm.fmuladd.f64(double %24, double %22, double %21)
%27 = fadd double %26, 1.000000e+00
%28 = fdiv double %22, %27
br label %33
29: ; preds = %7
%30 = tail call double @llvm.fmuladd.f64(double %24, double %22, double %22)
%31 = tail call double @llvm.fmuladd.f64(double %24, double %22, double 1.000000e+00)
%32 = fdiv double %30, %31
br label %33
33: ; preds = %29, %25
%34 = phi double [ %28, %25 ], [ %32, %29 ]
%35 = fadd double %16, %34
%36 = fdiv double %35, %14
%37 = icmp eq i64 %12, %6
br i1 %37, label %38, label %7
38: ; preds = %33, %3
%39 = phi double [ %2, %3 ], [ %36, %33 ]
ret double %39
}