#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 */
void lcfit2_normalize(const double max_lnl, const size_t n, double *lnl) {
  for (size_t i = 0; i < n; ++i) {
    lnl[i] -= max_lnl;
  }
}


x86 assembly (clang, -O0):
<lcfit2_normalize>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1153 <lcfit2_normalize+0x53>
movsd  -0x8(%rbp),%xmm1
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1119 <lcfit2_normalize+0x19>
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcfit2_normalize>:
test   %rdi,%rdi
je     11e7 <lcfit2_normalize+0xe7>
cmp    $0x4,%rdi
jae    1116 <lcfit2_normalize+0x16>
xor    %eax,%eax
jmp    11d0 <lcfit2_normalize+0xd0>
mov    %rdi,%rax
and    $0xfffffffffffffffc,%rax
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x4(%rax),%rcx
mov    %rcx,%r8
shr    $0x2,%r8
add    $0x1,%r8
test   %rcx,%rcx
je     11e8 <lcfit2_normalize+0xe8>
mov    %r8,%rdx
and    $0xfffffffffffffffe,%rdx
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
movupd (%rsi,%rcx,8),%xmm2
movupd 0x10(%rsi,%rcx,8),%xmm3
movupd 0x20(%rsi,%rcx,8),%xmm4
movupd 0x30(%rsi,%rcx,8),%xmm5
subpd  %xmm1,%xmm2
subpd  %xmm1,%xmm3
movupd %xmm2,(%rsi,%rcx,8)
movupd %xmm3,0x10(%rsi,%rcx,8)
subpd  %xmm1,%xmm4
subpd  %xmm1,%xmm5
movupd %xmm4,0x20(%rsi,%rcx,8)
movupd %xmm5,0x30(%rsi,%rcx,8)
add    $0x8,%rcx
add    $0xfffffffffffffffe,%rdx
jne    1150 <lcfit2_normalize+0x50>
test   $0x1,%r8b
je     11bc <lcfit2_normalize+0xbc>
movupd (%rsi,%rcx,8),%xmm2
movupd 0x10(%rsi,%rcx,8),%xmm3
subpd  %xmm1,%xmm2
subpd  %xmm1,%xmm3
movupd %xmm2,(%rsi,%rcx,8)
movupd %xmm3,0x10(%rsi,%rcx,8)
cmp    %rdi,%rax
je     11e7 <lcfit2_normalize+0xe7>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%rsi,%rax,8),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsi,%rax,8)
add    $0x1,%rax
cmp    %rax,%rdi
jne    11d0 <lcfit2_normalize+0xd0>
ret
xor    %ecx,%ecx
test   $0x1,%r8b
jne    119e <lcfit2_normalize+0x9e>
jmp    11bc <lcfit2_normalize+0xbc>

LLVM IR (-O0):
define void @lcfit2_normalize(double %0, i64 %1, double* %2) {
%4 = alloca double
%5 = alloca i64
%6 = alloca double*
%7 = alloca i64
store double %0, double* %4
store i64 %1, i64* %5
store double* %2, double** %6
store i64 0, i64* %7
br label %8
8: ; preds = %19, %3
%9 = load i64, i64* %7
%10 = load i64, i64* %5
%11 = icmp ult i64 %9, %10
br i1 %11, label %12, label %22
12: ; preds = %8
%13 = load double, double* %4
%14 = load double*, double** %6
%15 = load i64, i64* %7
%16 = getelementptr inbounds double, double* %14, i64 %15
%17 = load double, double* %16
%18 = fsub double %17, %13
store double %18, double* %16
br label %19
19: ; preds = %12
%20 = load i64, i64* %7
%21 = add i64 %20, 1
store i64 %21, i64* %7
br label %8
22: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @lcfit2_normalize(double %0, i64 %1, double* nocapture %2) {
%4 = icmp eq i64 %1, 0
br i1 %4, label %65, label %5
5: ; preds = %3
%6 = icmp ult i64 %1, 4
br i1 %6, label %63, label %7
7: ; preds = %5
%8 = and i64 %1, -4
%9 = insertelement <2 x double> poison, double %0, i64 0
%10 = shufflevector <2 x double> %9, <2 x double> poison, <2 x i32> zeroinitializer
%11 = insertelement <2 x double> poison, double %0, i64 0
%12 = shufflevector <2 x double> %11, <2 x double> poison, <2 x i32> zeroinitializer
%13 = add i64 %8, -4
%14 = lshr exact i64 %13, 2
%15 = add nuw nsw i64 %14, 1
%16 = and i64 %15, 1
%17 = icmp eq i64 %13, 0
br i1 %17, label %47, label %18
18: ; preds = %7
%19 = and i64 %15, 9223372036854775806
br label %20
20: ; preds = %20, %18
%21 = phi i64 [ 0, %18 ], [ %44, %20 ]
%22 = phi i64 [ 0, %18 ], [ %45, %20 ]
%23 = getelementptr inbounds double, double* %2, i64 %21
%24 = bitcast double* %23 to <2 x double>*
%25 = load <2 x double>, <2 x double>* %24
%26 = getelementptr inbounds double, double* %23, i64 2
%27 = bitcast double* %26 to <2 x double>*
%28 = load <2 x double>, <2 x double>* %27
%29 = fsub <2 x double> %25, %10
%30 = fsub <2 x double> %28, %12
%31 = bitcast double* %23 to <2 x double>*
store <2 x double> %29, <2 x double>* %31
%32 = bitcast double* %26 to <2 x double>*
store <2 x double> %30, <2 x double>* %32
%33 = or i64 %21, 4
%34 = getelementptr inbounds double, double* %2, i64 %33
%35 = bitcast double* %34 to <2 x double>*
%36 = load <2 x double>, <2 x double>* %35
%37 = getelementptr inbounds double, double* %34, i64 2
%38 = bitcast double* %37 to <2 x double>*
%39 = load <2 x double>, <2 x double>* %38
%40 = fsub <2 x double> %36, %10
%41 = fsub <2 x double> %39, %12
%42 = bitcast double* %34 to <2 x double>*
store <2 x double> %40, <2 x double>* %42
%43 = bitcast double* %37 to <2 x double>*
store <2 x double> %41, <2 x double>* %43
%44 = add nuw i64 %21, 8
%45 = add i64 %22, 2
%46 = icmp eq i64 %45, %19
br i1 %46, label %47, label %20
47: ; preds = %20, %7
%48 = phi i64 [ 0, %7 ], [ %44, %20 ]
%49 = icmp eq i64 %16, 0
br i1 %49, label %61, label %50
50: ; preds = %47
%51 = getelementptr inbounds double, double* %2, i64 %48
%52 = bitcast double* %51 to <2 x double>*
%53 = load <2 x double>, <2 x double>* %52
%54 = getelementptr inbounds double, double* %51, i64 2
%55 = bitcast double* %54 to <2 x double>*
%56 = load <2 x double>, <2 x double>* %55
%57 = fsub <2 x double> %53, %10
%58 = fsub <2 x double> %56, %12
%59 = bitcast double* %51 to <2 x double>*
store <2 x double> %57, <2 x double>* %59
%60 = bitcast double* %54 to <2 x double>*
store <2 x double> %58, <2 x double>* %60
br label %61
61: ; preds = %47, %50
%62 = icmp eq i64 %8, %1
br i1 %62, label %65, label %63
63: ; preds = %5, %61
%64 = phi i64 [ 0, %5 ], [ %8, %61 ]
br label %66
65: ; preds = %66, %61, %3
ret void
66: ; preds = %63, %66
%67 = phi i64 [ %71, %66 ], [ %64, %63 ]
%68 = getelementptr inbounds double, double* %2, i64 %67
%69 = load double, double* %68
%70 = fsub double %69, %0
store double %70, double* %68
%71 = add nuw i64 %67, 1
%72 = icmp eq i64 %71, %1
br i1 %72, label %65, label %66
}