; LLVM IR from zchrissirhcz/pixel :: src (px_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_matrix_t = type { ptr, i32, i32 }

@.str.1 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [42 x i8], align 1
@__PRETTY_FUNCTION__.px_matrix_add_matrix = external hidden unnamed_addr constant [61 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [54 x i8], align 1

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

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @px_matrix_add_matrix(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %15

11:                                               ; preds = %2
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %15

14:                                               ; preds = %11
  br label %16

15:                                               ; preds = %11, %2
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 81, ptr noundef @__PRETTY_FUNCTION__.px_matrix_add_matrix) #3
  unreachable

16:                                               ; preds = %14
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.px_matrix_t, ptr %17, i32 0, i32 1
  %19 = load i32, ptr %18, align 8, !tbaa !9
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.px_matrix_t, ptr %20, i32 0, i32 1
  %22 = load i32, ptr %21, align 8, !tbaa !9
  %23 = icmp eq i32 %19, %22
  br i1 %23, label %24, label %33

24:                                               ; preds = %16
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.px_matrix_t, ptr %25, i32 0, i32 2
  %27 = load i32, ptr %26, align 4, !tbaa !12
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.px_matrix_t, ptr %28, i32 0, i32 2
  %30 = load i32, ptr %29, align 4, !tbaa !12
  %31 = icmp eq i32 %27, %30
  br i1 %31, label %32, label %33

32:                                               ; preds = %24
  br label %34

33:                                               ; preds = %24, %16
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 82, ptr noundef @__PRETTY_FUNCTION__.px_matrix_add_matrix) #3
  unreachable

34:                                               ; preds = %32
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.px_matrix_t, ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !13
  %38 = icmp ne ptr %37, null
  br i1 %38, label %39, label %45

39:                                               ; preds = %34
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.px_matrix_t, ptr %40, i32 0, i32 0
  %42 = load ptr, ptr %41, align 8, !tbaa !13
  %43 = icmp ne ptr %42, null
  br i1 %43, label %44, label %45

44:                                               ; preds = %39
  br label %46

45:                                               ; preds = %39, %34
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 83, ptr noundef @__PRETTY_FUNCTION__.px_matrix_add_matrix) #3
  unreachable

46:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !14
  br label %47

47:                                               ; preds = %89, %46
  %48 = load i32, ptr %5, align 4, !tbaa !14
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.px_matrix_t, ptr %49, i32 0, i32 1
  %51 = load i32, ptr %50, align 8, !tbaa !9
  %52 = icmp slt i32 %48, %51
  br i1 %52, label %54, label %53

53:                                               ; preds = %47
  store i32 2, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %92

54:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !14
  br label %55

55:                                               ; preds = %85, %54
  %56 = load i32, ptr %7, align 4, !tbaa !14
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.px_matrix_t, ptr %57, i32 0, i32 2
  %59 = load i32, ptr %58, align 4, !tbaa !12
  %60 = icmp slt i32 %56, %59
  br i1 %60, label %62, label %61

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

62:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %63 = load i32, ptr %5, align 4, !tbaa !14
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.px_matrix_t, ptr %64, i32 0, i32 2
  %66 = load i32, ptr %65, align 4, !tbaa !12
  %67 = mul nsw i32 %63, %66
  %68 = load i32, ptr %7, align 4, !tbaa !14
  %69 = add nsw i32 %67, %68
  store i32 %69, ptr %8, align 4, !tbaa !14
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.px_matrix_t, ptr %70, i32 0, i32 0
  %72 = load ptr, ptr %71, align 8, !tbaa !13
  %73 = load i32, ptr %8, align 4, !tbaa !14
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds float, ptr %72, i64 %74
  %76 = load float, ptr %75, align 4, !tbaa !15
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.px_matrix_t, ptr %77, i32 0, i32 0
  %79 = load ptr, ptr %78, align 8, !tbaa !13
  %80 = load i32, ptr %8, align 4, !tbaa !14
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds float, ptr %79, i64 %81
  %83 = load float, ptr %82, align 4, !tbaa !15
  %84 = fadd float %83, %76
  store float %84, ptr %82, align 4, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %85

85:                                               ; preds = %62
  %86 = load i32, ptr %7, align 4, !tbaa !14
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %7, align 4, !tbaa !14
  br label %55, !llvm.loop !17

88:                                               ; preds = %61
  br label %89

89:                                               ; preds = %88
  %90 = load i32, ptr %5, align 4, !tbaa !14
  %91 = add nsw i32 %90, 1
  store i32 %91, ptr %5, align 4, !tbaa !14
  br label %47, !llvm.loop !19

92:                                               ; preds = %53
  ret i32 0
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #2 = { 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 #3 = { noreturn nounwind }
attributes #4 = { 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 8}
!10 = !{!"px_matrix_t", !6, i64 0, !11, i64 8, !11, i64 12}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 12}
!13 = !{!10, !6, i64 0}
!14 = !{!11, !11, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


; 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"

@.str.1 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [42 x i8], align 1
@__PRETTY_FUNCTION__.px_matrix_add_matrix = external hidden unnamed_addr constant [61 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [54 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @px_matrix_add_matrix(ptr noundef readonly %0, ptr noundef readonly %1) local_unnamed_addr #1 {
  %3 = icmp ne ptr %0, null
  %4 = icmp ne ptr %1, null
  %or.cond = and i1 %3, %4
  br i1 %or.cond, label %6, label %5

5:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 81, ptr noundef nonnull @__PRETTY_FUNCTION__.px_matrix_add_matrix) #2
  unreachable

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load i32, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = load i32, ptr %9, align 8, !tbaa !5
  %11 = icmp eq i32 %8, %10
  br i1 %11, label %12, label %18

12:                                               ; preds = %6
  %13 = getelementptr inbounds i8, ptr %0, i64 12
  %14 = load i32, ptr %13, align 4, !tbaa !11
  %15 = getelementptr inbounds i8, ptr %1, i64 12
  %16 = load i32, ptr %15, align 4, !tbaa !11
  %17 = icmp eq i32 %14, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %12, %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 82, ptr noundef nonnull @__PRETTY_FUNCTION__.px_matrix_add_matrix) #2
  unreachable

19:                                               ; preds = %12
  %20 = load ptr, ptr %0, align 8, !tbaa !12
  %.not = icmp eq ptr %20, null
  br i1 %.not, label %57, label %21

21:                                               ; preds = %19
  %22 = load ptr, ptr %1, align 8, !tbaa !12
  %.not25 = icmp eq ptr %22, null
  br i1 %.not25, label %57, label %.preheader26

.preheader26:                                     ; preds = %21
  %23 = icmp sgt i32 %8, 0
  %24 = icmp sgt i32 %14, 0
  %or.cond37 = and i1 %23, %24
  br i1 %or.cond37, label %.preheader.us.preheader, label %._crit_edge29

.preheader.us.preheader:                          ; preds = %.preheader26
  %25 = zext nneg i32 %14 to i64
  %wide.trip.count35 = zext nneg i32 %8 to i64
  %26 = mul nuw nsw i64 %wide.trip.count35, %25
  %27 = shl nuw i64 %26, 2
  %scevgep = getelementptr i8, ptr %20, i64 %27
  %scevgep38 = getelementptr i8, ptr %22, i64 %27
  %min.iters.check = icmp ult i32 %14, 8
  %bound0 = icmp ult ptr %20, %scevgep38
  %bound1 = icmp ult ptr %22, %scevgep
  %found.conflict = and i1 %bound0, %bound1
  %n.vec = and i64 %25, 2147483640
  %cmp.n = icmp eq i64 %n.vec, %25
  %xtraiter = and i64 %25, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  %28 = add nsw i64 %25, -1
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us
  %indvars.iv32 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next33, %._crit_edge.us ]
  %29 = mul nuw nsw i64 %indvars.iv32, %25
  %brmerge = select i1 %min.iters.check, i1 true, i1 %found.conflict
  br i1 %brmerge, label %scalar.ph.preheader, label %vector.body

vector.body:                                      ; preds = %.preheader.us, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %.preheader.us ]
  %30 = add nuw nsw i64 %index, %29
  %31 = getelementptr inbounds float, ptr %22, i64 %30
  %32 = getelementptr inbounds i8, ptr %31, i64 16
  %wide.load = load <4 x float>, ptr %31, align 4, !tbaa !13, !alias.scope !15
  %wide.load39 = load <4 x float>, ptr %32, align 4, !tbaa !13, !alias.scope !15
  %33 = getelementptr inbounds float, ptr %20, i64 %30
  %34 = getelementptr inbounds i8, ptr %33, i64 16
  %wide.load40 = load <4 x float>, ptr %33, align 4, !tbaa !13, !alias.scope !18, !noalias !15
  %wide.load41 = load <4 x float>, ptr %34, align 4, !tbaa !13, !alias.scope !18, !noalias !15
  %35 = fadd <4 x float> %wide.load, %wide.load40
  %36 = fadd <4 x float> %wide.load39, %wide.load41
  store <4 x float> %35, ptr %33, align 4, !tbaa !13, !alias.scope !18, !noalias !15
  store <4 x float> %36, ptr %34, align 4, !tbaa !13, !alias.scope !18, !noalias !15
  %index.next = add nuw i64 %index, 8
  %37 = icmp eq i64 %index.next, %n.vec
  br i1 %37, label %middle.block, label %vector.body, !llvm.loop !20

middle.block:                                     ; preds = %vector.body
  br i1 %cmp.n, label %._crit_edge.us, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %.preheader.us, %middle.block
  %indvars.iv.ph = phi i64 [ 0, %.preheader.us ], [ %n.vec, %middle.block ]
  br i1 %lcmp.mod.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol

scalar.ph.prol:                                   ; preds = %scalar.ph.preheader
  %38 = add nuw nsw i64 %indvars.iv.ph, %29
  %39 = getelementptr inbounds float, ptr %22, i64 %38
  %40 = load float, ptr %39, align 4, !tbaa !13
  %41 = getelementptr inbounds float, ptr %20, i64 %38
  %42 = load float, ptr %41, align 4, !tbaa !13
  %43 = fadd float %40, %42
  store float %43, ptr %41, align 4, !tbaa !13
  %indvars.iv.next.prol = or disjoint i64 %indvars.iv.ph, 1
  br label %scalar.ph.prol.loopexit

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %scalar.ph.preheader ], [ %indvars.iv.next.prol, %scalar.ph.prol ]
  %44 = icmp eq i64 %indvars.iv.ph, %28
  br i1 %44, label %._crit_edge.us, label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %scalar.ph ], [ %indvars.iv.unr, %scalar.ph.prol.loopexit ]
  %45 = add nuw nsw i64 %indvars.iv, %29
  %46 = getelementptr inbounds float, ptr %22, i64 %45
  %47 = load float, ptr %46, align 4, !tbaa !13
  %48 = getelementptr inbounds float, ptr %20, i64 %45
  %49 = load float, ptr %48, align 4, !tbaa !13
  %50 = fadd float %47, %49
  store float %50, ptr %48, align 4, !tbaa !13
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %51 = add nuw nsw i64 %indvars.iv.next, %29
  %52 = getelementptr inbounds float, ptr %22, i64 %51
  %53 = load float, ptr %52, align 4, !tbaa !13
  %54 = getelementptr inbounds float, ptr %20, i64 %51
  %55 = load float, ptr %54, align 4, !tbaa !13
  %56 = fadd float %53, %55
  store float %56, ptr %54, align 4, !tbaa !13
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, %25
  br i1 %exitcond.not.1, label %._crit_edge.us, label %scalar.ph, !llvm.loop !24

._crit_edge.us:                                   ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block
  %indvars.iv.next33 = add nuw nsw i64 %indvars.iv32, 1
  %exitcond36.not = icmp eq i64 %indvars.iv.next33, %wide.trip.count35
  br i1 %exitcond36.not, label %._crit_edge29, label %.preheader.us, !llvm.loop !25

57:                                               ; preds = %21, %19
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 83, ptr noundef nonnull @__PRETTY_FUNCTION__.px_matrix_add_matrix) #2
  unreachable

._crit_edge29:                                    ; preds = %._crit_edge.us, %.preheader26
  ret i32 0
}

attributes #0 = { noreturn 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 #1 = { 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 #2 = { noreturn 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, !10, i64 8}
!6 = !{!"px_matrix_t", !7, i64 0, !10, i64 8, !10, i64 12}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 12}
!12 = !{!6, !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !8, i64 0}
!15 = !{!16}
!16 = distinct !{!16, !17}
!17 = distinct !{!17, !"LVerDomain"}
!18 = !{!19}
!19 = distinct !{!19, !17}
!20 = distinct !{!20, !21, !22, !23}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!"llvm.loop.isvectorized", i32 1}
!23 = !{!"llvm.loop.unroll.runtime.disable"}
!24 = distinct !{!24, !21, !22}
!25 = distinct !{!25, !21}


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