#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ die(char *, ...);
float **load_2d_float_array(int *, int *, int /*<<< orphan*/ *);
char **load_strings(int *, int /*<<< orphan*/ *);
float **load_distance_matrix(int *dims_ptr, char ***labels_ptr, FILE *fp) {
  int dim1, dim2;
  float **matrix = load_2d_float_array(&dim1, &dim2, fp);
  if (dim1 != dim2)
    die("load_distance_matrix: Distance matrix is not square\n");
  *dims_ptr = dim1;
  *labels_ptr = load_strings(&dim1, fp);
  if (dim1 != *dims_ptr)
    die("load_distance_matrix: List of labels (%d) not same size as matrix "
        "(%d)",
        dim1, dim2);
  return matrix;
}


x86 assembly (clang, -O0):
<load_distance_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <load_2d_float_array@plt>
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
je     1173 <load_distance_matrix+0x43>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1040 <die@plt>
mov    -0x1c(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdi
call   1030 <load_strings@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x1c(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%eax
je     11b6 <load_distance_matrix+0x86>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1040 <die@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_distance_matrix>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r12
mov    %rsp,%rdi
lea    0x4(%rsp),%rsi
call   1050 <load_2d_float_array@plt>
mov    %rax,%r14
mov    (%rsp),%eax
cmp    0x4(%rsp),%eax
je     116b <load_distance_matrix+0x3b>
lea    0xe9f(%rip),%rdi
xor    %eax,%eax
call   1040 <die@plt>
mov    (%rsp),%eax
mov    %eax,(%r12)
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1030 <load_strings@plt>
mov    %rax,(%r15)
mov    (%rsp),%esi
cmp    (%r12),%esi
je     1198 <load_distance_matrix+0x68>
mov    0x4(%rsp),%edx
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1040 <die@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [53 x i8] c"load_distance_matrix: Distance matrix is not square\0A\00"
@.str.1 = [71 x i8] c"load_distance_matrix: List of labels (%d) not same size as matrix (%d)\00"
define float** @load_distance_matrix(i32* %0, i8*** %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i8***
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca float**
store i32* %0, i32** %4
store i8*** %1, i8**** %5
store i32* %2, i32** %6
%10 = load i32*, i32** %6
%11 = call float** @load_2d_float_array(i32* %7, i32* %8, i32* %10)
store float** %11, float*** %9
%12 = load i32, i32* %7
%13 = load i32, i32* %8
%14 = icmp ne i32 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %3
%18 = load i32, i32* %7
%19 = load i32*, i32** %4
store i32 %18, i32* %19
%20 = load i32*, i32** %6
%21 = call i8** @load_strings(i32* %7, i32* %20)
%22 = load i8***, i8**** %5
store i8** %21, i8*** %22
%23 = load i32, i32* %7
%24 = load i32*, i32** %4
%25 = load i32, i32* %24
%26 = icmp ne i32 %23, %25
br i1 %26, label %27, label %31
27: ; preds = %17
%28 = load i32, i32* %7
%29 = load i32, i32* %8
%30 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0), i32 %28, i32 %29)
br label %31
31: ; preds = %27, %17
%32 = load float**, float*** %9
ret float** %32
}

LLVM IR (-O2):
@.str = [53 x i8] c"load_distance_matrix: Distance matrix is not square\0A\00"
@.str.1 = [71 x i8] c"load_distance_matrix: List of labels (%d) not same size as matrix (%d)\00"
define float** @load_distance_matrix(i32* nocapture %0, i8*** nocapture writeonly %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %4 to i8*
%7 = bitcast i32* %5 to i8*
%8 = call float** @load_2d_float_array(i32* %4, i32* %5, i32* %2)
%9 = load i32, i32* %4
%10 = load i32, i32* %5
%11 = icmp eq i32 %9, %10
br i1 %11, label %15, label %12
12: ; preds = %3
%13 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* %4
br label %15
15: ; preds = %12, %3
%16 = phi i32 [ %14, %12 ], [ %9, %3 ]
store i32 %16, i32* %0
%17 = call i8** @load_strings(i32* %4, i32* %2)
store i8** %17, i8*** %1
%18 = load i32, i32* %4
%19 = load i32, i32* %0
%20 = icmp eq i32 %18, %19
br i1 %20, label %24, label %21
21: ; preds = %15
%22 = load i32, i32* %5
%23 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %22)
br label %24
24: ; preds = %21, %15
ret float** %8
}