#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 *, int, int, double, double);
void zgemm_print_matrix(int M, int K, double *A) {
  int i, j;
  double *ap = A;
  for (i = 0; i < M; i++) {
    for (j = 0; j < K; j++) {
      printf("%d,%d:	%f\t%f\n", i, j, ap[0], ap[1]);
      ap += 2;
    }
  }
}


x86 assembly (clang, -O0):
<zgemm_print_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a0 <zgemm_print_matrix+0x90>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    118d <zgemm_print_matrix+0x7d>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm1
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1144 <zgemm_print_matrix+0x34>
jmp    1192 <zgemm_print_matrix+0x82>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1131 <zgemm_print_matrix+0x21>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zgemm_print_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    1174 <zgemm_print_matrix+0x64>
mov    %rdx,%rbx
mov    %esi,%r15d
mov    %edi,%r14d
xor    %r13d,%r13d
lea    0xece(%rip),%r12
jmp    1149 <zgemm_print_matrix+0x39>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r13d
cmp    %r14d,%r13d
je     1174 <zgemm_print_matrix+0x64>
test   %r15d,%r15d
jle    1140 <zgemm_print_matrix+0x30>
xor    %ebp,%ebp
movsd  (%rbx),%xmm0
movsd  0x8(%rbx),%xmm1
mov    %r12,%rdi
mov    %r13d,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
add    $0x10,%rbx
add    $0x1,%ebp
cmp    %ebp,%r15d
jne    1150 <zgemm_print_matrix+0x40>
jmp    1140 <zgemm_print_matrix+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"%d,%d:\09%f\09%f\0A\00"
define void @zgemm_print_matrix(i32 %0, i32 %1, double* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca double*
store i32 %0, i32* %4
store i32 %1, i32* %5
store double* %2, double** %6
%10 = load double*, double** %6
store double* %10, double** %9
store i32 0, i32* %7
br label %11
11: ; preds = %36, %3
%12 = load i32, i32* %7
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %39
15: ; preds = %11
store i32 0, i32* %8
br label %16
16: ; preds = %32, %15
%17 = load i32, i32* %8
%18 = load i32, i32* %5
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %35
20: ; preds = %16
%21 = load i32, i32* %7
%22 = load i32, i32* %8
%23 = load double*, double** %9
%24 = getelementptr inbounds double, double* %23, i64 0
%25 = load double, double* %24
%26 = load double*, double** %9
%27 = getelementptr inbounds double, double* %26, i64 1
%28 = load double, double* %27
%29 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %22, double %25, double %28)
%30 = load double*, double** %9
%31 = getelementptr inbounds double, double* %30, i64 2
store double* %31, double** %9
br label %32
32: ; preds = %20
%33 = load i32, i32* %8
%34 = add nsw i32 %33, 1
store i32 %34, i32* %8
br label %16
35: ; preds = %16
br label %36
36: ; preds = %35
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %11
39: ; preds = %11
ret void
}

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