#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_vector_norm(char *desc, int m, int n, double *a, int lda) {
  int i, j;
  double norm;
  printf("\n %s\n", desc);
  for (j = 0; j < n; j++) {
    norm = 0.0;
    for (i = 0; i < m; i++)
      norm += a[i + j * lda] * a[i + j * lda];
    printf(" %6.2f", norm);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_vector_norm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11db <print_vector_norm+0xcb>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ba <print_vector_norm+0xaa>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%edx
imul   -0x1c(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%edx
imul   -0x1c(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    115e <print_vector_norm+0x4e>
movsd  -0x30(%rbp),%xmm0
lea    0xe40(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1143 <print_vector_norm+0x33>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_vector_norm>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,%r14d
mov    %rcx,%rbx
mov    %edx,%r15d
mov    %esi,0x4(%rsp)
mov    %rdi,%rsi
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r15d,%r15d
jle    125b <print_vector_norm+0x13b>
movslq %r14d,%r13
mov    %r15d,%eax
mov    %rax,0x10(%rsp)
mov    0x4(%rsp),%r14d
lea    -0x1(%r14),%rax
mov    %rax,0x8(%rsp)
mov    %r14d,%ebp
and    $0x3,%ebp
and    $0xfffffffc,%r14d
lea    0x18(%rbx),%r12
shl    $0x3,%r13
xor    %r15d,%r15d
jmp    11b7 <print_vector_norm+0x97>
cs nopw 0x0(%rax,%rax,1)
nop
xorpd  %xmm0,%xmm0
lea    0xe6b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%r15
add    %r13,%r12
add    %r13,%rbx
cmp    0x10(%rsp),%r15
je     125b <print_vector_norm+0x13b>
cmpl   $0x0,0x4(%rsp)
jle    1190 <print_vector_norm+0x70>
cmpq   $0x3,0x8(%rsp)
jae    11d0 <print_vector_norm+0xb0>
xorpd  %xmm0,%xmm0
xor    %eax,%eax
jmp    1224 <print_vector_norm+0x104>
xchg   %ax,%ax
xorpd  %xmm0,%xmm0
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
movsd  -0x18(%r12,%rax,8),%xmm1
movsd  -0x10(%r12,%rax,8),%xmm2
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
mulsd  %xmm2,%xmm2
addsd  %xmm1,%xmm2
movsd  -0x8(%r12,%rax,8),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm2,%xmm1
movsd  (%r12,%rax,8),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
add    $0x4,%rax
cmp    %rax,%r14
jne    11e0 <print_vector_norm+0xc0>
test   %rbp,%rbp
je     1194 <print_vector_norm+0x74>
lea    (%rbx,%rax,8),%rax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm1,%xmm0
add    $0x1,%rcx
cmp    %rcx,%rbp
jne    1240 <print_vector_norm+0x120>
jmp    1194 <print_vector_norm+0x74>
mov    $0xa,%edi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str = [6 x i8] c"\0A %s\0A\00"
@.str.1 = [7 x i8] c" %6.2f\00"
define void @print_vector_norm(i8* %0, i32 %1, i32 %2, double* nocapture %3, i32 %4) {
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0)
%7 = icmp sgt i32 %2, 0
br i1 %7, label %8, label %68
8: ; preds = %5
%9 = icmp sgt i32 %1, 0
%10 = sext i32 %4 to i64
%11 = zext i32 %2 to i64
%12 = zext i32 %1 to i64
%13 = add nsw i64 %12, -1
%14 = and i64 %12, 3
%15 = icmp ult i64 %13, 3
%16 = and i64 %12, 4294967292
%17 = icmp eq i64 %14, 0
br label %18
18: ; preds = %8, %63
%19 = phi i64 [ 0, %8 ], [ %66, %63 ]
br i1 %9, label %20, label %63
20: ; preds = %18
%21 = mul nsw i64 %19, %10
br i1 %15, label %48, label %22
22: ; preds = %20, %22
%23 = phi i64 [ %45, %22 ], [ 0, %20 ]
%24 = phi double [ %44, %22 ], [ 0.000000e+00, %20 ]
%25 = phi i64 [ %46, %22 ], [ 0, %20 ]
%26 = add nsw i64 %23, %21
%27 = getelementptr inbounds double, double* %3, i64 %26
%28 = load double, double* %27
%29 = tail call double @llvm.fmuladd.f64(double %28, double %28, double %24)
%30 = or i64 %23, 1
%31 = add nsw i64 %30, %21
%32 = getelementptr inbounds double, double* %3, i64 %31
%33 = load double, double* %32
%34 = tail call double @llvm.fmuladd.f64(double %33, double %33, double %29)
%35 = or i64 %23, 2
%36 = add nsw i64 %35, %21
%37 = getelementptr inbounds double, double* %3, i64 %36
%38 = load double, double* %37
%39 = tail call double @llvm.fmuladd.f64(double %38, double %38, double %34)
%40 = or i64 %23, 3
%41 = add nsw i64 %40, %21
%42 = getelementptr inbounds double, double* %3, i64 %41
%43 = load double, double* %42
%44 = tail call double @llvm.fmuladd.f64(double %43, double %43, double %39)
%45 = add nuw nsw i64 %23, 4
%46 = add i64 %25, 4
%47 = icmp eq i64 %46, %16
br i1 %47, label %48, label %22
48: ; preds = %22, %20
%49 = phi double [ undef, %20 ], [ %44, %22 ]
%50 = phi i64 [ 0, %20 ], [ %45, %22 ]
%51 = phi double [ 0.000000e+00, %20 ], [ %44, %22 ]
br i1 %17, label %63, label %52
52: ; preds = %48, %52
%53 = phi i64 [ %60, %52 ], [ %50, %48 ]
%54 = phi double [ %59, %52 ], [ %51, %48 ]
%55 = phi i64 [ %61, %52 ], [ 0, %48 ]
%56 = add nsw i64 %53, %21
%57 = getelementptr inbounds double, double* %3, i64 %56
%58 = load double, double* %57
%59 = tail call double @llvm.fmuladd.f64(double %58, double %58, double %54)
%60 = add nuw nsw i64 %53, 1
%61 = add i64 %55, 1
%62 = icmp eq i64 %61, %14
br i1 %62, label %63, label %52
63: ; preds = %48, %52, %18
%64 = phi double [ 0.000000e+00, %18 ], [ %49, %48 ], [ %59, %52 ]
%65 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %64)
%66 = add nuw nsw i64 %19, 1
%67 = icmp eq i64 %66, %11
br i1 %67, label %68, label %18
68: ; preds = %63, %5
%69 = tail call i32 @putchar(i32 10)
ret void
}