#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(int /*<<< orphan*/);
int /*<<< orphan*/ innerprod(double *, double *, int);
void Update_affinity_mat(double **X, double **A, int idx, int m, int n) {
  int i;
  for (i = 0; i < m; i++) {
    A[idx][i] = exp(innerprod(X[idx], X[i], n));
    A[i][idx] = A[idx][i];
  }
}


x86 assembly (clang, -O0):
<Update_affinity_mat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11c1 <Update_affinity_mat+0xa1>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <innerprod@plt>
mov    %eax,%edi
call   1030 <exp@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1141 <Update_affinity_mat+0x21>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Update_affinity_mat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %ecx,%ecx
jle    1174 <Update_affinity_mat+0x54>
mov    %r8d,%r14d
mov    %rsi,%r15
mov    %rdi,%r13
movslq %edx,%rbx
mov    %ecx,%r12d
xor    %ebp,%ebp
mov    0x0(%r13,%rbx,8),%rdi
mov    0x0(%r13,%rbp,8),%rsi
mov    %r14d,%edx
call   1040 <innerprod@plt>
mov    %eax,%edi
call   1030 <exp@plt>
mov    (%r15,%rbx,8),%rax
movsd  %xmm0,(%rax,%rbp,8)
mov    (%r15,%rbp,8),%rax
movsd  %xmm0,(%rax,%rbx,8)
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1140 <Update_affinity_mat+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @Update_affinity_mat(double** nocapture %0, double** nocapture %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp sgt i32 %3, 0
br i1 %6, label %7, label %26
7: ; preds = %5
%8 = sext i32 %2 to i64
%9 = getelementptr inbounds double*, double** %0, i64 %8
%10 = getelementptr inbounds double*, double** %1, i64 %8
%11 = zext i32 %3 to i64
br label %12
12: ; preds = %7, %12
%13 = phi i64 [ 0, %7 ], [ %24, %12 ]
%14 = load double*, double** %9
%15 = getelementptr inbounds double*, double** %0, i64 %13
%16 = load double*, double** %15
%17 = tail call i32 @innerprod(double* %14, double* %16, i32 %4)
%18 = tail call double @exp(i32 %17)
%19 = load double*, double** %10
%20 = getelementptr inbounds double, double* %19, i64 %13
store double %18, double* %20
%21 = getelementptr inbounds double*, double** %1, i64 %13
%22 = load double*, double** %21
%23 = getelementptr inbounds double, double* %22, i64 %8
store double %18, double* %23
%24 = add nuw nsw i64 %13, 1
%25 = icmp eq i64 %24, %11
br i1 %25, label %26, label %12
26: ; preds = %12, %5
ret void
}