#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);
double te_scale(int no, double *vp) {
  register int i;
  register double scale, tmp;
  scale = 0;
  for (i = 0; i < 3 * no; i += 3) {
    tmp = fabs(vp[i]) + fabs(vp[i + 1]) + 1.42 * fabs(vp[i + 2]);
    if (scale < tmp)
      scale = tmp;
  }
  return scale * 1.1;
}


x86 assembly (clang, -O0):
<te_scale>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
imul   $0x3,-0x4(%rbp),%ecx
cmp    %ecx,%eax
jge    11c5 <te_scale+0xc5>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movaps 0xed3(%rip),%xmm0
pand   %xmm0,%xmm1
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xeb6(%rip),%xmm2
pand   %xmm2,%xmm0
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xe95(%rip),%xmm2
pand   %xmm2,%xmm0
movsd  0xe81(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b2 <te_scale+0xb2>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11b7 <te_scale+0xb7>
mov    -0x14(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x14(%rbp)
jmp    111a <te_scale+0x1a>
movsd  0xe33(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<te_scale>:
test   %edi,%edi
jle    115e <te_scale+0x5e>
lea    (%rdi,%rdi,2),%eax
cltq
xorpd  %xmm0,%xmm0
xor    %ecx,%ecx
movdqa 0xee9(%rip),%xmm1
movsd  0xef1(%rip),%xmm2
nop
movapd %xmm0,%xmm3
movdqu (%rsi,%rcx,8),%xmm0
pand   %xmm1,%xmm0
pshufd $0xee,%xmm0,%xmm4
addsd  %xmm0,%xmm4
movq   0x10(%rsi,%rcx,8),%xmm0
pand   %xmm1,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm4,%xmm0
maxsd  %xmm3,%xmm0
add    $0x3,%rcx
cmp    %rax,%rcx
jl     1120 <te_scale+0x20>
mulsd  0xebb(%rip),%xmm0
ret
xorps  %xmm0,%xmm0
ret

LLVM IR (-O0):
define double @te_scale(i32 %0, double* %1) {
%3 = alloca i32
%4 = alloca double*
%5 = alloca i32
%6 = alloca double
%7 = alloca double
store i32 %0, i32* %3
store double* %1, double** %4
store double 0.000000e+00, double* %6
store i32 0, i32* %5
br label %8
8: ; preds = %42, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %3
%11 = mul nsw i32 3, %10
%12 = icmp slt i32 %9, %11
br i1 %12, label %13, label %45
13: ; preds = %8
%14 = load double*, double** %4
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %14, i64 %16
%18 = load double, double* %17
%19 = call double @llvm.fabs.f64(double %18)
%20 = load double*, double** %4
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %20, i64 %23
%25 = load double, double* %24
%26 = call double @llvm.fabs.f64(double %25)
%27 = fadd double %19, %26
%28 = load double*, double** %4
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %28, i64 %31
%33 = load double, double* %32
%34 = call double @llvm.fabs.f64(double %33)
%35 = call double @llvm.fmuladd.f64(double 1.420000e+00, double %34, double %27)
store double %35, double* %7
%36 = load double, double* %6
%37 = load double, double* %7
%38 = fcmp olt double %36, %37
br i1 %38, label %39, label %41
39: ; preds = %13
%40 = load double, double* %7
store double %40, double* %6
br label %41
41: ; preds = %39, %13
br label %42
42: ; preds = %41
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 3
store i32 %44, i32* %5
br label %8
45: ; preds = %8
%46 = load double, double* %6
%47 = fmul double %46, 1.100000e+00
ret double %47
}

LLVM IR (-O2):
define double @te_scale(i32 %0, double* nocapture %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %28
4: ; preds = %2
%5 = mul nsw i32 %0, 3
%6 = sext i32 %5 to i64
br label %7
7: ; preds = %4, %7
%8 = phi i64 [ 0, %4 ], [ %24, %7 ]
%9 = phi double [ 0.000000e+00, %4 ], [ %23, %7 ]
%10 = getelementptr inbounds double, double* %1, i64 %8
%11 = bitcast double* %10 to <2 x double>*
%12 = load <2 x double>, <2 x double>* %11
%13 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %12)
%14 = shufflevector <2 x double> %13, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%15 = fadd <2 x double> %13, %14
%16 = extractelement <2 x double> %15, i64 0
%17 = add nuw nsw i64 %8, 2
%18 = getelementptr inbounds double, double* %1, i64 %17
%19 = load double, double* %18
%20 = tail call double @llvm.fabs.f64(double %19)
%21 = tail call double @llvm.fmuladd.f64(double %20, double 1.420000e+00, double %16)
%22 = fcmp olt double %9, %21
%23 = select i1 %22, double %21, double %9
%24 = add nuw nsw i64 %8, 3
%25 = icmp slt i64 %24, %6
br i1 %25, label %7, label %26
26: ; preds = %7
%27 = fmul double %23, 1.100000e+00
br label %28
28: ; preds = %26, %2
%29 = phi double [ 0.000000e+00, %2 ], [ %27, %26 ]
ret double %29
}