#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 */
scalar_t__ my_norm(float *, int);
float *my_normalize_matrix_rows(float *p, int M, int dim) {
  float *tmp;
  int i, j;
  float d = 0;
  int dim2 = dim;
  tmp = p;
  for (i = 0; i < M; i++) {
    d = (float)my_norm(tmp, dim);
    for (j = 0; j < dim; j++) {
      tmp[j] /= d;
    }
    tmp += dim;
    for (; j < dim2; j++) {
      tmp++;
    }
  }
  return p;
}


x86 assembly (clang, -O0):
<my_normalize_matrix_rows>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11eb <my_normalize_matrix_rows+0xdb>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1030 <my_norm@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x24(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    119d <my_normalize_matrix_rows+0x8d>
movss  -0x24(%rbp),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1168 <my_normalize_matrix_rows+0x58>
mov    -0x10(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    11d8 <my_normalize_matrix_rows+0xc8>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11b2 <my_normalize_matrix_rows+0xa2>
jmp    11dd <my_normalize_matrix_rows+0xcd>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113f <my_normalize_matrix_rows+0x2f>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_normalize_matrix_rows>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,(%rsp)
test   %esi,%esi
jle    1259 <my_normalize_matrix_rows+0x149>
mov    %edx,%r13d
mov    %esi,%r15d
movslq %edx,%r12
mov    %r12d,%ebx
mov    %ebx,%eax
and    $0xfffffffc,%eax
mov    %rax,0x20(%rsp)
add    $0xfffffffffffffffc,%rax
mov    %rax,0x18(%rsp)
mov    %rax,%rcx
shr    $0x2,%rcx
add    $0x1,%rcx
mov    %rcx,%rax
mov    %rcx,0x10(%rsp)
and    $0xfffffffffffffffe,%rcx
mov    %rcx,0x8(%rsp)
shl    $0x2,%r12
xor    %r14d,%r14d
mov    (%rsp),%rbp
jmp    1190 <my_normalize_matrix_rows+0x80>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    %r12,%rbp
add    $0x1,%r14d
cmp    %r15d,%r14d
je     1259 <my_normalize_matrix_rows+0x149>
mov    %rbp,%rdi
mov    %r13d,%esi
call   1030 <my_norm@plt>
test   %r13d,%r13d
jle    1180 <my_normalize_matrix_rows+0x70>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cmp    $0x4,%r13d
jae    11c0 <my_normalize_matrix_rows+0xb0>
xor    %eax,%eax
jmp    1230 <my_normalize_matrix_rows+0x120>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movaps %xmm0,%xmm1
shufps $0x0,%xmm0,%xmm1
cmpq   $0x0,0x18(%rsp)
je     124e <my_normalize_matrix_rows+0x13e>
mov    0x8(%rsp),%rcx
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
movups 0x0(%rbp,%rax,4),%xmm2
movups 0x10(%rbp,%rax,4),%xmm3
divps  %xmm1,%xmm2
movups %xmm2,0x0(%rbp,%rax,4)
divps  %xmm1,%xmm3
movups %xmm3,0x10(%rbp,%rax,4)
add    $0x8,%rax
add    $0xfffffffffffffffe,%rcx
jne    11e0 <my_normalize_matrix_rows+0xd0>
testb  $0x1,0x10(%rsp)
je     1218 <my_normalize_matrix_rows+0x108>
movups 0x0(%rbp,%rax,4),%xmm2
divps  %xmm1,%xmm2
movups %xmm2,0x0(%rbp,%rax,4)
mov    0x20(%rsp),%rcx
mov    %rcx,%rax
cmp    %rbx,%rcx
je     1180 <my_normalize_matrix_rows+0x70>
nopl   0x0(%rax)
movss  0x0(%rbp,%rax,4),%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,0x0(%rbp,%rax,4)
add    $0x1,%rax
cmp    %rax,%rbx
jne    1230 <my_normalize_matrix_rows+0x120>
jmp    1180 <my_normalize_matrix_rows+0x70>
xor    %eax,%eax
testb  $0x1,0x10(%rsp)
jne    120b <my_normalize_matrix_rows+0xfb>
jmp    1218 <my_normalize_matrix_rows+0x108>
mov    (%rsp),%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define float* @my_normalize_matrix_rows(float* %0, i32 %1, i32 %2) {
%4 = alloca float*
%5 = alloca i32
%6 = alloca i32
%7 = alloca float*
%8 = alloca i32
%9 = alloca i32
%10 = alloca float
%11 = alloca i32
store float* %0, float** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store float 0.000000e+00, float* %10
%12 = load i32, i32* %6
store i32 %12, i32* %11
%13 = load float*, float** %4
store float* %13, float** %7
store i32 0, i32* %8
br label %14
14: ; preds = %54, %3
%15 = load i32, i32* %8
%16 = load i32, i32* %5
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %57
18: ; preds = %14
%19 = load float*, float** %7
%20 = load i32, i32* %6
%21 = call i64 @my_norm(float* %19, i32 %20)
%22 = sitofp i64 %21 to float
store float %22, float* %10
store i32 0, i32* %9
br label %23
23: ; preds = %35, %18
%24 = load i32, i32* %9
%25 = load i32, i32* %6
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %38
27: ; preds = %23
%28 = load float, float* %10
%29 = load float*, float** %7
%30 = load i32, i32* %9
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds float, float* %29, i64 %31
%33 = load float, float* %32
%34 = fdiv float %33, %28
store float %34, float* %32
br label %35
35: ; preds = %27
%36 = load i32, i32* %9
%37 = add nsw i32 %36, 1
store i32 %37, i32* %9
br label %23
38: ; preds = %23
%39 = load i32, i32* %6
%40 = load float*, float** %7
%41 = sext i32 %39 to i64
%42 = getelementptr inbounds float, float* %40, i64 %41
store float* %42, float** %7
br label %43
43: ; preds = %50, %38
%44 = load i32, i32* %9
%45 = load i32, i32* %11
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %53
47: ; preds = %43
%48 = load float*, float** %7
%49 = getelementptr inbounds float, float* %48, i32 1
store float* %49, float** %7
br label %50
50: ; preds = %47
%51 = load i32, i32* %9
%52 = add nsw i32 %51, 1
store i32 %52, i32* %9
br label %43
53: ; preds = %43
br label %54
54: ; preds = %53
%55 = load i32, i32* %8
%56 = add nsw i32 %55, 1
store i32 %56, i32* %8
br label %14
57: ; preds = %14
%58 = load float*, float** %4
ret float* %58
}

LLVM IR (-O2):
define float* @my_normalize_matrix_rows(float* returned %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %68
5: ; preds = %3
%6 = icmp sgt i32 %2, 0
%7 = sext i32 %2 to i64
%8 = zext i32 %2 to i64
%9 = and i64 %8, 4294967292
%10 = add nsw i64 %9, -4
%11 = lshr exact i64 %10, 2
%12 = add nuw nsw i64 %11, 1
%13 = icmp ult i32 %2, 4
%14 = and i64 %8, 4294967292
%15 = and i64 %12, 1
%16 = icmp eq i64 %10, 0
%17 = and i64 %12, 9223372036854775806
%18 = icmp eq i64 %15, 0
%19 = icmp eq i64 %14, %8
br label %20
20: ; preds = %5, %64
%21 = phi float* [ %0, %5 ], [ %65, %64 ]
%22 = phi i32 [ 0, %5 ], [ %66, %64 ]
%23 = tail call i64 @my_norm(float* %21, i32 %2)
%24 = sitofp i64 %23 to float
br i1 %6, label %25, label %64
25: ; preds = %20
br i1 %13, label %55, label %26
26: ; preds = %25
%27 = insertelement <4 x float> poison, float %24, i64 0
%28 = shufflevector <4 x float> %27, <4 x float> poison, <4 x i32> zeroinitializer
br i1 %16, label %46, label %29
29: ; preds = %26, %29
%30 = phi i64 [ %43, %29 ], [ 0, %26 ]
%31 = phi i64 [ %44, %29 ], [ 0, %26 ]
%32 = getelementptr inbounds float, float* %21, i64 %30
%33 = bitcast float* %32 to <4 x float>*
%34 = load <4 x float>, <4 x float>* %33
%35 = fdiv <4 x float> %34, %28
%36 = bitcast float* %32 to <4 x float>*
store <4 x float> %35, <4 x float>* %36
%37 = or i64 %30, 4
%38 = getelementptr inbounds float, float* %21, i64 %37
%39 = bitcast float* %38 to <4 x float>*
%40 = load <4 x float>, <4 x float>* %39
%41 = fdiv <4 x float> %40, %28
%42 = bitcast float* %38 to <4 x float>*
store <4 x float> %41, <4 x float>* %42
%43 = add nuw i64 %30, 8
%44 = add i64 %31, 2
%45 = icmp eq i64 %44, %17
br i1 %45, label %46, label %29
46: ; preds = %29, %26
%47 = phi i64 [ 0, %26 ], [ %43, %29 ]
br i1 %18, label %54, label %48
48: ; preds = %46
%49 = getelementptr inbounds float, float* %21, i64 %47
%50 = bitcast float* %49 to <4 x float>*
%51 = load <4 x float>, <4 x float>* %50
%52 = fdiv <4 x float> %51, %28
%53 = bitcast float* %49 to <4 x float>*
store <4 x float> %52, <4 x float>* %53
br label %54
54: ; preds = %46, %48
br i1 %19, label %64, label %55
55: ; preds = %25, %54
%56 = phi i64 [ 0, %25 ], [ %14, %54 ]
br label %57
57: ; preds = %55, %57
%58 = phi i64 [ %62, %57 ], [ %56, %55 ]
%59 = getelementptr inbounds float, float* %21, i64 %58
%60 = load float, float* %59
%61 = fdiv float %60, %24
store float %61, float* %59
%62 = add nuw nsw i64 %58, 1
%63 = icmp eq i64 %62, %8
br i1 %63, label %64, label %57
64: ; preds = %57, %54, %20
%65 = getelementptr inbounds float, float* %21, i64 %7
%66 = add nuw nsw i32 %22, 1
%67 = icmp eq i32 %66, %1
br i1 %67, label %68, label %20
68: ; preds = %64, %3
ret float* %0
}