void set_swift_record(struct module *mod, double st_array[],
                      unsigned long long pre_array[],
                      unsigned long long cur_array[], int inter) {
  if (cur_array[0] > pre_array[0])
    st_array[0] = (cur_array[0] - pre_array[0]) / inter;
  else
    st_array[0] = 0;
  if (cur_array[1] > 0)
    st_array[1] = cur_array[1];
  else
    st_array[1] = 0;
  if (cur_array[2] > pre_array[2])
    st_array[2] = (cur_array[2] - pre_array[2]) / inter;
  else
    st_array[2] = 0;
  if (cur_array[3] > 0)
    st_array[3] = cur_array[3];
  else
    st_array[3] = 0;
  if (cur_array[4] > 0)
    st_array[4] = cur_array[4];
  else
    st_array[4] = 0;
}


x86 assembly (clang, -O0):
<set_swift_record>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%rax
jbe    117a <set_swift_record+0x7a>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%rcx
sub    %rcx,%rax
movslq -0x24(%rbp),%rcx
xor    %edx,%edx
div    %rcx
movq   %rax,%xmm0
movaps 0xeae(%rip),%xmm1
punpckldq %xmm1,%xmm0
movapd 0xeb2(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1185 <set_swift_record+0x85>
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jbe    11cd <set_swift_record+0xcd>
mov    -0x20(%rbp),%rax
movq   0x8(%rax),%xmm0
movaps 0xe5c(%rip),%xmm1
punpckldq %xmm1,%xmm0
movapd 0xe60(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
jmp    11d9 <set_swift_record+0xd9>
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x18(%rbp),%rcx
cmp    0x10(%rcx),%rax
jbe    1240 <set_swift_record+0x140>
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x18(%rbp),%rcx
mov    0x10(%rcx),%rcx
sub    %rcx,%rax
movslq -0x24(%rbp),%rcx
xor    %edx,%edx
div    %rcx
movq   %rax,%xmm0
movaps 0xde9(%rip),%xmm1
punpckldq %xmm1,%xmm0
movapd 0xded(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
jmp    124c <set_swift_record+0x14c>
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x20(%rbp),%rax
cmpq   $0x0,0x18(%rax)
jbe    1294 <set_swift_record+0x194>
mov    -0x20(%rbp),%rax
movq   0x18(%rax),%xmm0
movaps 0xd95(%rip),%xmm1
punpckldq %xmm1,%xmm0
movapd 0xd99(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x18(%rax)
jmp    12a0 <set_swift_record+0x1a0>
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x18(%rax)
mov    -0x20(%rbp),%rax
cmpq   $0x0,0x20(%rax)
jbe    12e8 <set_swift_record+0x1e8>
mov    -0x20(%rbp),%rax
movq   0x20(%rax),%xmm0
movaps 0xd41(%rip),%xmm1
punpckldq %xmm1,%xmm0
movapd 0xd45(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x20(%rax)
jmp    12f4 <set_swift_record+0x1f4>
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x20(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_swift_record>:
mov    %rdx,%rdi
mov    (%rcx),%rax
xorpd  %xmm0,%xmm0
movslq %r8d,%r9
xorpd  %xmm1,%xmm1
sub    (%rdx),%rax
jbe    114f <set_swift_record+0x4f>
mov    %rax,%rdx
or     %r9,%rdx
shr    $0x20,%rdx
je     1129 <set_swift_record+0x29>
xor    %edx,%edx
div    %r9
jmp    112e <set_swift_record+0x2e>
xor    %edx,%edx
div    %r8d
movq   %rax,%xmm2
punpckldq 0xec5(%rip),%xmm2
subpd  0xecd(%rip),%xmm2
movapd %xmm2,%xmm1
unpckhpd %xmm2,%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,(%rsi)
movsd  0x8(%rcx),%xmm1
unpcklps 0xea1(%rip),%xmm1
subpd  0xea9(%rip),%xmm1
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsi)
mov    0x10(%rcx),%rax
sub    0x10(%rdi),%rax
jbe    11bb <set_swift_record+0xbb>
mov    %rax,%rdx
or     %r9,%rdx
shr    $0x20,%rdx
je     1195 <set_swift_record+0x95>
xor    %edx,%edx
div    %r9
jmp    119a <set_swift_record+0x9a>
xor    %edx,%edx
div    %r8d
movq   %rax,%xmm1
punpckldq 0xe59(%rip),%xmm1
subpd  0xe61(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsi)
movsd  0x18(%rcx),%xmm0
movapd 0xe33(%rip),%xmm1
unpcklps %xmm1,%xmm0
movapd 0xe38(%rip),%xmm2
subpd  %xmm2,%xmm0
movapd %xmm0,%xmm3
unpckhpd %xmm0,%xmm3
addsd  %xmm0,%xmm3
movsd  %xmm3,0x18(%rsi)
movsd  0x20(%rcx),%xmm0
unpcklps %xmm1,%xmm0
subpd  %xmm2,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rsi)
ret

LLVM IR (-O0):
%struct.module = type opaque
define void @set_swift_record(%struct.module* %0, double* %1, i64* %2, i64* %3, i32 %4) {
%6 = alloca %struct.module*
%7 = alloca double*
%8 = alloca i64*
%9 = alloca i64*
%10 = alloca i32
store %struct.module* %0, %struct.module** %6
store double* %1, double** %7
store i64* %2, i64** %8
store i64* %3, i64** %9
store i32 %4, i32* %10
%11 = load i64*, i64** %9
%12 = getelementptr inbounds i64, i64* %11, i64 0
%13 = load i64, i64* %12
%14 = load i64*, i64** %8
%15 = getelementptr inbounds i64, i64* %14, i64 0
%16 = load i64, i64* %15
%17 = icmp ugt i64 %13, %16
br i1 %17, label %18, label %32
18: ; preds = %5
%19 = load i64*, i64** %9
%20 = getelementptr inbounds i64, i64* %19, i64 0
%21 = load i64, i64* %20
%22 = load i64*, i64** %8
%23 = getelementptr inbounds i64, i64* %22, i64 0
%24 = load i64, i64* %23
%25 = sub i64 %21, %24
%26 = load i32, i32* %10
%27 = sext i32 %26 to i64
%28 = udiv i64 %25, %27
%29 = uitofp i64 %28 to double
%30 = load double*, double** %7
%31 = getelementptr inbounds double, double* %30, i64 0
store double %29, double* %31
br label %35
32: ; preds = %5
%33 = load double*, double** %7
%34 = getelementptr inbounds double, double* %33, i64 0
store double 0.000000e+00, double* %34
br label %35
35: ; preds = %32, %18
%36 = load i64*, i64** %9
%37 = getelementptr inbounds i64, i64* %36, i64 1
%38 = load i64, i64* %37
%39 = icmp ugt i64 %38, 0
br i1 %39, label %40, label %47
40: ; preds = %35
%41 = load i64*, i64** %9
%42 = getelementptr inbounds i64, i64* %41, i64 1
%43 = load i64, i64* %42
%44 = uitofp i64 %43 to double
%45 = load double*, double** %7
%46 = getelementptr inbounds double, double* %45, i64 1
store double %44, double* %46
br label %50
47: ; preds = %35
%48 = load double*, double** %7
%49 = getelementptr inbounds double, double* %48, i64 1
store double 0.000000e+00, double* %49
br label %50
50: ; preds = %47, %40
%51 = load i64*, i64** %9
%52 = getelementptr inbounds i64, i64* %51, i64 2
%53 = load i64, i64* %52
%54 = load i64*, i64** %8
%55 = getelementptr inbounds i64, i64* %54, i64 2
%56 = load i64, i64* %55
%57 = icmp ugt i64 %53, %56
br i1 %57, label %58, label %72
58: ; preds = %50
%59 = load i64*, i64** %9
%60 = getelementptr inbounds i64, i64* %59, i64 2
%61 = load i64, i64* %60
%62 = load i64*, i64** %8
%63 = getelementptr inbounds i64, i64* %62, i64 2
%64 = load i64, i64* %63
%65 = sub i64 %61, %64
%66 = load i32, i32* %10
%67 = sext i32 %66 to i64
%68 = udiv i64 %65, %67
%69 = uitofp i64 %68 to double
%70 = load double*, double** %7
%71 = getelementptr inbounds double, double* %70, i64 2
store double %69, double* %71
br label %75
72: ; preds = %50
%73 = load double*, double** %7
%74 = getelementptr inbounds double, double* %73, i64 2
store double 0.000000e+00, double* %74
br label %75
75: ; preds = %72, %58
%76 = load i64*, i64** %9
%77 = getelementptr inbounds i64, i64* %76, i64 3
%78 = load i64, i64* %77
%79 = icmp ugt i64 %78, 0
br i1 %79, label %80, label %87
80: ; preds = %75
%81 = load i64*, i64** %9
%82 = getelementptr inbounds i64, i64* %81, i64 3
%83 = load i64, i64* %82
%84 = uitofp i64 %83 to double
%85 = load double*, double** %7
%86 = getelementptr inbounds double, double* %85, i64 3
store double %84, double* %86
br label %90
87: ; preds = %75
%88 = load double*, double** %7
%89 = getelementptr inbounds double, double* %88, i64 3
store double 0.000000e+00, double* %89
br label %90
90: ; preds = %87, %80
%91 = load i64*, i64** %9
%92 = getelementptr inbounds i64, i64* %91, i64 4
%93 = load i64, i64* %92
%94 = icmp ugt i64 %93, 0
br i1 %94, label %95, label %102
95: ; preds = %90
%96 = load i64*, i64** %9
%97 = getelementptr inbounds i64, i64* %96, i64 4
%98 = load i64, i64* %97
%99 = uitofp i64 %98 to double
%100 = load double*, double** %7
%101 = getelementptr inbounds double, double* %100, i64 4
store double %99, double* %101
br label %105
102: ; preds = %90
%103 = load double*, double** %7
%104 = getelementptr inbounds double, double* %103, i64 4
store double 0.000000e+00, double* %104
br label %105
105: ; preds = %102, %95
ret void
}

LLVM IR (-O2):
%struct.module = type opaque
define void @set_swift_record(%struct.module* nocapture readnone %0, double* nocapture writeonly %1, i64* nocapture %2, i64* nocapture %3, i32 %4) {
%6 = load i64, i64* %3
%7 = load i64, i64* %2
%8 = icmp ugt i64 %6, %7
br i1 %8, label %9, label %14
9: ; preds = %5
%10 = sub i64 %6, %7
%11 = sext i32 %4 to i64
%12 = udiv i64 %10, %11
%13 = uitofp i64 %12 to double
br label %14
14: ; preds = %5, %9
%15 = phi double [ %13, %9 ], [ 0.000000e+00, %5 ]
store double %15, double* %1
%16 = getelementptr inbounds i64, i64* %3, i64 1
%17 = load i64, i64* %16
%18 = uitofp i64 %17 to double
%19 = getelementptr inbounds double, double* %1, i64 1
store double %18, double* %19
%20 = getelementptr inbounds i64, i64* %3, i64 2
%21 = load i64, i64* %20
%22 = getelementptr inbounds i64, i64* %2, i64 2
%23 = load i64, i64* %22
%24 = icmp ugt i64 %21, %23
br i1 %24, label %25, label %30
25: ; preds = %14
%26 = sub i64 %21, %23
%27 = sext i32 %4 to i64
%28 = udiv i64 %26, %27
%29 = uitofp i64 %28 to double
br label %30
30: ; preds = %14, %25
%31 = phi double [ %29, %25 ], [ 0.000000e+00, %14 ]
%32 = getelementptr inbounds double, double* %1, i64 2
store double %31, double* %32
%33 = getelementptr inbounds i64, i64* %3, i64 3
%34 = load i64, i64* %33
%35 = uitofp i64 %34 to double
%36 = getelementptr inbounds double, double* %1, i64 3
store double %35, double* %36
%37 = getelementptr inbounds i64, i64* %3, i64 4
%38 = load i64, i64* %37
%39 = uitofp i64 %38 to double
%40 = getelementptr inbounds double, double* %1, i64 4
store double %39, double* %40
ret void
}