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


x86 assembly (clang, -O0):
<Cal_exp_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)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11e2 <Cal_exp_affinity_mat+0xc2>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11cf <Cal_exp_affinity_mat+0xaf>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x18(%rbp),%edx
call   1040 <innerprod@plt>
mov    %eax,%edi
call   1030 <exp@plt>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x1c(%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 -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114f <Cal_exp_affinity_mat+0x2f>
jmp    11d4 <Cal_exp_affinity_mat+0xb4>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113d <Cal_exp_affinity_mat+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Cal_exp_affinity_mat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    118d <Cal_exp_affinity_mat+0x6d>
mov    %ecx,%r14d
mov    %rsi,%r12
mov    %rdi,%r13
mov    %edx,%r15d
xor    %ebp,%ebp
nopl   (%rax)
mov    %rbp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%r13,%rbp,8),%rdi
mov    0x0(%r13,%rbx,8),%rsi
mov    %r14d,%edx
call   1040 <innerprod@plt>
mov    %eax,%edi
call   1030 <exp@plt>
mov    (%r12,%rbp,8),%rax
movsd  %xmm0,(%rax,%rbx,8)
mov    (%r12,%rbx,8),%rax
movsd  %xmm0,(%rax,%rbp,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1150 <Cal_exp_affinity_mat+0x30>
add    $0x1,%rbp
cmp    %r15,%rbp
jne    1140 <Cal_exp_affinity_mat+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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