; LLVM IR from zchrissirhcz/pixel :: legacy/NaiveCNN/cnn (cnn)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.px_size_t = type { i32, i32 }
%struct.InnerproductLayer = type { i32, i32, ptr, ptr, ptr, ptr, ptr, i8 }
%struct.matrix_t = type { i32, i32, ptr }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare i64 @px_create_size(i32 noundef, i32 noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

; Function Attrs: nounwind
declare void @srand(i32 noundef) #3

; Function Attrs: nounwind
declare i64 @time(ptr noundef) #3

; Function Attrs: nounwind
declare i32 @rand() #3

; Function Attrs: nounwind
declare double @sqrt(double noundef) #3

declare ptr @create_array(i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @init_innerproduct_layer(i32 noundef %0, i32 noundef %1) #4 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca %struct.px_size_t, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca float, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %11 = call noalias ptr @malloc(i64 noundef 56) #6
  store ptr %11, ptr %5, align 8, !tbaa !9
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = load ptr, ptr %5, align 8, !tbaa !9
  %14 = getelementptr inbounds %struct.InnerproductLayer, ptr %13, i32 0, i32 0
  store i32 %12, ptr %14, align 8, !tbaa !11
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = load ptr, ptr %5, align 8, !tbaa !9
  %17 = getelementptr inbounds %struct.InnerproductLayer, ptr %16, i32 0, i32 1
  store i32 %15, ptr %17, align 4, !tbaa !14
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = call ptr @create_array(i32 noundef %18)
  %20 = load ptr, ptr %5, align 8, !tbaa !9
  %21 = getelementptr inbounds %struct.InnerproductLayer, ptr %20, i32 0, i32 3
  store ptr %19, ptr %21, align 8, !tbaa !15
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = call ptr @create_array(i32 noundef %22)
  %24 = load ptr, ptr %5, align 8, !tbaa !9
  %25 = getelementptr inbounds %struct.InnerproductLayer, ptr %24, i32 0, i32 6
  store ptr %23, ptr %25, align 8, !tbaa !16
  %26 = load i32, ptr %4, align 4, !tbaa !5
  %27 = call ptr @create_array(i32 noundef %26)
  %28 = load ptr, ptr %5, align 8, !tbaa !9
  %29 = getelementptr inbounds %struct.InnerproductLayer, ptr %28, i32 0, i32 4
  store ptr %27, ptr %29, align 8, !tbaa !17
  %30 = load i32, ptr %4, align 4, !tbaa !5
  %31 = call ptr @create_array(i32 noundef %30)
  %32 = load ptr, ptr %5, align 8, !tbaa !9
  %33 = getelementptr inbounds %struct.InnerproductLayer, ptr %32, i32 0, i32 5
  store ptr %31, ptr %33, align 8, !tbaa !18
  %34 = load ptr, ptr %5, align 8, !tbaa !9
  %35 = getelementptr inbounds %struct.InnerproductLayer, ptr %34, i32 0, i32 3
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  call void @clear_array(ptr noundef %36)
  %37 = load ptr, ptr %5, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.InnerproductLayer, ptr %37, i32 0, i32 6
  %39 = load ptr, ptr %38, align 8, !tbaa !16
  call void @clear_array(ptr noundef %39)
  %40 = load ptr, ptr %5, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct.InnerproductLayer, ptr %40, i32 0, i32 4
  %42 = load ptr, ptr %41, align 8, !tbaa !17
  call void @clear_array(ptr noundef %42)
  %43 = load ptr, ptr %5, align 8, !tbaa !9
  %44 = getelementptr inbounds %struct.InnerproductLayer, ptr %43, i32 0, i32 5
  %45 = load ptr, ptr %44, align 8, !tbaa !18
  call void @clear_array(ptr noundef %45)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %46 = load i32, ptr %4, align 4, !tbaa !5
  %47 = load i32, ptr %3, align 4, !tbaa !5
  %48 = call i64 @px_create_size(i32 noundef %46, i32 noundef %47)
  store i64 %48, ptr %6, align 4
  %49 = load i64, ptr %6, align 4
  %50 = call ptr @create_matrix(i64 %49)
  %51 = load ptr, ptr %5, align 8, !tbaa !9
  %52 = getelementptr inbounds %struct.InnerproductLayer, ptr %51, i32 0, i32 2
  store ptr %50, ptr %52, align 8, !tbaa !19
  %53 = call i64 @time(ptr noundef null) #5
  %54 = trunc i64 %53 to i32
  call void @srand(i32 noundef %54) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %55

55:                                               ; preds = %101, %2
  %56 = load i32, ptr %7, align 4, !tbaa !5
  %57 = load i32, ptr %4, align 4, !tbaa !5
  %58 = icmp slt i32 %56, %57
  br i1 %58, label %60, label %59

59:                                               ; preds = %55
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %104

60:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %97, %60
  %62 = load i32, ptr %9, align 4, !tbaa !5
  %63 = load i32, ptr %3, align 4, !tbaa !5
  %64 = icmp slt i32 %62, %63
  br i1 %64, label %66, label %65

65:                                               ; preds = %61
  store i32 5, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %100

66:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %67 = call i32 @rand() #5
  %68 = sitofp i32 %67 to float
  %69 = fdiv float %68, 0x41E0000000000000
  %70 = fpext float %69 to double
  %71 = fsub double %70, 5.000000e-01
  %72 = fmul double %71, 2.000000e+00
  %73 = fptrunc double %72 to float
  store float %73, ptr %10, align 4, !tbaa !20
  %74 = load float, ptr %10, align 4, !tbaa !20
  %75 = fpext float %74 to double
  %76 = load i32, ptr %3, align 4, !tbaa !5
  %77 = load i32, ptr %4, align 4, !tbaa !5
  %78 = add nsw i32 %76, %77
  %79 = sitofp i32 %78 to float
  %80 = fdiv float 6.000000e+00, %79
  %81 = fpext float %80 to double
  %82 = call double @sqrt(double noundef %81) #5
  %83 = fmul double %75, %82
  %84 = fptrunc double %83 to float
  %85 = load ptr, ptr %5, align 8, !tbaa !9
  %86 = getelementptr inbounds %struct.InnerproductLayer, ptr %85, i32 0, i32 2
  %87 = load ptr, ptr %86, align 8, !tbaa !19
  %88 = getelementptr inbounds %struct.matrix_t, ptr %87, i32 0, i32 2
  %89 = load ptr, ptr %88, align 8, !tbaa !22
  %90 = load i32, ptr %7, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds ptr, ptr %89, i64 %91
  %93 = load ptr, ptr %92, align 8, !tbaa !9
  %94 = load i32, ptr %9, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds float, ptr %93, i64 %95
  store float %84, ptr %96, align 4, !tbaa !20
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %97

97:                                               ; preds = %66
  %98 = load i32, ptr %9, align 4, !tbaa !5
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr %9, align 4, !tbaa !5
  br label %61, !llvm.loop !24

100:                                              ; preds = %65
  br label %101

101:                                              ; preds = %100
  %102 = load i32, ptr %7, align 4, !tbaa !5
  %103 = add nsw i32 %102, 1
  store i32 %103, ptr %7, align 4, !tbaa !5
  br label %55, !llvm.loop !26

104:                                              ; preds = %59
  %105 = load ptr, ptr %5, align 8, !tbaa !9
  %106 = getelementptr inbounds %struct.InnerproductLayer, ptr %105, i32 0, i32 7
  store i8 1, ptr %106, align 8, !tbaa !27
  %107 = load ptr, ptr %5, align 8, !tbaa !9
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret ptr %107
}

declare void @clear_array(ptr noundef) #1

declare ptr @create_matrix(i64) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind allocsize(0) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"InnerproductLayer", !6, i64 0, !6, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !13, i64 48}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!12, !6, i64 4}
!15 = !{!12, !10, i64 16}
!16 = !{!12, !10, i64 40}
!17 = !{!12, !10, i64 24}
!18 = !{!12, !10, i64 32}
!19 = !{!12, !10, i64 8}
!20 = !{!21, !21, i64 0}
!21 = !{!"float", !7, i64 0}
!22 = !{!23, !10, i64 8}
!23 = !{!"matrix_t", !6, i64 0, !6, i64 4, !10, i64 8}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = distinct !{!26, !25}
!27 = !{!12, !13, i64 48}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

declare i64 @px_create_size(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare void @srand(i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare i64 @time(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #3

declare ptr @create_array(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @init_innerproduct_layer(i32 noundef %0, i32 noundef %1) local_unnamed_addr #4 {
  %3 = tail call noalias dereferenceable_or_null(56) ptr @malloc(i64 noundef 56) #5
  store i32 %0, ptr %3, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 4
  store i32 %1, ptr %4, align 4, !tbaa !12
  %5 = tail call ptr @create_array(i32 noundef %1) #6
  %6 = getelementptr inbounds i8, ptr %3, i64 16
  store ptr %5, ptr %6, align 8, !tbaa !13
  %7 = tail call ptr @create_array(i32 noundef %1) #6
  %8 = getelementptr inbounds i8, ptr %3, i64 40
  store ptr %7, ptr %8, align 8, !tbaa !14
  %9 = tail call ptr @create_array(i32 noundef %1) #6
  %10 = getelementptr inbounds i8, ptr %3, i64 24
  store ptr %9, ptr %10, align 8, !tbaa !15
  %11 = tail call ptr @create_array(i32 noundef %1) #6
  %12 = getelementptr inbounds i8, ptr %3, i64 32
  store ptr %11, ptr %12, align 8, !tbaa !16
  tail call void @clear_array(ptr noundef %5) #6
  tail call void @clear_array(ptr noundef %7) #6
  tail call void @clear_array(ptr noundef %9) #6
  tail call void @clear_array(ptr noundef %11) #6
  %13 = tail call i64 @px_create_size(i32 noundef %1, i32 noundef %0) #6
  %14 = tail call ptr @create_matrix(i64 %13) #6
  %15 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr %14, ptr %15, align 8, !tbaa !17
  %16 = tail call i64 @time(ptr noundef null) #6
  %17 = trunc i64 %16 to i32
  tail call void @srand(i32 noundef %17) #6
  %18 = icmp sgt i32 %1, 0
  br i1 %18, label %.preheader.lr.ph, label %._crit_edge37

.preheader.lr.ph:                                 ; preds = %2
  %19 = icmp sgt i32 %0, 0
  %20 = add nsw i32 %1, %0
  %21 = sitofp i32 %20 to float
  %22 = fdiv float 6.000000e+00, %21
  %23 = fpext float %22 to double
  %24 = getelementptr inbounds i8, ptr %14, i64 8
  br i1 %19, label %.preheader.us.preheader, label %._crit_edge37

.preheader.us.preheader:                          ; preds = %.preheader.lr.ph
  %wide.trip.count43 = zext nneg i32 %1 to i64
  %wide.trip.count = zext nneg i32 %0 to i64
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us
  %indvars.iv40 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next41, %._crit_edge.us ]
  br label %25

25:                                               ; preds = %.preheader.us, %25
  %indvars.iv = phi i64 [ 0, %.preheader.us ], [ %indvars.iv.next, %25 ]
  %26 = tail call i32 @rand() #6
  %27 = sitofp i32 %26 to float
  %28 = fmul float %27, 0x3E00000000000000
  %29 = fpext float %28 to double
  %30 = fadd double %29, -5.000000e-01
  %31 = fmul double %30, 2.000000e+00
  %32 = fptrunc double %31 to float
  %33 = fpext float %32 to double
  %34 = tail call double @sqrt(double noundef %23) #6
  %35 = fmul double %34, %33
  %36 = fptrunc double %35 to float
  %37 = load ptr, ptr %24, align 8, !tbaa !18
  %38 = getelementptr inbounds ptr, ptr %37, i64 %indvars.iv40
  %39 = load ptr, ptr %38, align 8, !tbaa !20
  %40 = getelementptr inbounds float, ptr %39, i64 %indvars.iv
  store float %36, ptr %40, align 4, !tbaa !21
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge.us, label %25, !llvm.loop !23

._crit_edge.us:                                   ; preds = %25
  %indvars.iv.next41 = add nuw nsw i64 %indvars.iv40, 1
  %exitcond44.not = icmp eq i64 %indvars.iv.next41, %wide.trip.count43
  br i1 %exitcond44.not, label %._crit_edge37, label %.preheader.us, !llvm.loop !25

._crit_edge37:                                    ; preds = %._crit_edge.us, %.preheader.lr.ph, %2
  %41 = getelementptr inbounds i8, ptr %3, i64 48
  store i8 1, ptr %41, align 8, !tbaa !26
  ret ptr %3
}

declare void @clear_array(ptr noundef) local_unnamed_addr #0

declare ptr @create_matrix(i64) local_unnamed_addr #0

attributes #0 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nofree nounwind willreturn memory(write) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind allocsize(0) }
attributes #6 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"InnerproductLayer", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !11, i64 48}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!6, !7, i64 4}
!13 = !{!6, !10, i64 16}
!14 = !{!6, !10, i64 40}
!15 = !{!6, !10, i64 24}
!16 = !{!6, !10, i64 32}
!17 = !{!6, !10, i64 8}
!18 = !{!19, !10, i64 8}
!19 = !{!"matrix_t", !7, i64 0, !7, i64 4, !10, i64 8}
!20 = !{!10, !10, i64 0}
!21 = !{!22, !22, i64 0}
!22 = !{!"float", !8, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = distinct !{!25, !24}
!26 = !{!6, !11, i64 48}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass