; 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.px_pad_t = type { i32, i32, i32, i32 }

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

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 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 = { 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 = !{!11, !7, i64 0}
!11 = !{!"px_pad_t", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12}
!12 = !{!11, !7, i64 4}
!13 = !{!7, !7, i64 0}
!14 = !{!6, !7, i64 0}
!15 = !{!11, !7, i64 8}
!16 = !{!11, !7, i64 12}


; 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: nounwind uwtable
define dso_local i64 @get_pooling_out_size(i64 %0, i64 %1, i64 %2, i64 %3, i64 %4) local_unnamed_addr #1 {
  %.sroa.06.0.extract.trunc = trunc i64 %0 to i32
  %.sroa.27.0.extract.shift = lshr i64 %0, 32
  %.sroa.27.0.extract.trunc = trunc nuw i64 %.sroa.27.0.extract.shift to i32
  %.sroa.04.0.extract.trunc = trunc i64 %1 to i32
  %.sroa.25.0.extract.shift = lshr i64 %1, 32
  %.sroa.25.0.extract.trunc = trunc nuw i64 %.sroa.25.0.extract.shift to i32
  %.sroa.1.0.extract.shift = lshr i64 %2, 32
  %.sroa.1.0.extract.trunc = trunc nuw i64 %.sroa.1.0.extract.shift to i32
  %.sroa.0.0.extract.trunc = trunc i64 %3 to i32
  %.sroa.2.0.extract.shift = lshr i64 %3, 32
  %.sroa.2.0.extract.trunc = trunc nuw i64 %.sroa.2.0.extract.shift to i32
  %.sroa.3.8.extract.trunc = trunc i64 %4 to i32
  %.sroa.5.8.extract.shift = lshr i64 %4, 32
  %.sroa.5.8.extract.trunc = trunc nuw i64 %.sroa.5.8.extract.shift to i32
  %6 = sub i32 %.sroa.27.0.extract.trunc, %.sroa.25.0.extract.trunc
  %7 = add nsw i32 %6, %.sroa.0.0.extract.trunc
  %8 = add nsw i32 %7, %.sroa.2.0.extract.trunc
  %9 = sdiv i32 %8, %.sroa.1.0.extract.trunc
  %10 = add nsw i32 %9, 1
  %11 = sub i32 %.sroa.06.0.extract.trunc, %.sroa.04.0.extract.trunc
  %12 = add nsw i32 %11, %.sroa.3.8.extract.trunc
  %13 = add nsw i32 %12, %.sroa.5.8.extract.trunc
  %14 = sdiv i32 %13, %.sroa.1.0.extract.trunc
  %15 = add nsw i32 %14, 1
  %16 = tail call i64 @px_create_size(i32 noundef %10, i32 noundef %15) #2
  ret i64 %16
}

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 = { 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 = { 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)"}


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