; LLVM IR from scemama/slaterlib :: src (core)

; 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.excitation_operator_t = type { [2 x i32], [2 x i32], i32, i32 }

; 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: nounwind uwtable
declare dso_local i32 @get_holes_particles(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @get_nperm_single(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @get_nperm_double(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @exc_op_of_det_pair(ptr dead_on_unwind noalias writable sret(%struct.excitation_operator_t) align 4 %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store i32 %1, ptr %5, align 4, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !9
  store ptr %3, ptr %7, align 8, !tbaa !9
  %9 = load i32, ptr %5, align 4, !tbaa !5
  %10 = zext i32 %9 to i64
  %11 = load i32, ptr %5, align 4, !tbaa !5
  %12 = zext i32 %11 to i64
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %13 = load i32, ptr %5, align 4, !tbaa !5
  %14 = load ptr, ptr %6, align 8, !tbaa !9
  %15 = load ptr, ptr %7, align 8, !tbaa !9
  %16 = getelementptr inbounds %struct.excitation_operator_t, ptr %0, i32 0, i32 0
  %17 = getelementptr inbounds [2 x i32], ptr %16, i64 0, i64 0
  %18 = getelementptr inbounds %struct.excitation_operator_t, ptr %0, i32 0, i32 1
  %19 = getelementptr inbounds [2 x i32], ptr %18, i64 0, i64 0
  %20 = call i32 @get_holes_particles(i32 noundef %13, ptr noundef %14, ptr noundef %15, ptr noundef %17, ptr noundef %19)
  %21 = getelementptr inbounds %struct.excitation_operator_t, ptr %0, i32 0, i32 2
  store i32 %20, ptr %21, align 4, !tbaa !11
  store i32 0, ptr %8, align 4, !tbaa !5
  %22 = getelementptr inbounds %struct.excitation_operator_t, ptr %0, i32 0, i32 2
  %23 = load i32, ptr %22, align 4, !tbaa !11
  switch i32 %23, label %42 [
    i32 2, label %24
    i32 1, label %33
  ]

24:                                               ; preds = %4
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = load ptr, ptr %6, align 8, !tbaa !9
  %27 = load ptr, ptr %7, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct.excitation_operator_t, ptr %0, i32 0, i32 0
  %29 = getelementptr inbounds [2 x i32], ptr %28, i64 0, i64 0
  %30 = getelementptr inbounds %struct.excitation_operator_t, ptr %0, i32 0, i32 1
  %31 = getelementptr inbounds [2 x i32], ptr %30, i64 0, i64 0
  %32 = call i32 @get_nperm_double(i32 noundef %25, ptr noundef %26, ptr noundef %27, ptr noundef %29, ptr noundef %31)
  store i32 %32, ptr %8, align 4, !tbaa !5
  br label %42

33:                                               ; preds = %4
  %34 = load i32, ptr %5, align 4, !tbaa !5
  %35 = load ptr, ptr %6, align 8, !tbaa !9
  %36 = load ptr, ptr %7, align 8, !tbaa !9
  %37 = getelementptr inbounds %struct.excitation_operator_t, ptr %0, i32 0, i32 0
  %38 = getelementptr inbounds [2 x i32], ptr %37, i64 0, i64 0
  %39 = getelementptr inbounds %struct.excitation_operator_t, ptr %0, i32 0, i32 1
  %40 = getelementptr inbounds [2 x i32], ptr %39, i64 0, i64 0
  %41 = call i32 @get_nperm_single(i32 noundef %34, ptr noundef %35, ptr noundef %36, ptr noundef %38, ptr noundef %40)
  store i32 %41, ptr %8, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %33, %24, %4
  %43 = load i32, ptr %8, align 4, !tbaa !5
  %44 = and i32 1, %43
  %45 = getelementptr inbounds %struct.excitation_operator_t, ptr %0, i32 0, i32 3
  store i32 %44, ptr %45, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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)"}
!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 16}
!12 = !{!"", !7, i64 0, !7, i64 8, !6, i64 16, !6, i64 20}
!13 = !{!12, !6, i64 20}


; 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.excitation_operator_t = type { [2 x i32], [2 x i32], i32, i32 }

; Function Attrs: nounwind uwtable
declare dso_local i32 @get_holes_particles(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @get_nperm_single(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @get_nperm_double(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @exc_op_of_det_pair(ptr dead_on_unwind noalias writable sret(%struct.excitation_operator_t) align 4 %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = tail call i32 @get_holes_particles(i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %0, ptr noundef nonnull %5)
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %6, ptr %7, align 4, !tbaa !5
  switch i32 %6, label %12 [
    i32 2, label %8
    i32 1, label %10
  ]

8:                                                ; preds = %4
  %9 = tail call i32 @get_nperm_double(i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef nonnull %0, ptr noundef nonnull %5)
  br label %12

10:                                               ; preds = %4
  %11 = tail call i32 @get_nperm_single(i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef nonnull %0, ptr noundef nonnull %5)
  br label %12

12:                                               ; preds = %10, %8, %4
  %.0 = phi i32 [ 0, %4 ], [ %11, %10 ], [ %9, %8 ]
  %13 = and i32 %.0, 1
  %14 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 %13, ptr %14, align 4, !tbaa !10
  ret void
}

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

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


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