; LLVM IR from zchrissirhcz/pixel :: src (px_convolution)

; 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_conv_param_t = type { i32, i32, i32, i32, i32, i32 }
%struct.px_size_t = type { i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local i64 @px_get_conv_output_matrix_dim(i64 %0, i64 %1, ptr noundef byval(%struct.px_conv_param_t) align 8 %2) #0 {
  %4 = alloca %struct.px_size_t, align 4
  %5 = alloca %struct.px_size_t, align 4
  %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 i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store i64 %0, ptr %5, align 4
  store i64 %1, ptr %6, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %15 = getelementptr inbounds %struct.px_size_t, ptr %5, i32 0, i32 1
  %16 = load i32, ptr %15, align 4, !tbaa !5
  store i32 %16, ptr %7, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %17 = getelementptr inbounds %struct.px_size_t, ptr %5, i32 0, i32 0
  %18 = load i32, ptr %17, align 4, !tbaa !11
  store i32 %18, ptr %8, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %19 = getelementptr inbounds %struct.px_size_t, ptr %6, i32 0, i32 1
  %20 = load i32, ptr %19, align 4, !tbaa !5
  store i32 %20, ptr %9, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %21 = getelementptr inbounds %struct.px_size_t, ptr %6, i32 0, i32 0
  %22 = load i32, ptr %21, align 4, !tbaa !11
  store i32 %22, ptr %10, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %23 = getelementptr inbounds %struct.px_conv_param_t, ptr %2, i32 0, i32 0
  %24 = load i32, ptr %23, align 8, !tbaa !12
  store i32 %24, ptr %11, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %25 = getelementptr inbounds %struct.px_conv_param_t, ptr %2, i32 0, i32 1
  %26 = load i32, ptr %25, align 4, !tbaa !14
  store i32 %26, ptr %12, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %27 = load i32, ptr %7, align 4, !tbaa !10
  %28 = load i32, ptr %9, align 4, !tbaa !10
  %29 = sub nsw i32 %27, %28
  %30 = load i32, ptr %11, align 4, !tbaa !10
  %31 = sdiv i32 %29, %30
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %13, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %33 = load i32, ptr %8, align 4, !tbaa !10
  %34 = load i32, ptr %10, align 4, !tbaa !10
  %35 = sub nsw i32 %33, %34
  %36 = load i32, ptr %12, align 4, !tbaa !10
  %37 = sdiv i32 %35, %36
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %14, align 4, !tbaa !10
  call void @llvm.memset.p0.i64(ptr align 4 %4, i8 0, i64 8, i1 false)
  %39 = load i32, ptr %13, align 4, !tbaa !10
  %40 = getelementptr inbounds %struct.px_size_t, ptr %4, i32 0, i32 1
  store i32 %39, ptr %40, align 4, !tbaa !5
  %41 = load i32, ptr %14, align 4, !tbaa !10
  %42 = getelementptr inbounds %struct.px_size_t, ptr %4, i32 0, i32 0
  store i32 %41, ptr %42, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  %43 = load i64, ptr %4, align 4
  ret i64 %43
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 4}
!6 = !{!"px_size_t", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!7, !7, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!13, !7, i64 0}
!13 = !{!"px_conv_param_t", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20}
!14 = !{!13, !7, i64 4}


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

%struct.px_conv_param_t = type { i32, i32, i32, i32, i32, i32 }

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i64 @px_get_conv_output_matrix_dim(i64 %0, i64 %1, ptr nocapture noundef readonly byval(%struct.px_conv_param_t) align 8 %2) local_unnamed_addr #0 {
  %.sroa.08.0.extract.trunc = trunc i64 %0 to i32
  %.sroa.29.0.extract.shift = lshr i64 %0, 32
  %.sroa.29.0.extract.trunc = trunc nuw i64 %.sroa.29.0.extract.shift to i32
  %.sroa.0.0.extract.trunc = trunc i64 %1 to i32
  %.sroa.2.0.extract.shift = lshr i64 %1, 32
  %.sroa.2.0.extract.trunc = trunc nuw i64 %.sroa.2.0.extract.shift to i32
  %4 = load i32, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %2, i64 4
  %6 = load i32, ptr %5, align 4, !tbaa !10
  %7 = sub nsw i32 %.sroa.29.0.extract.trunc, %.sroa.2.0.extract.trunc
  %8 = sdiv i32 %7, %4
  %9 = add nsw i32 %8, 1
  %10 = sub nsw i32 %.sroa.08.0.extract.trunc, %.sroa.0.0.extract.trunc
  %11 = sdiv i32 %10, %6
  %12 = add nsw i32 %11, 1
  %.sroa.3.0.insert.ext = zext i32 %9 to i64
  %.sroa.3.0.insert.shift = shl nuw i64 %.sroa.3.0.insert.ext, 32
  %.sroa.010.0.insert.ext = zext i32 %12 to i64
  %.sroa.010.0.insert.insert = or disjoint i64 %.sroa.3.0.insert.shift, %.sroa.010.0.insert.ext
  ret i64 %.sroa.010.0.insert.insert
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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" }

!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 = !{!"px_conv_param_t", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 4}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass