; 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.AtomStr = type { ptr, ptr }
%struct.PropertyStr = type { [8 x i8], [2 x [16 x i8]], [8 x i8], i32, i32, i32, double, double, [3 x double], %struct.AtomSeqStr, ptr, ptr }
%struct.AtomSeqStr = type { i32, i32, i32 }
%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 }
%struct.AtomListStr = type { i32, [27 x i32], [27 x i32], [27 x i32], double, ptr, ptr, ptr }

; 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
define dso_local i32 @HazardCheck(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.AtomStr, ptr %15, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = getelementptr inbounds %struct.PropertyStr, ptr %17, i32 0, i32 3
  %19 = load i32, ptr %18, align 8, !tbaa !11
  store i32 %19, ptr %12, align 4, !tbaa !16
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %28

22:                                               ; preds = %5
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.AtomStr, ptr %23, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  %26 = getelementptr inbounds %struct.PropertyStr, ptr %25, i32 0, i32 3
  %27 = load i32, ptr %26, align 8, !tbaa !11
  store i32 %27, ptr %13, align 4, !tbaa !16
  br label %29

28:                                               ; preds = %5
  store i32 0, ptr %13, align 4, !tbaa !16
  br label %29

29:                                               ; preds = %28, %22
  %30 = load i32, ptr %13, align 4, !tbaa !16
  %31 = icmp sgt i32 %30, 0
  br i1 %31, label %32, label %73

32:                                               ; preds = %29
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.AtomStr, ptr %33, i32 0, i32 1
  %35 = load ptr, ptr %34, align 8, !tbaa !17
  %36 = getelementptr inbounds %struct.DynamicStr, ptr %35, i32 0, i32 5
  %37 = getelementptr inbounds %struct.InteractionEventStr, ptr %36, i32 0, i32 2
  %38 = load i64, ptr %37, align 8, !tbaa !18
  %39 = load ptr, ptr %11, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.AtomListStr, ptr %39, i32 0, i32 7
  %41 = load ptr, ptr %40, align 8, !tbaa !24
  %42 = load i32, ptr %13, align 4, !tbaa !16
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds ptr, ptr %41, i64 %43
  %45 = load ptr, ptr %44, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.AtomStr, ptr %45, i32 0, i32 1
  %47 = load ptr, ptr %46, align 8, !tbaa !17
  %48 = getelementptr inbounds %struct.DynamicStr, ptr %47, i32 0, i32 5
  %49 = getelementptr inbounds %struct.InteractionEventStr, ptr %48, i32 0, i32 1
  %50 = load i64, ptr %49, align 8, !tbaa !26
  %51 = icmp slt i64 %38, %50
  br i1 %51, label %72, label %52

52:                                               ; preds = %32
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.AtomStr, ptr %53, i32 0, i32 1
  %55 = load ptr, ptr %54, align 8, !tbaa !17
  %56 = getelementptr inbounds %struct.DynamicStr, ptr %55, i32 0, i32 5
  %57 = getelementptr inbounds %struct.InteractionEventStr, ptr %56, i32 0, i32 1
  %58 = load i64, ptr %57, align 8, !tbaa !26
  %59 = load ptr, ptr %11, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.AtomListStr, ptr %59, i32 0, i32 7
  %61 = load ptr, ptr %60, align 8, !tbaa !24
  %62 = load i32, ptr %13, align 4, !tbaa !16
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds ptr, ptr %61, i64 %63
  %65 = load ptr, ptr %64, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.AtomStr, ptr %65, i32 0, i32 1
  %67 = load ptr, ptr %66, align 8, !tbaa !17
  %68 = getelementptr inbounds %struct.DynamicStr, ptr %67, i32 0, i32 5
  %69 = getelementptr inbounds %struct.InteractionEventStr, ptr %68, i32 0, i32 1
  %70 = load i64, ptr %69, align 8, !tbaa !26
  %71 = icmp slt i64 %58, %70
  br i1 %71, label %72, label %73

72:                                               ; preds = %52, %32
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %115

73:                                               ; preds = %52, %29
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.AtomStr, ptr %74, i32 0, i32 1
  %76 = load ptr, ptr %75, align 8, !tbaa !17
  %77 = getelementptr inbounds %struct.DynamicStr, ptr %76, i32 0, i32 5
  %78 = getelementptr inbounds %struct.InteractionEventStr, ptr %77, i32 0, i32 1
  %79 = load i64, ptr %78, align 8, !tbaa !26
  %80 = load ptr, ptr %11, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.AtomListStr, ptr %80, i32 0, i32 7
  %82 = load ptr, ptr %81, align 8, !tbaa !24
  %83 = load i32, ptr %12, align 4, !tbaa !16
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds ptr, ptr %82, i64 %84
  %86 = load ptr, ptr %85, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.AtomStr, ptr %86, i32 0, i32 1
  %88 = load ptr, ptr %87, align 8, !tbaa !17
  %89 = getelementptr inbounds %struct.DynamicStr, ptr %88, i32 0, i32 5
  %90 = getelementptr inbounds %struct.InteractionEventStr, ptr %89, i32 0, i32 1
  %91 = load i64, ptr %90, align 8, !tbaa !26
  %92 = icmp slt i64 %79, %91
  br i1 %92, label %113, label %93

93:                                               ; preds = %73
  %94 = load ptr, ptr %7, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.AtomStr, ptr %94, i32 0, i32 1
  %96 = load ptr, ptr %95, align 8, !tbaa !17
  %97 = getelementptr inbounds %struct.DynamicStr, ptr %96, i32 0, i32 5
  %98 = getelementptr inbounds %struct.InteractionEventStr, ptr %97, i32 0, i32 0
  %99 = load i32, ptr %98, align 8, !tbaa !27
  %100 = load ptr, ptr %11, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.AtomListStr, ptr %100, i32 0, i32 7
  %102 = load ptr, ptr %101, align 8, !tbaa !24
  %103 = load i32, ptr %12, align 4, !tbaa !16
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds ptr, ptr %102, i64 %104
  %106 = load ptr, ptr %105, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.AtomStr, ptr %106, i32 0, i32 1
  %108 = load ptr, ptr %107, align 8, !tbaa !17
  %109 = getelementptr inbounds %struct.DynamicStr, ptr %108, i32 0, i32 5
  %110 = getelementptr inbounds %struct.InteractionEventStr, ptr %109, i32 0, i32 0
  %111 = load i32, ptr %110, align 8, !tbaa !27
  %112 = icmp ne i32 %99, %111
  br i1 %112, label %113, label %114

113:                                              ; preds = %93, %73
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %115

114:                                              ; preds = %93
  store i32 0, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %115

115:                                              ; preds = %114, %113, %72
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  %116 = load i32, ptr %6, align 4
  ret i32 %116
}

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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"AtomStr", !6, i64 0, !6, i64 8}
!11 = !{!12, !13, i64 48}
!12 = !{!"PropertyStr", !7, i64 0, !7, i64 8, !7, i64 40, !13, i64 48, !13, i64 52, !13, i64 56, !14, i64 64, !14, i64 72, !7, i64 80, !15, i64 104, !6, i64 120, !6, i64 128}
!13 = !{!"int", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!"AtomSeqStr", !13, i64 0, !13, i64 4, !13, i64 8}
!16 = !{!13, !13, i64 0}
!17 = !{!10, !6, i64 8}
!18 = !{!19, !23, i64 144}
!19 = !{!"DynamicStr", !7, i64 0, !7, i64 16, !7, i64 48, !20, i64 80, !21, i64 96, !22, i64 128}
!20 = !{!"HBStr", !13, i64 0, !13, i64 4, !7, i64 8, !13, i64 12}
!21 = !{!"HBNeighborStr", !7, i64 0, !13, i64 20, !13, i64 24}
!22 = !{!"InteractionEventStr", !13, i64 0, !23, i64 8, !23, i64 16, !14, i64 24, !14, i64 32, !13, i64 40, !13, i64 44}
!23 = !{!"long", !7, i64 0}
!24 = !{!25, !6, i64 352}
!25 = !{!"AtomListStr", !13, i64 0, !7, i64 4, !7, i64 112, !7, i64 220, !14, i64 328, !6, i64 336, !6, i64 344, !6, i64 352}
!26 = !{!19, !23, i64 136}
!27 = !{!19, !13, i64 128}


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local range(i32 -1, 1) i32 @HazardCheck(ptr nocapture noundef readonly %0, ptr noundef readonly %1, ptr nocapture noundef readnone %2, ptr nocapture noundef readnone %3, ptr nocapture noundef readonly %4) local_unnamed_addr #0 {
  %6 = load ptr, ptr %0, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 48
  %8 = load i32, ptr %7, align 8, !tbaa !10
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %.thread, label %9

9:                                                ; preds = %5
  %10 = load ptr, ptr %1, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %10, i64 48
  %12 = load i32, ptr %11, align 8, !tbaa !10
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %14, label %.thread

14:                                               ; preds = %9
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !15
  %17 = getelementptr inbounds i8, ptr %16, i64 144
  %18 = load i64, ptr %17, align 8, !tbaa !16
  %19 = getelementptr inbounds i8, ptr %4, i64 352
  %20 = load ptr, ptr %19, align 8, !tbaa !22
  %21 = zext nneg i32 %12 to i64
  %22 = getelementptr inbounds ptr, ptr %20, i64 %21
  %23 = load ptr, ptr %22, align 8, !tbaa !24
  %24 = getelementptr inbounds i8, ptr %23, i64 8
  %25 = load ptr, ptr %24, align 8, !tbaa !15
  %26 = getelementptr inbounds i8, ptr %25, i64 136
  %27 = load i64, ptr %26, align 8, !tbaa !25
  %28 = icmp slt i64 %18, %27
  br i1 %28, label %54, label %29

29:                                               ; preds = %14
  %30 = getelementptr inbounds i8, ptr %1, i64 8
  %31 = load ptr, ptr %30, align 8, !tbaa !15
  %32 = getelementptr inbounds i8, ptr %31, i64 136
  %33 = load i64, ptr %32, align 8, !tbaa !25
  %34 = icmp slt i64 %33, %27
  br i1 %34, label %54, label %.thread

.thread:                                          ; preds = %5, %29, %9
  %35 = getelementptr inbounds i8, ptr %0, i64 8
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  %37 = getelementptr inbounds i8, ptr %36, i64 136
  %38 = load i64, ptr %37, align 8, !tbaa !25
  %39 = getelementptr inbounds i8, ptr %4, i64 352
  %40 = load ptr, ptr %39, align 8, !tbaa !22
  %41 = sext i32 %8 to i64
  %42 = getelementptr inbounds ptr, ptr %40, i64 %41
  %43 = load ptr, ptr %42, align 8, !tbaa !24
  %44 = getelementptr inbounds i8, ptr %43, i64 8
  %45 = load ptr, ptr %44, align 8, !tbaa !15
  %46 = getelementptr inbounds i8, ptr %45, i64 136
  %47 = load i64, ptr %46, align 8, !tbaa !25
  %48 = icmp slt i64 %38, %47
  br i1 %48, label %54, label %49

49:                                               ; preds = %.thread
  %50 = getelementptr inbounds i8, ptr %45, i64 128
  %51 = getelementptr inbounds i8, ptr %36, i64 128
  %52 = load i32, ptr %51, align 8, !tbaa !26
  %53 = load i32, ptr %50, align 8, !tbaa !26
  %.not19 = icmp ne i32 %52, %53
  %spec.select = sext i1 %.not19 to i32
  br label %54

54:                                               ; preds = %49, %.thread, %14, %29
  %.016 = phi i32 [ -1, %29 ], [ -1, %14 ], [ -1, %.thread ], [ %spec.select, %49 ]
  ret i32 %.016
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, 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, !7, i64 0}
!6 = !{!"AtomStr", !7, i64 0, !7, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !12, i64 48}
!11 = !{!"PropertyStr", !8, i64 0, !8, i64 8, !8, i64 40, !12, i64 48, !12, i64 52, !12, i64 56, !13, i64 64, !13, i64 72, !8, i64 80, !14, i64 104, !7, i64 120, !7, i64 128}
!12 = !{!"int", !8, i64 0}
!13 = !{!"double", !8, i64 0}
!14 = !{!"AtomSeqStr", !12, i64 0, !12, i64 4, !12, i64 8}
!15 = !{!6, !7, i64 8}
!16 = !{!17, !21, i64 144}
!17 = !{!"DynamicStr", !8, i64 0, !8, i64 16, !8, i64 48, !18, i64 80, !19, i64 96, !20, i64 128}
!18 = !{!"HBStr", !12, i64 0, !12, i64 4, !8, i64 8, !12, i64 12}
!19 = !{!"HBNeighborStr", !8, i64 0, !12, i64 20, !12, i64 24}
!20 = !{!"InteractionEventStr", !12, i64 0, !21, i64 8, !21, i64 16, !13, i64 24, !13, i64 32, !12, i64 40, !12, i64 44}
!21 = !{!"long", !8, i64 0}
!22 = !{!23, !7, i64 352}
!23 = !{!"AtomListStr", !12, i64 0, !8, i64 4, !8, i64 112, !8, i64 220, !13, i64 328, !7, i64 336, !7, i64 344, !7, i64 352}
!24 = !{!7, !7, i64 0}
!25 = !{!17, !21, i64 136}
!26 = !{!17, !12, i64 128}


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