#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*/ AppendDebugTraceFile(char *);
scalar_t__ calloc(int, int);
int floor(double);
int /*<<< orphan*/ sprintf(char *, char *, int, int);
void Default_RelConnectionCost(int iZoneCount, double *_RelConnectionCost[]) {
  int i, j, iArraySize;
  double rArraySize;
  char debugbuffer[1000];
  AppendDebugTraceFile("Default_RelConnectionCost start\n");
  rArraySize = iZoneCount * iZoneCount;
  iArraySize = floor(rArraySize);
  sprintf(debugbuffer,
          "Default_RelConnectionCost iZoneCount %i iArraySize %i\n", iZoneCount,
          iArraySize);
  AppendDebugTraceFile(debugbuffer);
  *_RelConnectionCost = (double *)calloc(iArraySize, sizeof(double));
  for (j = 0; j < iZoneCount; j++) {
    for (i = 0; i < iZoneCount; i++) {
      (*_RelConnectionCost)[(j * iZoneCount) + i] = 0;
      if (j == 0)
        (*_RelConnectionCost)[(j * iZoneCount) + i] = 1;
      if (i == 0)
        (*_RelConnectionCost)[(j * iZoneCount) + i] = 1;
    }
  }
  AppendDebugTraceFile("Default_RelConnectionCost end\n");
}


x86 assembly (clang, -O0):
<Default_RelConnectionCost>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeaf(%rip),%rdi
call   1030 <AppendDebugTraceFile@plt>
mov    -0x4(%rbp),%eax
imul   -0x4(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1060 <floor@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x4(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xe9a(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x410(%rbp),%rdi
call   1030 <AppendDebugTraceFile@plt>
mov    -0x1c(%rbp),%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1275 <Default_RelConnectionCost+0x135>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1262 <Default_RelConnectionCost+0x122>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%ecx
imul   -0x4(%rbp),%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
cmpl   $0x0,-0x18(%rbp)
jne    1224 <Default_RelConnectionCost+0xe4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%ecx
imul   -0x4(%rbp),%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
movsd  0xde1(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
cmpl   $0x0,-0x14(%rbp)
jne    124f <Default_RelConnectionCost+0x10f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%ecx
imul   -0x4(%rbp),%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
movsd  0xdb6(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    1254 <Default_RelConnectionCost+0x114>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d1 <Default_RelConnectionCost+0x91>
jmp    1267 <Default_RelConnectionCost+0x127>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11be <Default_RelConnectionCost+0x7e>
lea    0xde4(%rip),%rdi
call   1030 <AppendDebugTraceFile@plt>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Default_RelConnectionCost>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x3f0,%rsp
mov    %rsi,%r14
mov    %edi,%r12d
lea    0xeac(%rip),%rdi
call   1030 <AppendDebugTraceFile@plt>
mov    %r12d,%eax
imul   %r12d,%eax
cvtsi2sd %eax,%xmm0
call   1060 <floor@plt>
mov    %eax,%ebp
lea    0xeaf(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
mov    %r12d,%edx
mov    %eax,%ecx
call   1050 <sprintf@plt>
mov    %r15,%rdi
call   1030 <AppendDebugTraceFile@plt>
mov    %ebp,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,(%r14)
test   %r12d,%r12d
jle    1270 <Default_RelConnectionCost+0x130>
mov    %r12d,%ecx
mov    %ecx,%edx
and    $0xfffffffe,%edx
mov    %rax,%rsi
add    $0x8,%rsi
lea    0x0(,%rcx,8),%r8
xor    %ebp,%ebp
movsd  0xe35(%rip),%xmm0
jmp    11e5 <Default_RelConnectionCost+0xa5>
nopl   (%rax)
movsd  %xmm2,(%rax,%rdi,8)
add    $0x1,%rbp
add    %r8,%rsi
cmp    %rcx,%rbp
je     1270 <Default_RelConnectionCost+0x130>
cmp    $0x1,%r12d
jne    1220 <Default_RelConnectionCost+0xe0>
xor    %ebx,%ebx
test   $0x1,%cl
je     11d5 <Default_RelConnectionCost+0x95>
mov    %rbp,%rdi
imul   %rcx,%rdi
movapd %xmm0,%xmm1
test   %rbp,%rbp
je     1206 <Default_RelConnectionCost+0xc6>
xorpd  %xmm1,%xmm1
add    %rbx,%rdi
movapd %xmm0,%xmm2
test   %rbx,%rbx
je     11d0 <Default_RelConnectionCost+0x90>
movapd %xmm1,%xmm2
jmp    11d0 <Default_RelConnectionCost+0x90>
nopl   0x0(%rax,%rax,1)
movapd %xmm0,%xmm1
test   %rbp,%rbp
je     122d <Default_RelConnectionCost+0xed>
xorpd  %xmm1,%xmm1
xor    %ebx,%ebx
jmp    1254 <Default_RelConnectionCost+0x114>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  %xmm3,-0x8(%rsi,%rbx,8)
movsd  %xmm1,(%rsi,%rbx,8)
add    $0x2,%rbx
cmp    %rbx,%rdx
je     11ed <Default_RelConnectionCost+0xad>
movapd %xmm0,%xmm2
test   %rbp,%rbp
je     1261 <Default_RelConnectionCost+0x121>
xorpd  %xmm2,%xmm2
movapd %xmm0,%xmm3
test   %rbx,%rbx
je     1240 <Default_RelConnectionCost+0x100>
movapd %xmm2,%xmm3
jmp    1240 <Default_RelConnectionCost+0x100>
lea    0xde9(%rip),%rdi
call   1030 <AppendDebugTraceFile@plt>
add    $0x3f0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Default_RelConnectionCost start\0A\00"
@.str.1 = [55 x i8] c"Default_RelConnectionCost iZoneCount %i iArraySize %i\0A\00"
@.str.2 = [31 x i8] c"Default_RelConnectionCost end\0A\00"
define void @Default_RelConnectionCost(i32 %0, double** %1) {
%3 = alloca i32
%4 = alloca double**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca [1000 x i8]
store i32 %0, i32* %3
store double** %1, double*** %4
%10 = call i32 @AppendDebugTraceFile(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* %3
%12 = load i32, i32* %3
%13 = mul nsw i32 %11, %12
%14 = sitofp i32 %13 to double
store double %14, double* %8
%15 = load double, double* %8
%16 = call i32 @floor(double %15)
store i32 %16, i32* %7
%17 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%18 = load i32, i32* %3
%19 = load i32, i32* %7
%20 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %19)
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%22 = call i32 @AppendDebugTraceFile(i8* %21)
%23 = load i32, i32* %7
%24 = call i64 @calloc(i32 %23, i32 8)
%25 = inttoptr i64 %24 to double*
%26 = load double**, double*** %4
store double* %25, double** %26
store i32 0, i32* %6
br label %27
27: ; preds = %76, %2
%28 = load i32, i32* %6
%29 = load i32, i32* %3
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %79
31: ; preds = %27
store i32 0, i32* %5
br label %32
32: ; preds = %72, %31
%33 = load i32, i32* %5
%34 = load i32, i32* %3
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %75
36: ; preds = %32
%37 = load double**, double*** %4
%38 = load double*, double** %37
%39 = load i32, i32* %6
%40 = load i32, i32* %3
%41 = mul nsw i32 %39, %40
%42 = load i32, i32* %5
%43 = add nsw i32 %41, %42
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %38, i64 %44
store double 0.000000e+00, double* %45
%46 = load i32, i32* %6
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %58
48: ; preds = %36
%49 = load double**, double*** %4
%50 = load double*, double** %49
%51 = load i32, i32* %6
%52 = load i32, i32* %3
%53 = mul nsw i32 %51, %52
%54 = load i32, i32* %5
%55 = add nsw i32 %53, %54
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double, double* %50, i64 %56
store double 1.000000e+00, double* %57
br label %58
58: ; preds = %48, %36
%59 = load i32, i32* %5
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %71
61: ; preds = %58
%62 = load double**, double*** %4
%63 = load double*, double** %62
%64 = load i32, i32* %6
%65 = load i32, i32* %3
%66 = mul nsw i32 %64, %65
%67 = load i32, i32* %5
%68 = add nsw i32 %66, %67
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds double, double* %63, i64 %69
store double 1.000000e+00, double* %70
br label %71
71: ; preds = %61, %58
br label %72
72: ; preds = %71
%73 = load i32, i32* %5
%74 = add nsw i32 %73, 1
store i32 %74, i32* %5
br label %32
75: ; preds = %32
br label %76
76: ; preds = %75
%77 = load i32, i32* %6
%78 = add nsw i32 %77, 1
store i32 %78, i32* %6
br label %27
79: ; preds = %27
%80 = call i32 @AppendDebugTraceFile(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"Default_RelConnectionCost start\0A\00"
@.str.1 = [55 x i8] c"Default_RelConnectionCost iZoneCount %i iArraySize %i\0A\00"
@.str.2 = [31 x i8] c"Default_RelConnectionCost end\0A\00"
define void @Default_RelConnectionCost(i32 %0, double** nocapture %1) {
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @AppendDebugTraceFile(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%6 = mul nsw i32 %0, %0
%7 = sitofp i32 %6 to double
%8 = tail call i32 @floor(double %7)
%9 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 %8)
%10 = call i32 @AppendDebugTraceFile(i8* %4)
%11 = call i64 @calloc(i32 %8, i32 8)
%12 = inttoptr i64 %11 to double*
store double* %12, double** %1
%13 = icmp sgt i32 %0, 0
br i1 %13, label %14, label %52
14: ; preds = %2
%15 = zext i32 %0 to i64
%16 = zext i32 %0 to i64
%17 = and i64 %16, 1
%18 = icmp eq i32 %0, 1
%19 = and i64 %16, 4294967294
%20 = icmp eq i64 %17, 0
br label %21
21: ; preds = %49, %14
%22 = phi i64 [ 0, %14 ], [ %50, %49 ]
%23 = mul nsw i64 %22, %15
%24 = icmp eq i64 %22, 0
br i1 %18, label %41, label %25
25: ; preds = %21
%26 = select i1 %24, double 1.000000e+00, double 0.000000e+00
br label %27
27: ; preds = %27, %25
%28 = phi i64 [ 0, %25 ], [ %38, %27 ]
%29 = phi i64 [ 0, %25 ], [ %39, %27 ]
%30 = add nuw nsw i64 %28, %23
%31 = getelementptr inbounds double, double* %12, i64 %30
%32 = icmp eq i64 %28, 0
%33 = select i1 %32, i1 true, i1 %24
%34 = select i1 %33, double 1.000000e+00, double 0.000000e+00
store double %34, double* %31
%35 = or i64 %28, 1
%36 = add nuw nsw i64 %35, %23
%37 = getelementptr inbounds double, double* %12, i64 %36
store double %26, double* %37
%38 = add nuw nsw i64 %28, 2
%39 = add i64 %29, 2
%40 = icmp eq i64 %39, %19
br i1 %40, label %41, label %27
41: ; preds = %27, %21
%42 = phi i64 [ 0, %21 ], [ %38, %27 ]
br i1 %20, label %49, label %43
43: ; preds = %41
%44 = add nuw nsw i64 %42, %23
%45 = getelementptr inbounds double, double* %12, i64 %44
%46 = icmp eq i64 %42, 0
%47 = select i1 %46, i1 true, i1 %24
%48 = select i1 %47, double 1.000000e+00, double 0.000000e+00
store double %48, double* %45
br label %49
49: ; preds = %41, %43
%50 = add nuw nsw i64 %22, 1
%51 = icmp eq i64 %50, %16
br i1 %51, label %52, label %21
52: ; preds = %49, %2
%53 = call i32 @AppendDebugTraceFile(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
ret void
}