#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*/ printf(char *, ...);
void print_distances(const char *name, double *buffer, int m, int n) {
  int j;
  printf("%s\n", name);
  for (j = 0; j < m; ++j) {
    int i;
    double *buffer_m = buffer + n * j;
    for (i = 0; i < n - 1; ++i)
      printf("%f ", buffer_m[i]);
    if (n > 0)
      printf("%f\n", buffer_m[n - 1]);
  }
}


x86 assembly (clang, -O0):
<print_distances>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11e2 <print_distances+0xd2>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11a5 <print_distances+0x95>
mov    -0x28(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe74(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    116b <print_distances+0x5b>
cmpl   $0x0,-0x18(%rbp)
jle    11cf <print_distances+0xbf>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe40(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    11d4 <print_distances+0xc4>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113f <print_distances+0x2f>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_distances>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %rsi,0x8(%rsp)
call   1030 <puts@plt>
test   %r12d,%r12d
jle    11e5 <print_distances+0xc5>
lea    -0x1(%r15),%ebx
movslq %r15d,%rax
mov    %r12d,%ecx
mov    %rcx,0x20(%rsp)
mov    %rax,0x10(%rsp)
lea    0x0(,%rax,8),%rax
mov    %rax,0x18(%rsp)
xor    %ebp,%ebp
lea    0xe8f(%rip),%r13
mov    0x8(%rsp),%r12
jmp    1190 <print_distances+0x70>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
add    0x18(%rsp),%r12
cmp    0x20(%rsp),%rbp
je     11e5 <print_distances+0xc5>
cmp    $0x2,%r15d
jl     11b9 <print_distances+0x99>
xor    %r14d,%r14d
nopl   0x0(%rax)
movsd  (%r12,%r14,8),%xmm0
mov    %r13,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%r14
cmp    %r14,%rbx
jne    11a0 <print_distances+0x80>
test   %r15d,%r15d
jle    1180 <print_distances+0x60>
mov    %rbp,%rax
imul   0x10(%rsp),%rax
mov    0x8(%rsp),%rcx
lea    (%rcx,%rax,8),%rax
movsd  (%rax,%rbx,8),%xmm0
lea    0xe28(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1180 <print_distances+0x60>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [4 x i8] c"%f \00"
@.str.2 = [4 x i8] c"%f\0A\00"
define void @print_distances(i8* %0, double* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double*
store i8* %0, i8** %5
store double* %1, double** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%12 = load i8*, i8** %5
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %12)
store i32 0, i32* %9
br label %14
14: ; preds = %52, %4
%15 = load i32, i32* %9
%16 = load i32, i32* %7
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %55
18: ; preds = %14
%19 = load double*, double** %6
%20 = load i32, i32* %8
%21 = load i32, i32* %9
%22 = mul nsw i32 %20, %21
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %19, i64 %23
store double* %24, double** %11
store i32 0, i32* %10
br label %25
25: ; preds = %37, %18
%26 = load i32, i32* %10
%27 = load i32, i32* %8
%28 = sub nsw i32 %27, 1
%29 = icmp slt i32 %26, %28
br i1 %29, label %30, label %40
30: ; preds = %25
%31 = load double*, double** %11
%32 = load i32, i32* %10
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
%35 = load double, double* %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %35)
br label %37
37: ; preds = %30
%38 = load i32, i32* %10
%39 = add nsw i32 %38, 1
store i32 %39, i32* %10
br label %25
40: ; preds = %25
%41 = load i32, i32* %8
%42 = icmp sgt i32 %41, 0
br i1 %42, label %43, label %51
43: ; preds = %40
%44 = load double*, double** %11
%45 = load i32, i32* %8
%46 = sub nsw i32 %45, 1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %44, i64 %47
%49 = load double, double* %48
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %49)
br label %51
51: ; preds = %43, %40
br label %52
52: ; preds = %51
%53 = load i32, i32* %9
%54 = add nsw i32 %53, 1
store i32 %54, i32* %9
br label %14
55: ; preds = %14
ret void
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%f \00"
@.str.2 = [4 x i8] c"%f\0A\00"
define void @print_distances(i8* nocapture %0, double* nocapture %1, i32 %2, i32 %3) {
%5 = tail call i32 @puts(i8* dereferenceable(1) %0)
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %33
7: ; preds = %4
%8 = add i32 %3, -1
%9 = icmp sgt i32 %3, 1
%10 = icmp sgt i32 %3, 0
%11 = zext i32 %8 to i64
%12 = sext i32 %3 to i64
%13 = zext i32 %2 to i64
br label %14
14: ; preds = %7, %30
%15 = phi i64 [ 0, %7 ], [ %31, %30 ]
%16 = mul nsw i64 %15, %12
%17 = getelementptr inbounds double, double* %1, i64 %16
br i1 %9, label %18, label %25
18: ; preds = %14, %18
%19 = phi i64 [ %23, %18 ], [ 0, %14 ]
%20 = getelementptr inbounds double, double* %17, i64 %19
%21 = load double, double* %20
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %21)
%23 = add nuw nsw i64 %19, 1
%24 = icmp eq i64 %23, %11
br i1 %24, label %25, label %18
25: ; preds = %18, %14
br i1 %10, label %26, label %30
26: ; preds = %25
%27 = getelementptr inbounds double, double* %17, i64 %11
%28 = load double, double* %27
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %28)
br label %30
30: ; preds = %26, %25
%31 = add nuw nsw i64 %15, 1
%32 = icmp eq i64 %31, %13
br i1 %32, label %33, label %14
33: ; preds = %30, %4
ret void
}