#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 swt_abs(double);
int /*<<< orphan*/ swt_max_abs(double *, int, double *);
int /*<<< orphan*/ swt_min_abs(double *, int, double *);
void wcodemat_abs(double *sigIn, int sigInLength, double *sigOut,
                  int sigOutLength, int minv, int maxv) {
  int count;
  double sigMin, sigMax;
  swt_max_abs(sigIn, sigInLength, &sigMax);
  swt_min_abs(sigIn, sigInLength, &sigMin);
  for (count = 0; count < sigInLength; count++)
    sigOut[count] =
        ((swt_abs(sigIn[count]) - sigMin) / (sigMax - sigMin)) * (maxv - minv) +
        minv;
  return;
}


x86 assembly (clang, -O0):
<wcodemat_abs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x38(%rbp),%rdx
call   1040 <swt_max_abs@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x30(%rbp),%rdx
call   1050 <swt_min_abs@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d8 <wcodemat_abs+0xa8>
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <swt_abs@plt>
subsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
subsd  -0x30(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x24(%rbp),%eax
sub    -0x20(%rbp),%eax
cvtsi2sd %eax,%xmm2
cvtsi2sdl -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1175 <wcodemat_abs+0x45>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wcodemat_abs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9d,%r12d
mov    %r8d,%r15d
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%r13
lea    0x18(%rsp),%rdx
call   1040 <swt_max_abs@plt>
lea    0x20(%rsp),%rdx
mov    %r13,%rdi
mov    %ebp,%esi
call   1050 <swt_min_abs@plt>
test   %ebp,%ebp
jle    11cf <wcodemat_abs+0x9f>
sub    %r15d,%r12d
cvtsi2sd %r12d,%xmm0
movsd  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax)
movsd  0x0(%r13,%rbx,8),%xmm0
call   1030 <swt_abs@plt>
movsd  0x20(%rsp),%xmm1
subsd  %xmm1,%xmm0
movsd  0x18(%rsp),%xmm2
subsd  %xmm1,%xmm2
divsd  %xmm2,%xmm0
mulsd  0x10(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1190 <wcodemat_abs+0x60>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @wcodemat_abs(double* %0, i32 %1, double* %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca double*
%8 = alloca i32
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca double
%15 = alloca double
store double* %0, double** %7
store i32 %1, i32* %8
store double* %2, double** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%16 = load double*, double** %7
%17 = load i32, i32* %8
%18 = call i32 @swt_max_abs(double* %16, i32 %17, double* %15)
%19 = load double*, double** %7
%20 = load i32, i32* %8
%21 = call i32 @swt_min_abs(double* %19, i32 %20, double* %14)
store i32 0, i32* %13
br label %22
22: ; preds = %50, %6
%23 = load i32, i32* %13
%24 = load i32, i32* %8
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %53
26: ; preds = %22
%27 = load double*, double** %7
%28 = load i32, i32* %13
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %27, i64 %29
%31 = load double, double* %30
%32 = call double @swt_abs(double %31)
%33 = load double, double* %14
%34 = fsub double %32, %33
%35 = load double, double* %15
%36 = load double, double* %14
%37 = fsub double %35, %36
%38 = fdiv double %34, %37
%39 = load i32, i32* %12
%40 = load i32, i32* %11
%41 = sub nsw i32 %39, %40
%42 = sitofp i32 %41 to double
%43 = load i32, i32* %11
%44 = sitofp i32 %43 to double
%45 = call double @llvm.fmuladd.f64(double %38, double %42, double %44)
%46 = load double*, double** %9
%47 = load i32, i32* %13
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds double, double* %46, i64 %48
store double %45, double* %49
br label %50
50: ; preds = %26
%51 = load i32, i32* %13
%52 = add nsw i32 %51, 1
store i32 %52, i32* %13
br label %22
53: ; preds = %22
ret void
}

LLVM IR (-O2):
define void @wcodemat_abs(double* %0, i32 %1, double* nocapture writeonly %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca double
%8 = alloca double
%9 = bitcast double* %7 to i8*
%10 = bitcast double* %8 to i8*
%11 = call i32 @swt_max_abs(double* %0, i32 %1, double* %8)
%12 = call i32 @swt_min_abs(double* %0, i32 %1, double* %7)
%13 = icmp sgt i32 %1, 0
br i1 %13, label %14, label %33
14: ; preds = %6
%15 = sub nsw i32 %5, %4
%16 = sitofp i32 %15 to double
%17 = sitofp i32 %4 to double
%18 = zext i32 %1 to i64
br label %19
19: ; preds = %14, %19
%20 = phi i64 [ 0, %14 ], [ %31, %19 ]
%21 = getelementptr inbounds double, double* %0, i64 %20
%22 = load double, double* %21
%23 = call double @swt_abs(double %22)
%24 = load double, double* %7
%25 = fsub double %23, %24
%26 = load double, double* %8
%27 = fsub double %26, %24
%28 = fdiv double %25, %27
%29 = call double @llvm.fmuladd.f64(double %28, double %16, double %17)
%30 = getelementptr inbounds double, double* %2, i64 %20
store double %29, double* %30
%31 = add nuw nsw i64 %20, 1
%32 = icmp eq i64 %31, %18
br i1 %32, label %33, label %19
33: ; preds = %19, %6
ret void
}