#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 fabs(double const);
void renormalize_weights(const double src_lats[4], double wgts[4][4]) {
  int n;
  double sum_wgts = 0.0;
  for (n = 0; n < 4; ++n)
    sum_wgts += fabs(src_lats[n]);
  for (n = 0; n < 4; ++n)
    wgts[n][0] = fabs(src_lats[n]) / sum_wgts;
  for (n = 0; n < 4; ++n)
    wgts[n][1] = 0.;
  for (n = 0; n < 4; ++n)
    wgts[n][2] = 0.;
  for (n = 0; n < 4; ++n)
    wgts[n][3] = 0.;
}


x86 assembly (clang, -O0):
<renormalize_weights>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    1155 <renormalize_weights+0x55>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xec7(%rip),%xmm1
pand   %xmm1,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    111b <renormalize_weights+0x1b>
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    11a4 <renormalize_weights+0xa4>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xe86(%rip),%xmm1
pand   %xmm1,%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movsd  %xmm0,(%rax)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115c <renormalize_weights+0x5c>
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    11da <renormalize_weights+0xda>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ab <renormalize_weights+0xab>
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    1210 <renormalize_weights+0x110>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e1 <renormalize_weights+0xe1>
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    1246 <renormalize_weights+0x146>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x18(%rax)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1217 <renormalize_weights+0x117>
pop    %rbp
ret

x86 assembly (clang, -O2):
<renormalize_weights>:
movsd  (%rdi),%xmm1
movsd  0x8(%rdi),%xmm2
movsd  0x10(%rdi),%xmm3
movsd  0x18(%rdi),%xmm0
movapd 0xee5(%rip),%xmm4
andpd  %xmm4,%xmm1
andpd  %xmm4,%xmm2
addsd  %xmm1,%xmm2
andpd  %xmm4,%xmm3
addsd  %xmm2,%xmm3
andpd  %xmm4,%xmm0
addsd  %xmm3,%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rsi)
movsd  0x8(%rdi),%xmm1
andpd  %xmm4,%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rsi)
movsd  0x10(%rdi),%xmm1
andpd  %xmm4,%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x40(%rsi)
movsd  0x18(%rdi),%xmm1
andpd  %xmm4,%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x60(%rsi)
xorpd  %xmm0,%xmm0
movupd %xmm0,0x8(%rsi)
movq   $0x0,0x18(%rsi)
movupd %xmm0,0x28(%rsi)
movq   $0x0,0x38(%rsi)
movupd %xmm0,0x48(%rsi)
movq   $0x0,0x58(%rsi)
movupd %xmm0,0x68(%rsi)
movq   $0x0,0x78(%rsi)
ret

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

LLVM IR (-O2):
define void @renormalize_weights(double* nocapture %0, [4 x double]* nocapture writeonly %1) {
%3 = load double, double* %0
%4 = tail call double @llvm.fabs.f64(double %3)
%5 = getelementptr inbounds double, double* %0, i64 1
%6 = load double, double* %5
%7 = tail call double @llvm.fabs.f64(double %6)
%8 = fadd double %4, %7
%9 = getelementptr inbounds double, double* %0, i64 2
%10 = load double, double* %9
%11 = tail call double @llvm.fabs.f64(double %10)
%12 = fadd double %8, %11
%13 = getelementptr inbounds double, double* %0, i64 3
%14 = load double, double* %13
%15 = tail call double @llvm.fabs.f64(double %14)
%16 = fadd double %12, %15
%17 = fdiv double %4, %16
%18 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 0, i64 0
store double %17, double* %18
%19 = load double, double* %5
%20 = tail call double @llvm.fabs.f64(double %19)
%21 = fdiv double %20, %16
%22 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 1, i64 0
store double %21, double* %22
%23 = load double, double* %9
%24 = tail call double @llvm.fabs.f64(double %23)
%25 = fdiv double %24, %16
%26 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 2, i64 0
store double %25, double* %26
%27 = load double, double* %13
%28 = tail call double @llvm.fabs.f64(double %27)
%29 = fdiv double %28, %16
%30 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 3, i64 0
store double %29, double* %30
%31 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 0, i64 1
%32 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 1, i64 1
%33 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 2, i64 1
%34 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 3, i64 1
%35 = bitcast double* %31 to i8*
%36 = bitcast double* %32 to i8*
%37 = bitcast double* %33 to i8*
%38 = bitcast double* %34 to i8*
ret void
}