double cal2ut1(int mode, int cal[3], double daysec) {
  double days = 0.;
  double deltaU = -0.0811;
  double sec;
  double ut1sec;
  int monthDays[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
  int monthDayLeap[] = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};
  int day;
  int doy;
  int month;
  int year;
  int years[] = {-7305, -6939, -6574, -6209, -5844, -5478, -5113, -4748, -4383,
                 -4017, -3652, -3287, -2922, -2556, -2191, -1826, -1461, -1095,
                 -730,  -365,  0,     366,   731,   1096,  1461,  1827,  2192,
                 2557,  2922,  3288,  3653,  4018,  4383,  4749,  5114,  5479,
                 5844,  6210,  6575,  6940,  7305,  7671,  8036,  8401,  8766,
                 9132,  9497,  9862,  10227, 10593, 10958, 11323, 11688, 12054,
                 12419, 12784, 13149, 13515, 13880, 14245, 14610, 14976, 15341,
                 15706, 16071, 16437, 16802, 17167, 17532, 17898, 18263, 18628,
                 18993, 19359, 19724, 20089, 20454, 20820, 21185, 21550, 21915};
  int leaps[] = {1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1,
                 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0,
                 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0,
                 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1};
  if (mode == 1) {
    year = cal[0];
    month = cal[1];
    day = cal[2];
    days = years[year - 1980] - 0.5;
    if (leaps[year - 1980] == 1) {
      days = days + monthDayLeap[month - 1];
    } else {
      days = days + monthDays[month - 1];
    }
    days = days + day - 1;
  } else if (mode == 2) {
    year = cal[0];
    doy = cal[1];
    days = years[year - 1980] - 0.5;
    days = days + doy - 1;
  }
  sec = days * 86400.0 + daysec;
  ut1sec = sec + deltaU;
  return ut1sec;
}


x86 assembly (clang, -O0):
<cal2ut1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x350,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xec9(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xed9(%rip),%rsi
mov    $0x30,%edx
call   1030 <memcpy@plt>
lea    -0xa0(%rbp),%rdi
lea    0xef1(%rip),%rsi
mov    $0x30,%edx
call   1030 <memcpy@plt>
lea    -0x200(%rbp),%rdi
lea    0xf09(%rip),%rsi
mov    $0x144,%edx
call   1030 <memcpy@plt>
lea    -0x350(%rbp),%rdi
lea    0x1041(%rip),%rsi
mov    $0x144,%edx
call   1030 <memcpy@plt>
cmpl   $0x1,-0x4(%rbp)
jne    1278 <cal2ut1+0x168>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xb0(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0xac(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0xa4(%rbp)
mov    -0xb0(%rbp),%eax
sub    $0x7bc,%eax
cltq
cvtsi2sdl -0x200(%rbp,%rax,4),%xmm0
ff ff
movsd  0xe29(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0xb0(%rbp),%eax
sub    $0x7bc,%eax
cltq
cmpl   $0x1,-0x350(%rbp,%rax,4)
01
jne    1232 <cal2ut1+0x122>
movsd  -0x20(%rbp),%xmm0
mov    -0xac(%rbp),%eax
sub    $0x1,%eax
cltq
cvtsi2sdl -0xa0(%rbp,%rax,4),%xmm1
ff ff
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1251 <cal2ut1+0x141>
movsd  -0x20(%rbp),%xmm0
mov    -0xac(%rbp),%eax
sub    $0x1,%eax
cltq
cvtsi2sdl -0x70(%rbp,%rax,4),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0xa4(%rbp),%xmm1
ff
addsd  %xmm1,%xmm0
movsd  0xd9e(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    12e9 <cal2ut1+0x1d9>
cmpl   $0x2,-0x4(%rbp)
jne    12e4 <cal2ut1+0x1d4>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xb0(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0xa8(%rbp)
mov    -0xb0(%rbp),%eax
sub    $0x7bc,%eax
cltq
cvtsi2sdl -0x200(%rbp,%rax,4),%xmm0
ff ff
movsd  0xd57(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0xa8(%rbp),%xmm1
ff
addsd  %xmm1,%xmm0
movsd  0xd2d(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    12e9 <cal2ut1+0x1d9>
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xd1d(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
add    $0x350,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cal2ut1>:
cmp    $0x2,%edi
je     115e <cal2ut1+0x5e>
xorpd  %xmm1,%xmm1
cmp    $0x1,%edi
jne    1194 <cal2ut1+0x94>
movslq (%rsi),%rax
movslq 0x4(%rsi),%rcx
lea    0xf60(%rip),%rdx
cvtsi2sdl -0x1ef0(%rdx,%rax,4),%xmm2
ff ff
add    $0x8,%rsi
addsd  0xecb(%rip),%xmm2
lea    0x1094(%rip),%rdx
cmpl   $0x1,-0x1ef0(%rdx,%rax,4)
01
lea    0xf05(%rip),%rax
lea    0xece(%rip),%rdx
cmove  %rax,%rdx
cvtsi2sdl -0x4(%rdx,%rcx,4),%xmm3
jmp    117d <cal2ut1+0x7d>
movslq (%rsi),%rax
add    $0x4,%rsi
lea    0xf14(%rip),%rcx
cvtsi2sdl -0x1ef0(%rcx,%rax,4),%xmm2
ff ff
movsd  0xe83(%rip),%xmm3
xorps  %xmm1,%xmm1
cvtsi2sdl (%rsi),%xmm1
addsd  %xmm2,%xmm3
addsd  %xmm3,%xmm1
addsd  0xe74(%rip),%xmm1
mulsd  0xe74(%rip),%xmm1
addsd  %xmm0,%xmm1
addsd  0xe70(%rip),%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
@__const.cal2ut1.monthDays = [12 x i32] [i32 0, i32 31, i32 59, i32 90, i32 120, i32 151, i32 181, i32 212, i32 243, i32 273, i32 304, i32 334]
@__const.cal2ut1.monthDayLeap = [12 x i32] [i32 0, i32 31, i32 60, i32 91, i32 121, i32 152, i32 182, i32 213, i32 244, i32 274, i32 305, i32 335]
@__const.cal2ut1.years = [81 x i32] [i32 -7305, i32 -6939, i32 -6574, i32 -6209, i32 -5844, i32 -5478, i32 -5113, i32 -4748, i32 -4383, i32 -4017, i32 -3652, i32 -3287, i32 -2922, i32 -2556, i32 -2191, i32 -1826, i32 -1461, i32 -1095, i32 -730, i32 -365, i32 0, i32 366, i32 731, i32 1096, i32 1461, i32 1827, i32 2192, i32 2557, i32 2922, i32 3288, i32 3653, i32 4018, i32 4383, i32 4749, i32 5114, i32 5479, i32 5844, i32 6210, i32 6575, i32 6940, i32 7305, i32 7671, i32 8036, i32 8401, i32 8766, i32 9132, i32 9497, i32 9862, i32 10227, i32 10593, i32 10958, i32 11323, i32 11688, i32 12054, i32 12419, i32 12784, i32 13149, i32 13515, i32 13880, i32 14245, i32 14610, i32 14976, i32 15341, i32 15706, i32 16071, i32 16437, i32 16802, i32 17167, i32 17532, i32 17898, i32 18263, i32 18628, i32 18993, i32 19359, i32 19724, i32 20089, i32 20454, i32 20820, i32 21185, i32 21550, i32 21915]
@__const.cal2ut1.leaps = [81 x i32] [i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1]
define double @cal2ut1(i32 %0, i32* %1, double %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca [12 x i32]
%12 = alloca [12 x i32]
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca [81 x i32]
%18 = alloca [81 x i32]
store i32 %0, i32* %4
store i32* %1, i32** %5
store double %2, double* %6
store double 0.000000e+00, double* %7
store double -8.110000e-02, double* %8
%19 = bitcast [12 x i32]* %11 to i8*
%20 = bitcast [12 x i32]* %12 to i8*
%21 = bitcast [81 x i32]* %17 to i8*
%22 = bitcast [81 x i32]* %18 to i8*
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %72
25: ; preds = %3
%26 = load i32*, i32** %5
%27 = getelementptr inbounds i32, i32* %26, i64 0
%28 = load i32, i32* %27
store i32 %28, i32* %16
%29 = load i32*, i32** %5
%30 = getelementptr inbounds i32, i32* %29, i64 1
%31 = load i32, i32* %30
store i32 %31, i32* %15
%32 = load i32*, i32** %5
%33 = getelementptr inbounds i32, i32* %32, i64 2
%34 = load i32, i32* %33
store i32 %34, i32* %13
%35 = load i32, i32* %16
%36 = sub nsw i32 %35, 1980
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [81 x i32], [81 x i32]* %17, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = sitofp i32 %39 to double
%41 = fsub double %40, 5.000000e-01
store double %41, double* %7
%42 = load i32, i32* %16
%43 = sub nsw i32 %42, 1980
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [81 x i32], [81 x i32]* %18, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = icmp eq i32 %46, 1
br i1 %47, label %48, label %57
48: ; preds = %25
%49 = load double, double* %7
%50 = load i32, i32* %15
%51 = sub nsw i32 %50, 1
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [12 x i32], [12 x i32]* %12, i64 0, i64 %52
%54 = load i32, i32* %53
%55 = sitofp i32 %54 to double
%56 = fadd double %49, %55
store double %56, double* %7
br label %66
57: ; preds = %25
%58 = load double, double* %7
%59 = load i32, i32* %15
%60 = sub nsw i32 %59, 1
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [12 x i32], [12 x i32]* %11, i64 0, i64 %61
%63 = load i32, i32* %62
%64 = sitofp i32 %63 to double
%65 = fadd double %58, %64
store double %65, double* %7
br label %66
66: ; preds = %57, %48
%67 = load double, double* %7
%68 = load i32, i32* %13
%69 = sitofp i32 %68 to double
%70 = fadd double %67, %69
%71 = fsub double %70, 1.000000e+00
store double %71, double* %7
br label %95
72: ; preds = %3
%73 = load i32, i32* %4
%74 = icmp eq i32 %73, 2
br i1 %74, label %75, label %94
75: ; preds = %72
%76 = load i32*, i32** %5
%77 = getelementptr inbounds i32, i32* %76, i64 0
%78 = load i32, i32* %77
store i32 %78, i32* %16
%79 = load i32*, i32** %5
%80 = getelementptr inbounds i32, i32* %79, i64 1
%81 = load i32, i32* %80
store i32 %81, i32* %14
%82 = load i32, i32* %16
%83 = sub nsw i32 %82, 1980
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [81 x i32], [81 x i32]* %17, i64 0, i64 %84
%86 = load i32, i32* %85
%87 = sitofp i32 %86 to double
%88 = fsub double %87, 5.000000e-01
store double %88, double* %7
%89 = load double, double* %7
%90 = load i32, i32* %14
%91 = sitofp i32 %90 to double
%92 = fadd double %89, %91
%93 = fsub double %92, 1.000000e+00
store double %93, double* %7
br label %94
94: ; preds = %75, %72
br label %95
95: ; preds = %94, %66
%96 = load double, double* %7
%97 = load double, double* %6
%98 = call double @llvm.fmuladd.f64(double %96, double 8.640000e+04, double %97)
store double %98, double* %9
%99 = load double, double* %9
%100 = load double, double* %8
%101 = fadd double %99, %100
store double %101, double* %10
%102 = load double, double* %10
ret double %102
}

LLVM IR (-O2):
@__const.cal2ut1.monthDays = [12 x i32] [i32 0, i32 31, i32 59, i32 90, i32 120, i32 151, i32 181, i32 212, i32 243, i32 273, i32 304, i32 334]
@__const.cal2ut1.monthDayLeap = [12 x i32] [i32 0, i32 31, i32 60, i32 91, i32 121, i32 152, i32 182, i32 213, i32 244, i32 274, i32 305, i32 335]
@__const.cal2ut1.years = [81 x i32] [i32 -7305, i32 -6939, i32 -6574, i32 -6209, i32 -5844, i32 -5478, i32 -5113, i32 -4748, i32 -4383, i32 -4017, i32 -3652, i32 -3287, i32 -2922, i32 -2556, i32 -2191, i32 -1826, i32 -1461, i32 -1095, i32 -730, i32 -365, i32 0, i32 366, i32 731, i32 1096, i32 1461, i32 1827, i32 2192, i32 2557, i32 2922, i32 3288, i32 3653, i32 4018, i32 4383, i32 4749, i32 5114, i32 5479, i32 5844, i32 6210, i32 6575, i32 6940, i32 7305, i32 7671, i32 8036, i32 8401, i32 8766, i32 9132, i32 9497, i32 9862, i32 10227, i32 10593, i32 10958, i32 11323, i32 11688, i32 12054, i32 12419, i32 12784, i32 13149, i32 13515, i32 13880, i32 14245, i32 14610, i32 14976, i32 15341, i32 15706, i32 16071, i32 16437, i32 16802, i32 17167, i32 17532, i32 17898, i32 18263, i32 18628, i32 18993, i32 19359, i32 19724, i32 20089, i32 20454, i32 20820, i32 21185, i32 21550, i32 21915]
@__const.cal2ut1.leaps = [81 x i32] [i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1]
define double @cal2ut1(i32 %0, i32* nocapture %1, double %2) {
switch i32 %0, label %41 [
i32 1, label %4
i32 2, label %24
]
4: ; preds = %3
%5 = load i32, i32* %1
%6 = getelementptr inbounds i32, i32* %1, i64 1
%7 = load i32, i32* %6
%8 = getelementptr inbounds i32, i32* %1, i64 2
%9 = add nsw i32 %5, -1980
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [81 x i32], [81 x i32]* @__const.cal2ut1.years, i64 0, i64 %10
%12 = load i32, i32* %11
%13 = sitofp i32 %12 to double
%14 = fadd double %13, -5.000000e-01
%15 = getelementptr inbounds [81 x i32], [81 x i32]* @__const.cal2ut1.leaps, i64 0, i64 %10
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, 1
%18 = add nsw i32 %7, -1
%19 = sext i32 %18 to i64
%20 = select i1 %17, [12 x i32]* @__const.cal2ut1.monthDayLeap, [12 x i32]* @__const.cal2ut1.monthDays
%21 = getelementptr inbounds [12 x i32], [12 x i32]* %20, i64 0, i64 %19
%22 = load i32, i32* %21
%23 = sitofp i32 %22 to double
br label %32
24: ; preds = %3
%25 = load i32, i32* %1
%26 = getelementptr inbounds i32, i32* %1, i64 1
%27 = add nsw i32 %25, -1980
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [81 x i32], [81 x i32]* @__const.cal2ut1.years, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = sitofp i32 %30 to double
br label %32
32: ; preds = %4, %24
%33 = phi double [ -5.000000e-01, %24 ], [ %23, %4 ]
%34 = phi double [ %31, %24 ], [ %14, %4 ]
%35 = phi i32* [ %26, %24 ], [ %8, %4 ]
%36 = load i32, i32* %35
%37 = fadd double %34, %33
%38 = sitofp i32 %36 to double
%39 = fadd double %37, %38
%40 = fadd double %39, -1.000000e+00
br label %41
41: ; preds = %32, %3
%42 = phi double [ 0.000000e+00, %3 ], [ %40, %32 ]
%43 = tail call double @llvm.fmuladd.f64(double %42, double 8.640000e+04, double %2)
%44 = fadd double %43, -8.110000e-02
ret double %44
}