#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 */
int /*<<< orphan*/ simplex(int, double *);
void generalized_simplex(int size, double sum, double v[]) {
  int i;
  simplex(size, v);
  for (i = 0; i < size; i++) {
    v[i] *= sum;
  }
}


x86 assembly (clang, -O0):
<generalized_simplex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1030 <simplex@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1168 <generalized_simplex+0x58>
movsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1137 <generalized_simplex+0x27>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generalized_simplex>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
movapd %xmm0,(%rsp)
mov    %edi,%ebp
call   1030 <simplex@plt>
movapd (%rsp),%xmm5
test   %ebp,%ebp
jle    1207 <generalized_simplex+0xf7>
mov    %ebp,%eax
cmp    $0x4,%ebp
jae    1140 <generalized_simplex+0x30>
xor    %ecx,%ecx
jmp    11f0 <generalized_simplex+0xe0>
mov    %eax,%ecx
and    $0xfffffffc,%ecx
movapd %xmm5,%xmm0
unpcklpd %xmm5,%xmm0
lea    -0x4(%rcx),%rdx
mov    %rdx,%rsi
shr    $0x2,%rsi
add    $0x1,%rsi
test   %rdx,%rdx
je     120e <generalized_simplex+0xfe>
mov    %rsi,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %edx,%edx
xchg   %ax,%ax
movupd (%rbx,%rdx,8),%xmm1
movupd 0x10(%rbx,%rdx,8),%xmm2
movupd 0x20(%rbx,%rdx,8),%xmm3
movupd 0x30(%rbx,%rdx,8),%xmm4
mulpd  %xmm0,%xmm1
mulpd  %xmm0,%xmm2
movupd %xmm1,(%rbx,%rdx,8)
movupd %xmm2,0x10(%rbx,%rdx,8)
mulpd  %xmm0,%xmm3
mulpd  %xmm0,%xmm4
movupd %xmm3,0x20(%rbx,%rdx,8)
movupd %xmm4,0x30(%rbx,%rdx,8)
add    $0x8,%rdx
add    $0xfffffffffffffffe,%rdi
jne    1170 <generalized_simplex+0x60>
test   $0x1,%sil
je     11dc <generalized_simplex+0xcc>
movupd (%rbx,%rdx,8),%xmm1
movupd 0x10(%rbx,%rdx,8),%xmm2
mulpd  %xmm0,%xmm1
mulpd  %xmm0,%xmm2
movupd %xmm1,(%rbx,%rdx,8)
movupd %xmm2,0x10(%rbx,%rdx,8)
cmp    %rax,%rcx
je     1207 <generalized_simplex+0xf7>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%rbx,%rcx,8),%xmm0
mulsd  %xmm5,%xmm0
movsd  %xmm0,(%rbx,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    11f0 <generalized_simplex+0xe0>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret
xor    %edx,%edx
test   $0x1,%sil
jne    11be <generalized_simplex+0xae>
jmp    11dc <generalized_simplex+0xcc>

LLVM IR (-O0):
define void @generalized_simplex(i32 %0, double %1, double* %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca double*
%7 = alloca i32
store i32 %0, i32* %4
store double %1, double* %5
store double* %2, double** %6
%8 = load i32, i32* %4
%9 = load double*, double** %6
%10 = call i32 @simplex(i32 %8, double* %9)
store i32 0, i32* %7
br label %11
11: ; preds = %23, %3
%12 = load i32, i32* %7
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %26
15: ; preds = %11
%16 = load double, double* %5
%17 = load double*, double** %6
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %17, i64 %19
%21 = load double, double* %20
%22 = fmul double %21, %16
store double %22, double* %20
br label %23
23: ; preds = %15
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %11
26: ; preds = %11
ret void
}

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