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;
}


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)
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_swift_record>:
mov    (%rcx),%rax
xorpd  %xmm0,%xmm0
sub    (%rdx),%rax
jbe    1148 <set_swift_record+0x48>
movslq %r8d,%rdi
mov    %rax,%rdx
or     %rdi,%rdx
shr    $0x20,%rdx
je     1122 <set_swift_record+0x22>
xor    %edx,%edx
div    %rdi
jmp    1127 <set_swift_record+0x27>
xor    %edx,%edx
div    %r8d
movq   %rax,%xmm1
punpckldq 0xecc(%rip),%xmm1
subpd  0xed4(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rsi)
movsd  0x8(%rcx),%xmm0
unpcklps 0xea8(%rip),%xmm0
subpd  0xeb0(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%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
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
ret void
}