; LLVM IR from alexzheng42/sDMD :: src (SGThread)

; 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.EventListStr = type { i32, ptr, ptr, ptr }
%struct.AtomListStr = type { i32, [27 x i32], [27 x i32], [27 x i32], double, ptr, ptr, ptr }
%struct.AtomStr = type { ptr, ptr }
%struct.DynamicStr = type { [4 x i32], [4 x double], [4 x double], %struct.HBStr, %struct.HBNeighborStr, %struct.InteractionEventStr }
%struct.HBStr = type { i32, i32, i8, i32 }
%struct.HBNeighborStr = type { [5 x i32], i32, i32 }
%struct.InteractionEventStr = type { i32, i64, i64, double, double, i32, i32 }

@CBT = external global %struct.EventListStr, align 8

; Function Attrs: nounwind uwtable
define dso_local void @AssignJob(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %9 = load ptr, ptr %7, align 8, !tbaa !5
  %10 = getelementptr inbounds i32, ptr %9, i64 0
  store i32 1, ptr %10, align 4, !tbaa !9
  %11 = load ptr, ptr %7, align 8, !tbaa !5
  %12 = getelementptr inbounds i32, ptr %11, i64 1
  store i32 0, ptr %12, align 4, !tbaa !9
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = getelementptr inbounds i32, ptr %13, i64 2
  store i32 0, ptr %14, align 4, !tbaa !9
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = getelementptr inbounds i32, ptr %15, i64 3
  store i32 0, ptr %16, align 4, !tbaa !9
  %17 = load ptr, ptr getelementptr inbounds (%struct.EventListStr, ptr @CBT, i32 0, i32 1), align 8, !tbaa !11
  %18 = getelementptr inbounds i32, ptr %17, i64 1
  %19 = load i32, ptr %18, align 4, !tbaa !9
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.AtomListStr, ptr %20, i32 0, i32 0
  store i32 %19, ptr %21, align 8, !tbaa !13
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.AtomListStr, ptr %22, i32 0, i32 7
  %24 = load ptr, ptr %23, align 8, !tbaa !16
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.AtomListStr, ptr %25, i32 0, i32 0
  %27 = load i32, ptr %26, align 8, !tbaa !13
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds ptr, ptr %24, i64 %28
  %30 = load ptr, ptr %29, align 8, !tbaa !5
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.AtomListStr, ptr %31, i32 0, i32 5
  store ptr %30, ptr %32, align 8, !tbaa !17
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.AtomListStr, ptr %33, i32 0, i32 5
  %35 = load ptr, ptr %34, align 8, !tbaa !17
  %36 = getelementptr inbounds %struct.AtomStr, ptr %35, i32 0, i32 1
  %37 = load ptr, ptr %36, align 8, !tbaa !18
  %38 = getelementptr inbounds %struct.DynamicStr, ptr %37, i32 0, i32 5
  %39 = getelementptr inbounds %struct.InteractionEventStr, ptr %38, i32 0, i32 3
  %40 = load double, ptr %39, align 8, !tbaa !20
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.AtomListStr, ptr %41, i32 0, i32 4
  store double %40, ptr %42, align 8, !tbaa !26
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.AtomListStr, ptr %43, i32 0, i32 0
  %45 = load i32, ptr %44, align 8, !tbaa !13
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = getelementptr inbounds i32, ptr %46, i64 1
  store i32 %45, ptr %47, align 4, !tbaa !9
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.AtomListStr, ptr %48, i32 0, i32 5
  %50 = load ptr, ptr %49, align 8, !tbaa !17
  %51 = getelementptr inbounds %struct.AtomStr, ptr %50, i32 0, i32 1
  %52 = load ptr, ptr %51, align 8, !tbaa !18
  %53 = getelementptr inbounds %struct.DynamicStr, ptr %52, i32 0, i32 5
  %54 = getelementptr inbounds %struct.InteractionEventStr, ptr %53, i32 0, i32 0
  %55 = load i32, ptr %54, align 8, !tbaa !27
  %56 = icmp sgt i32 %55, 0
  br i1 %56, label %57, label %89

57:                                               ; preds = %4
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.AtomListStr, ptr %58, i32 0, i32 7
  %60 = load ptr, ptr %59, align 8, !tbaa !16
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.AtomListStr, ptr %61, i32 0, i32 5
  %63 = load ptr, ptr %62, align 8, !tbaa !17
  %64 = getelementptr inbounds %struct.AtomStr, ptr %63, i32 0, i32 1
  %65 = load ptr, ptr %64, align 8, !tbaa !18
  %66 = getelementptr inbounds %struct.DynamicStr, ptr %65, i32 0, i32 5
  %67 = getelementptr inbounds %struct.InteractionEventStr, ptr %66, i32 0, i32 0
  %68 = load i32, ptr %67, align 8, !tbaa !27
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds ptr, ptr %60, i64 %69
  %71 = load ptr, ptr %70, align 8, !tbaa !5
  %72 = load ptr, ptr %8, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.AtomListStr, ptr %72, i32 0, i32 6
  store ptr %71, ptr %73, align 8, !tbaa !28
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.AtomListStr, ptr %74, i32 0, i32 5
  %76 = load ptr, ptr %75, align 8, !tbaa !17
  %77 = getelementptr inbounds %struct.AtomStr, ptr %76, i32 0, i32 1
  %78 = load ptr, ptr %77, align 8, !tbaa !18
  %79 = getelementptr inbounds %struct.DynamicStr, ptr %78, i32 0, i32 5
  %80 = getelementptr inbounds %struct.InteractionEventStr, ptr %79, i32 0, i32 0
  %81 = load i32, ptr %80, align 8, !tbaa !27
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  %84 = getelementptr inbounds i32, ptr %83, i64 0
  %85 = load i32, ptr %84, align 4, !tbaa !9
  %86 = add nsw i32 %85, 1
  store i32 %86, ptr %84, align 4, !tbaa !9
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds i32, ptr %82, i64 %87
  store i32 %81, ptr %88, align 4, !tbaa !9
  br label %92

89:                                               ; preds = %4
  %90 = load ptr, ptr %8, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.AtomListStr, ptr %90, i32 0, i32 6
  store ptr null, ptr %91, align 8, !tbaa !28
  br label %92

92:                                               ; preds = %89, %57
  %93 = load ptr, ptr %8, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.AtomListStr, ptr %93, i32 0, i32 5
  %95 = load ptr, ptr %94, align 8, !tbaa !17
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %95, ptr %96, align 8, !tbaa !5
  %97 = load ptr, ptr %8, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.AtomListStr, ptr %97, i32 0, i32 6
  %99 = load ptr, ptr %98, align 8, !tbaa !28
  %100 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %99, ptr %100, align 8, !tbaa !5
  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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"EventListStr", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!13 = !{!14, !10, i64 0}
!14 = !{!"AtomListStr", !10, i64 0, !7, i64 4, !7, i64 112, !7, i64 220, !15, i64 328, !6, i64 336, !6, i64 344, !6, i64 352}
!15 = !{!"double", !7, i64 0}
!16 = !{!14, !6, i64 352}
!17 = !{!14, !6, i64 336}
!18 = !{!19, !6, i64 8}
!19 = !{!"AtomStr", !6, i64 0, !6, i64 8}
!20 = !{!21, !15, i64 152}
!21 = !{!"DynamicStr", !7, i64 0, !7, i64 16, !7, i64 48, !22, i64 80, !23, i64 96, !24, i64 128}
!22 = !{!"HBStr", !10, i64 0, !10, i64 4, !7, i64 8, !10, i64 12}
!23 = !{!"HBNeighborStr", !7, i64 0, !10, i64 20, !10, i64 24}
!24 = !{!"InteractionEventStr", !10, i64 0, !25, i64 8, !25, i64 16, !15, i64 24, !15, i64 32, !10, i64 40, !10, i64 44}
!25 = !{!"long", !7, i64 0}
!26 = !{!14, !15, i64 328}
!27 = !{!21, !10, i64 128}
!28 = !{!14, !6, i64 344}


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

@CBT = external local_unnamed_addr global %struct.EventListStr, align 8

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @AssignJob(ptr nocapture noundef writeonly %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef %2, ptr nocapture noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %2, i64 4
  store <4 x i32> <i32 1, i32 0, i32 0, i32 0>, ptr %2, align 4, !tbaa !5
  %6 = load ptr, ptr getelementptr inbounds (i8, ptr @CBT, i64 8), align 8, !tbaa !9
  %7 = getelementptr inbounds i8, ptr %6, i64 4
  %8 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %8, ptr %3, align 8, !tbaa !12
  %9 = getelementptr inbounds i8, ptr %3, i64 352
  %10 = load ptr, ptr %9, align 8, !tbaa !15
  %11 = sext i32 %8 to i64
  %12 = getelementptr inbounds ptr, ptr %10, i64 %11
  %13 = load ptr, ptr %12, align 8, !tbaa !16
  %14 = getelementptr inbounds i8, ptr %3, i64 336
  store ptr %13, ptr %14, align 8, !tbaa !17
  %15 = getelementptr inbounds i8, ptr %13, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !18
  %17 = getelementptr inbounds i8, ptr %16, i64 152
  %18 = load double, ptr %17, align 8, !tbaa !20
  %19 = getelementptr inbounds i8, ptr %3, i64 328
  store double %18, ptr %19, align 8, !tbaa !26
  store i32 %8, ptr %5, align 4, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %16, i64 128
  %21 = load i32, ptr %20, align 8, !tbaa !27
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %23, label %31

23:                                               ; preds = %4
  %24 = zext nneg i32 %21 to i64
  %25 = getelementptr inbounds ptr, ptr %10, i64 %24
  %26 = load ptr, ptr %25, align 8, !tbaa !16
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %2, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds i32, ptr %2, i64 %29
  store i32 %21, ptr %30, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %4, %23
  %.sink = phi ptr [ %26, %23 ], [ null, %4 ]
  %32 = getelementptr inbounds i8, ptr %3, i64 344
  store ptr %.sink, ptr %32, align 8
  store ptr %13, ptr %0, align 8, !tbaa !16
  %33 = load ptr, ptr %32, align 8, !tbaa !28
  store ptr %33, ptr %1, align 8, !tbaa !16
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) 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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 8}
!10 = !{!"EventListStr", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!13, !6, i64 0}
!13 = !{!"AtomListStr", !6, i64 0, !7, i64 4, !7, i64 112, !7, i64 220, !14, i64 328, !11, i64 336, !11, i64 344, !11, i64 352}
!14 = !{!"double", !7, i64 0}
!15 = !{!13, !11, i64 352}
!16 = !{!11, !11, i64 0}
!17 = !{!13, !11, i64 336}
!18 = !{!19, !11, i64 8}
!19 = !{!"AtomStr", !11, i64 0, !11, i64 8}
!20 = !{!21, !14, i64 152}
!21 = !{!"DynamicStr", !7, i64 0, !7, i64 16, !7, i64 48, !22, i64 80, !23, i64 96, !24, i64 128}
!22 = !{!"HBStr", !6, i64 0, !6, i64 4, !7, i64 8, !6, i64 12}
!23 = !{!"HBNeighborStr", !7, i64 0, !6, i64 20, !6, i64 24}
!24 = !{!"InteractionEventStr", !6, i64 0, !25, i64 8, !25, i64 16, !14, i64 24, !14, i64 32, !6, i64 40, !6, i64 44}
!25 = !{!"long", !7, i64 0}
!26 = !{!13, !14, i64 328}
!27 = !{!21, !6, i64 128}
!28 = !{!13, !11, i64 344}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass