#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);
int /*<<< orphan*/ printf(char *, double, double);
double mult(int dims, double fx, double *pos, double *b) {
  int i;
  double val = 1.0;
  for (i = 0; i < dims; i++) {
    val *= fabs(1.0 - pos[i] - b[i]);
  }
  val *= fx;
  printf("mult val= %f fx=%f\n", val, fx);
  return val;
}


x86 assembly (clang, -O0):
<mult>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movsd  0xed0(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    118d <mult+0x7d>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  0xea8(%rip),%xmm0
subsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movaps 0xe9f(%rip),%xmm1
pand   %xmm1,%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113c <mult+0x2c>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x30(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mult>:
sub    $0x18,%rsp
movapd %xmm0,%xmm1
test   %edi,%edi
jle    112f <mult+0x1f>
mov    %edi,%eax
cmp    $0x1,%edi
jne    113c <mult+0x2c>
movsd  0xed5(%rip),%xmm0
xor    %ecx,%ecx
jmp    1197 <mult+0x87>
movsd  0xec9(%rip),%xmm0
jmp    11b9 <mult+0xa9>
mov    %eax,%edi
and    $0xfffffffe,%edi
movsd  0xeb7(%rip),%xmm4
xor    %ecx,%ecx
movapd 0xebd(%rip),%xmm2
movapd %xmm4,%xmm0
nopw   0x0(%rax,%rax,1)
movapd %xmm4,%xmm3
subsd  (%rsi,%rcx,8),%xmm3
subsd  (%rdx,%rcx,8),%xmm3
andpd  %xmm2,%xmm3
mulsd  %xmm0,%xmm3
movapd %xmm4,%xmm0
subsd  0x8(%rsi,%rcx,8),%xmm0
subsd  0x8(%rdx,%rcx,8),%xmm0
andpd  %xmm2,%xmm0
mulsd  %xmm3,%xmm0
add    $0x2,%rcx
cmp    %rcx,%rdi
jne    1160 <mult+0x50>
test   $0x1,%al
je     11b9 <mult+0xa9>
movsd  0xe5d(%rip),%xmm2
subsd  (%rsi,%rcx,8),%xmm2
subsd  (%rdx,%rcx,8),%xmm2
andpd  0xe5b(%rip),%xmm2
mulsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
movapd %xmm0,(%rsp)
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
movaps (%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"mult val= %f fx=%f\0A\00"
define double @mult(i32 %0, double %1, double* %2, double* %3) {
%5 = alloca i32
%6 = alloca double
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca double
store i32 %0, i32* %5
store double %1, double* %6
store double* %2, double** %7
store double* %3, double** %8
store double 1.000000e+00, double* %10
store i32 0, i32* %9
br label %11
11: ; preds = %31, %4
%12 = load i32, i32* %9
%13 = load i32, i32* %5
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %34
15: ; preds = %11
%16 = load double*, double** %7
%17 = load i32, i32* %9
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double, double* %16, i64 %18
%20 = load double, double* %19
%21 = fsub double 1.000000e+00, %20
%22 = load double*, double** %8
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %22, i64 %24
%26 = load double, double* %25
%27 = fsub double %21, %26
%28 = call double @llvm.fabs.f64(double %27)
%29 = load double, double* %10
%30 = fmul double %29, %28
store double %30, double* %10
br label %31
31: ; preds = %15
%32 = load i32, i32* %9
%33 = add nsw i32 %32, 1
store i32 %33, i32* %9
br label %11
34: ; preds = %11
%35 = load double, double* %6
%36 = load double, double* %10
%37 = fmul double %36, %35
store double %37, double* %10
%38 = load double, double* %10
%39 = load double, double* %6
%40 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), double %38, double %39)
%41 = load double, double* %10
ret double %41
}

LLVM IR (-O2):
@.str = [20 x i8] c"mult val= %f fx=%f\0A\00"
define double @mult(i32 %0, double %1, double* nocapture %2, double* nocapture %3) {
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %50
6: ; preds = %4
%7 = zext i32 %0 to i64
%8 = and i64 %7, 1
%9 = icmp eq i32 %0, 1
br i1 %9, label %36, label %10
10: ; preds = %6
%11 = and i64 %7, 4294967294
br label %12
12: ; preds = %12, %10
%13 = phi i64 [ 0, %10 ], [ %33, %12 ]
%14 = phi double [ 1.000000e+00, %10 ], [ %32, %12 ]
%15 = phi i64 [ 0, %10 ], [ %34, %12 ]
%16 = getelementptr inbounds double, double* %2, i64 %13
%17 = load double, double* %16
%18 = fsub double 1.000000e+00, %17
%19 = getelementptr inbounds double, double* %3, i64 %13
%20 = load double, double* %19
%21 = fsub double %18, %20
%22 = tail call double @llvm.fabs.f64(double %21)
%23 = fmul double %14, %22
%24 = or i64 %13, 1
%25 = getelementptr inbounds double, double* %2, i64 %24
%26 = load double, double* %25
%27 = fsub double 1.000000e+00, %26
%28 = getelementptr inbounds double, double* %3, i64 %24
%29 = load double, double* %28
%30 = fsub double %27, %29
%31 = tail call double @llvm.fabs.f64(double %30)
%32 = fmul double %23, %31
%33 = add nuw nsw i64 %13, 2
%34 = add i64 %15, 2
%35 = icmp eq i64 %34, %11
br i1 %35, label %36, label %12
36: ; preds = %12, %6
%37 = phi double [ undef, %6 ], [ %32, %12 ]
%38 = phi i64 [ 0, %6 ], [ %33, %12 ]
%39 = phi double [ 1.000000e+00, %6 ], [ %32, %12 ]
%40 = icmp eq i64 %8, 0
br i1 %40, label %50, label %41
41: ; preds = %36
%42 = getelementptr inbounds double, double* %2, i64 %38
%43 = load double, double* %42
%44 = fsub double 1.000000e+00, %43
%45 = getelementptr inbounds double, double* %3, i64 %38
%46 = load double, double* %45
%47 = fsub double %44, %46
%48 = tail call double @llvm.fabs.f64(double %47)
%49 = fmul double %39, %48
br label %50
50: ; preds = %41, %36, %4
%51 = phi double [ 1.000000e+00, %4 ], [ %37, %36 ], [ %49, %41 ]
%52 = fmul double %51, %1
%53 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), double %52, double %1)
ret double %52
}