#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 exp(double const);
void inverse_transform_msimplex(double *x, const double *y, int K) {
  double sum = 0;
  int k = 0;
  for (; k < K - 1; k++) {
    x[k] = exp(y[k]);
    sum += x[k];
  }
  x[k] = 1.0 / (1.0 + sum);
  for (int i = 0; i < K - 1; i++) {
    x[i] /= x[k];
  }
}


x86 assembly (clang, -O0):
<inverse_transform_msimplex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1187 <inverse_transform_msimplex+0x77>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <exp@plt>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1132 <inverse_transform_msimplex+0x22>
movsd  0xe71(%rip),%xmm1
addsd  -0x20(%rbp),%xmm1
movsd  0xe64(%rip),%xmm0
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11f6 <inverse_transform_msimplex+0xe6>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11b4 <inverse_transform_msimplex+0xa4>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inverse_transform_msimplex>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
cmp    $0x1,%edx
jle    1211 <inverse_transform_msimplex+0x101>
mov    %edx,%r14d
mov    %rsi,%rbx
lea    -0x1(%r14),%r13d
mov    %r13d,%r12d
xorpd  %xmm1,%xmm1
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movsd  %xmm1,(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
call   1030 <exp@plt>
movsd  (%rsp),%xmm1
movsd  %xmm0,(%r15,%rbp,8)
addsd  %xmm0,%xmm1
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1140 <inverse_transform_msimplex+0x30>
movsd  0xe91(%rip),%xmm0
addsd  %xmm0,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%r15,%r12,8)
cmp    $0x2,%r14d
jl     121e <inverse_transform_msimplex+0x10e>
movsd  (%r15),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r15)
cmp    $0x1,%r13d
je     121e <inverse_transform_msimplex+0x10e>
lea    -0x1(%r12),%rcx
mov    $0x1,%eax
cmp    $0x2,%r13d
je     11f8 <inverse_transform_msimplex+0xe8>
mov    %rcx,%rdx
and    $0xfffffffffffffffe,%rdx
neg    %rdx
mov    $0x1,%eax
xchg   %ax,%ax
movsd  (%r15,%rax,8),%xmm0
divsd  (%r15,%r12,8),%xmm0
movsd  0x8(%r15,%rax,8),%xmm1
movsd  %xmm0,(%r15,%rax,8)
divsd  (%r15,%r12,8),%xmm1
movsd  %xmm1,0x8(%r15,%rax,8)
lea    (%rdx,%rax,1),%rsi
add    $0x2,%rsi
add    $0x2,%rax
cmp    $0x1,%rsi
jne    11c0 <inverse_transform_msimplex+0xb0>
test   $0x1,%cl
je     121e <inverse_transform_msimplex+0x10e>
movsd  (%r15,%rax,8),%xmm0
divsd  (%r15,%r12,8),%xmm0
movsd  %xmm0,(%r15,%rax,8)
jmp    121e <inverse_transform_msimplex+0x10e>
movabs $0x3ff0000000000000,%rax
mov    %rax,(%r15)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @inverse_transform_msimplex(double* %0, double* %1, i32 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store i32 %2, i32* %6
store double 0.000000e+00, double* %7
store i32 0, i32* %8
br label %10
10: ; preds = %33, %3
%11 = load i32, i32* %8
%12 = load i32, i32* %6
%13 = sub nsw i32 %12, 1
%14 = icmp slt i32 %11, %13
br i1 %14, label %15, label %36
15: ; preds = %10
%16 = load double*, double** %5
%17 = load i32, i32* %8
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double, double* %16, i64 %18
%20 = load double, double* %19
%21 = call double @exp(double %20)
%22 = load double*, double** %4
%23 = load i32, i32* %8
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %22, i64 %24
store double %21, double* %25
%26 = load double*, double** %4
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %26, i64 %28
%30 = load double, double* %29
%31 = load double, double* %7
%32 = fadd double %31, %30
store double %32, double* %7
br label %33
33: ; preds = %15
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
br label %10
36: ; preds = %10
%37 = load double, double* %7
%38 = fadd double 1.000000e+00, %37
%39 = fdiv double 1.000000e+00, %38
%40 = load double*, double** %4
%41 = load i32, i32* %8
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %40, i64 %42
store double %39, double* %43
store i32 0, i32* %9
br label %44
44: ; preds = %61, %36
%45 = load i32, i32* %9
%46 = load i32, i32* %6
%47 = sub nsw i32 %46, 1
%48 = icmp slt i32 %45, %47
br i1 %48, label %49, label %64
49: ; preds = %44
%50 = load double*, double** %4
%51 = load i32, i32* %8
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds double, double* %50, i64 %52
%54 = load double, double* %53
%55 = load double*, double** %4
%56 = load i32, i32* %9
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds double, double* %55, i64 %57
%59 = load double, double* %58
%60 = fdiv double %59, %54
store double %60, double* %58
br label %61
61: ; preds = %49
%62 = load i32, i32* %9
%63 = add nsw i32 %62, 1
store i32 %63, i32* %9
br label %44
64: ; preds = %44
ret void
}

LLVM IR (-O2):
define void @inverse_transform_msimplex(double* nocapture %0, double* nocapture %1, i32 %2) {
%4 = add i32 %2, -1
%5 = icmp sgt i32 %2, 1
br i1 %5, label %7, label %6
6: ; preds = %3
store double 1.000000e+00, double* %0
br label %42
7: ; preds = %3
%8 = zext i32 %4 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %17, %9 ]
%11 = phi double [ 0.000000e+00, %7 ], [ %16, %9 ]
%12 = getelementptr inbounds double, double* %1, i64 %10
%13 = load double, double* %12
%14 = tail call double @exp(double %13)
%15 = getelementptr inbounds double, double* %0, i64 %10
store double %14, double* %15
%16 = fadd double %11, %14
%17 = add nuw nsw i64 %10, 1
%18 = icmp eq i64 %17, %8
br i1 %18, label %19, label %9
19: ; preds = %9
%20 = fadd double %16, 1.000000e+00
%21 = zext i32 %4 to i64
%22 = fdiv double 1.000000e+00, %20
%23 = getelementptr inbounds double, double* %0, i64 %21
store double %22, double* %23
br i1 %5, label %24, label %42
24: ; preds = %19
%25 = load double, double* %0
%26 = fdiv double %25, %22
store double %26, double* %0
%27 = icmp eq i32 %4, 1
br i1 %27, label %42, label %28
28: ; preds = %24
%29 = add nsw i64 %8, -1
%30 = and i64 %29, 1
%31 = icmp eq i32 %4, 2
br i1 %31, label %34, label %32
32: ; preds = %28
%33 = and i64 %29, -2
br label %43
34: ; preds = %43, %28
%35 = phi i64 [ 1, %28 ], [ %55, %43 ]
%36 = icmp eq i64 %30, 0
br i1 %36, label %42, label %37
37: ; preds = %34
%38 = load double, double* %23
%39 = getelementptr inbounds double, double* %0, i64 %35
%40 = load double, double* %39
%41 = fdiv double %40, %38
store double %41, double* %39
br label %42
42: ; preds = %37, %34, %24, %6, %19
ret void
43: ; preds = %43, %32
%44 = phi i64 [ 1, %32 ], [ %55, %43 ]
%45 = phi i64 [ 0, %32 ], [ %56, %43 ]
%46 = load double, double* %23
%47 = getelementptr inbounds double, double* %0, i64 %44
%48 = load double, double* %47
%49 = fdiv double %48, %46
store double %49, double* %47
%50 = add nuw nsw i64 %44, 1
%51 = load double, double* %23
%52 = getelementptr inbounds double, double* %0, i64 %50
%53 = load double, double* %52
%54 = fdiv double %53, %51
store double %54, double* %52
%55 = add nuw nsw i64 %44, 2
%56 = add i64 %45, 2
%57 = icmp eq i64 %56, %33
br i1 %57, label %34, label %43
}