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

; 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.AAStr = type { [5 x i8], i32, i32, i32, i32, double }
%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.ConstraintStr = type { i32, double, ptr, double, ptr }

@atom = external global ptr, align 8
@aminoacid = external global ptr, align 8
@connectionMap = external global ptr, align 8

; 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 @FindNextBondList(i32 noundef, ptr noundef, double noundef, double noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @BondDuplicate(i32 noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %8 = load ptr, ptr @aminoacid, align 8, !tbaa !9
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds %struct.AAStr, ptr %8, i64 %10
  %12 = getelementptr inbounds %struct.AAStr, ptr %11, i32 0, i32 2
  %13 = load i32, ptr %12, align 4, !tbaa !11
  store i32 %13, ptr %5, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %118, %1
  %15 = load i32, ptr %5, align 4, !tbaa !5
  %16 = load ptr, ptr @aminoacid, align 8, !tbaa !9
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds %struct.AAStr, ptr %16, i64 %18
  %20 = getelementptr inbounds %struct.AAStr, ptr %19, i32 0, i32 3
  %21 = load i32, ptr %20, align 8, !tbaa !14
  %22 = icmp sle i32 %15, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %14
  store i32 2, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  br label %121

24:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %25 = load ptr, ptr @atom, align 8, !tbaa !9
  %26 = load i32, ptr %5, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds %struct.AtomStr, ptr %25, i64 %27
  %29 = getelementptr inbounds %struct.AtomStr, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !15
  %31 = getelementptr inbounds %struct.PropertyStr, ptr %30, i32 0, i32 9
  %32 = getelementptr inbounds %struct.AtomSeqStr, ptr %31, i32 0, i32 2
  %33 = load i32, ptr %32, align 8, !tbaa !17
  %34 = icmp eq i32 %33, 1
  br i1 %34, label %35, label %42

35:                                               ; preds = %24
  %36 = load ptr, ptr @aminoacid, align 8, !tbaa !9
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds %struct.AAStr, ptr %36, i64 %38
  %40 = getelementptr inbounds %struct.AAStr, ptr %39, i32 0, i32 2
  %41 = load i32, ptr %40, align 4, !tbaa !11
  br label %50

42:                                               ; preds = %24
  %43 = load ptr, ptr @aminoacid, align 8, !tbaa !9
  %44 = load i32, ptr %2, align 4, !tbaa !5
  %45 = sub nsw i32 %44, 1
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds %struct.AAStr, ptr %43, i64 %46
  %48 = getelementptr inbounds %struct.AAStr, ptr %47, i32 0, i32 2
  %49 = load i32, ptr %48, align 4, !tbaa !11
  br label %50

50:                                               ; preds = %42, %35
  %51 = phi i32 [ %41, %35 ], [ %49, %42 ]
  store i32 %51, ptr %7, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %114, %50
  %53 = load i32, ptr %7, align 4, !tbaa !5
  %54 = load ptr, ptr @aminoacid, align 8, !tbaa !9
  %55 = load i32, ptr %2, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds %struct.AAStr, ptr %54, i64 %56
  %58 = getelementptr inbounds %struct.AAStr, ptr %57, i32 0, i32 3
  %59 = load i32, ptr %58, align 8, !tbaa !14
  %60 = icmp sle i32 %53, %59
  br i1 %60, label %62, label %61

61:                                               ; preds = %52
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  br label %117

62:                                               ; preds = %52
  %63 = load ptr, ptr @atom, align 8, !tbaa !9
  %64 = load i32, ptr %7, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds %struct.AtomStr, ptr %63, i64 %65
  %67 = getelementptr inbounds %struct.AtomStr, ptr %66, i32 0, i32 0
  %68 = load ptr, ptr %67, align 8, !tbaa !15
  %69 = getelementptr inbounds %struct.PropertyStr, ptr %68, i32 0, i32 10
  %70 = load ptr, ptr %69, align 8, !tbaa !20
  store ptr %70, ptr %4, align 8, !tbaa !9
  br label %71

71:                                               ; preds = %109, %62
  %72 = load ptr, ptr %4, align 8, !tbaa !9
  %73 = icmp ne ptr %72, null
  br i1 %73, label %74, label %113

74:                                               ; preds = %71
  %75 = load ptr, ptr %4, align 8, !tbaa !9
  %76 = getelementptr inbounds %struct.ConstraintStr, ptr %75, i32 0, i32 0
  %77 = load i32, ptr %76, align 8, !tbaa !21
  %78 = load i32, ptr %5, align 4, !tbaa !5
  %79 = icmp eq i32 %77, %78
  br i1 %79, label %80, label %109

80:                                               ; preds = %74
  %81 = load i32, ptr %7, align 4, !tbaa !5
  %82 = load ptr, ptr @atom, align 8, !tbaa !9
  %83 = load i32, ptr %5, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds %struct.AtomStr, ptr %82, i64 %84
  %86 = getelementptr inbounds %struct.AtomStr, ptr %85, i32 0, i32 0
  %87 = load ptr, ptr %86, align 8, !tbaa !15
  %88 = load ptr, ptr %4, align 8, !tbaa !9
  %89 = getelementptr inbounds %struct.ConstraintStr, ptr %88, i32 0, i32 1
  %90 = load double, ptr %89, align 8, !tbaa !23
  %91 = load ptr, ptr %4, align 8, !tbaa !9
  %92 = getelementptr inbounds %struct.ConstraintStr, ptr %91, i32 0, i32 3
  %93 = load double, ptr %92, align 8, !tbaa !24
  %94 = call i32 @FindNextBondList(i32 noundef %81, ptr noundef %87, double noundef %90, double noundef %93, i32 noundef 0)
  store i32 %94, ptr %3, align 4, !tbaa !5
  %95 = load i32, ptr %3, align 4, !tbaa !5
  %96 = icmp eq i32 %95, 1
  br i1 %96, label %97, label %108

97:                                               ; preds = %80
  %98 = load ptr, ptr @connectionMap, align 8, !tbaa !9
  %99 = load i32, ptr %5, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds ptr, ptr %98, i64 %100
  %102 = load ptr, ptr %101, align 8, !tbaa !9
  %103 = load i32, ptr %7, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds i32, ptr %102, i64 %104
  %106 = load i32, ptr %105, align 4, !tbaa !5
  %107 = or i32 %106, 1
  store i32 %107, ptr %105, align 4, !tbaa !5
  br label %108

108:                                              ; preds = %97, %80
  br label %113

109:                                              ; preds = %74
  %110 = load ptr, ptr %4, align 8, !tbaa !9
  %111 = getelementptr inbounds %struct.ConstraintStr, ptr %110, i32 0, i32 4
  %112 = load ptr, ptr %111, align 8, !tbaa !25
  store ptr %112, ptr %4, align 8, !tbaa !9
  br label %71, !llvm.loop !26

113:                                              ; preds = %108, %71
  br label %114

114:                                              ; preds = %113
  %115 = load i32, ptr %7, align 4, !tbaa !5
  %116 = add nsw i32 %115, 1
  store i32 %116, ptr %7, align 4, !tbaa !5
  br label %52, !llvm.loop !28

117:                                              ; preds = %61
  br label %118

118:                                              ; preds = %117
  %119 = load i32, ptr %5, align 4, !tbaa !5
  %120 = add nsw i32 %119, 1
  store i32 %120, ptr %5, align 4, !tbaa !5
  br label %14, !llvm.loop !29

121:                                              ; preds = %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #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 12}
!12 = !{!"AAStr", !7, i64 0, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !13, i64 24}
!13 = !{!"double", !7, i64 0}
!14 = !{!12, !6, i64 16}
!15 = !{!16, !10, i64 0}
!16 = !{!"AtomStr", !10, i64 0, !10, i64 8}
!17 = !{!18, !6, i64 112}
!18 = !{!"PropertyStr", !7, i64 0, !7, i64 8, !7, i64 40, !6, i64 48, !6, i64 52, !6, i64 56, !13, i64 64, !13, i64 72, !7, i64 80, !19, i64 104, !10, i64 120, !10, i64 128}
!19 = !{!"AtomSeqStr", !6, i64 0, !6, i64 4, !6, i64 8}
!20 = !{!18, !10, i64 120}
!21 = !{!22, !6, i64 0}
!22 = !{!"ConstraintStr", !6, i64 0, !13, i64 8, !10, i64 16, !13, i64 24, !10, i64 32}
!23 = !{!22, !13, i64 8}
!24 = !{!22, !13, i64 24}
!25 = !{!22, !10, i64 32}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = distinct !{!28, !27}
!29 = distinct !{!29, !27}


; 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.AAStr = type { [5 x i8], i32, i32, i32, i32, double }
%struct.AtomStr = type { ptr, ptr }

@atom = external local_unnamed_addr global ptr, align 8
@aminoacid = external local_unnamed_addr global ptr, align 8
@connectionMap = external local_unnamed_addr global ptr, align 8

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

; Function Attrs: nounwind uwtable
define dso_local void @BondDuplicate(i32 noundef %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr @aminoacid, align 8, !tbaa !5
  %3 = sext i32 %0 to i64
  %4 = getelementptr inbounds %struct.AAStr, ptr %2, i64 %3, i32 2
  %5 = load i32, ptr %4, align 4, !tbaa !9
  %6 = getelementptr inbounds %struct.AAStr, ptr %2, i64 %3, i32 3
  %7 = load i32, ptr %6, align 8, !tbaa !13
  %.not33 = icmp sgt i32 %5, %7
  br i1 %.not33, label %._crit_edge37, label %.lr.ph36.preheader

.lr.ph36.preheader:                               ; preds = %1
  %8 = sext i32 %5 to i64
  %.pre45 = load ptr, ptr @atom, align 8, !tbaa !5
  br label %.lr.ph36

._crit_edge37:                                    ; preds = %._crit_edge, %1
  ret void

.lr.ph36:                                         ; preds = %.lr.ph36.preheader, %._crit_edge
  %.pre44 = phi i32 [ %7, %.lr.ph36.preheader ], [ %.pre4451, %._crit_edge ]
  %.pre43 = phi ptr [ %.pre45, %.lr.ph36.preheader ], [ %.pre4346, %._crit_edge ]
  %9 = phi ptr [ %.pre45, %.lr.ph36.preheader ], [ %20, %._crit_edge ]
  %10 = phi ptr [ %2, %.lr.ph36.preheader ], [ %21, %._crit_edge ]
  %indvars.iv40 = phi i64 [ %8, %.lr.ph36.preheader ], [ %indvars.iv.next41, %._crit_edge ]
  %11 = getelementptr inbounds %struct.AAStr, ptr %10, i64 %3
  %12 = getelementptr inbounds %struct.AtomStr, ptr %9, i64 %indvars.iv40
  %13 = load ptr, ptr %12, align 8, !tbaa !14
  %14 = getelementptr inbounds i8, ptr %13, i64 112
  %15 = load i32, ptr %14, align 8, !tbaa !16
  %16 = icmp eq i32 %15, 1
  %.in.v = select i1 %16, i64 12, i64 -20
  %.in = getelementptr i8, ptr %11, i64 %.in.v
  %17 = load i32, ptr %.in, align 4, !tbaa !9
  %.not2329 = icmp sgt i32 %17, %.pre44
  br i1 %.not2329, label %.lr.ph36.._crit_edge_crit_edge, label %.lr.ph32.preheader

.lr.ph36.._crit_edge_crit_edge:                   ; preds = %.lr.ph36
  %.pre52 = sext i32 %.pre44 to i64
  br label %._crit_edge

.lr.ph32.preheader:                               ; preds = %.lr.ph36
  %18 = sext i32 %17 to i64
  %19 = trunc nsw i64 %indvars.iv40 to i32
  br label %.lr.ph32

._crit_edge:                                      ; preds = %.loopexit, %.lr.ph36.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre52, %.lr.ph36.._crit_edge_crit_edge ], [ %51, %.loopexit ]
  %.pre4451 = phi i32 [ %.pre44, %.lr.ph36.._crit_edge_crit_edge ], [ %50, %.loopexit ]
  %.pre4346 = phi ptr [ %.pre43, %.lr.ph36.._crit_edge_crit_edge ], [ %.pre4347, %.loopexit ]
  %20 = phi ptr [ %9, %.lr.ph36.._crit_edge_crit_edge ], [ %47, %.loopexit ]
  %21 = phi ptr [ %10, %.lr.ph36.._crit_edge_crit_edge ], [ %48, %.loopexit ]
  %indvars.iv.next41 = add nsw i64 %indvars.iv40, 1
  %.not.not = icmp slt i64 %indvars.iv40, %.pre-phi
  br i1 %.not.not, label %.lr.ph36, label %._crit_edge37, !llvm.loop !19

.lr.ph32:                                         ; preds = %.lr.ph32.preheader, %.loopexit
  %.pre4348 = phi ptr [ %.pre43, %.lr.ph32.preheader ], [ %.pre4347, %.loopexit ]
  %22 = phi ptr [ %.pre43, %.lr.ph32.preheader ], [ %47, %.loopexit ]
  %indvars.iv = phi i64 [ %18, %.lr.ph32.preheader ], [ %indvars.iv.next, %.loopexit ]
  %23 = getelementptr inbounds %struct.AtomStr, ptr %22, i64 %indvars.iv
  %24 = load ptr, ptr %23, align 8, !tbaa !14
  %25 = getelementptr inbounds i8, ptr %24, i64 120
  %.02226 = load ptr, ptr %25, align 8, !tbaa !5
  %.not2427 = icmp eq ptr %.02226, null
  br i1 %.not2427, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph32, %45
  %.02228 = phi ptr [ %.022, %45 ], [ %.02226, %.lr.ph32 ]
  %26 = load i32, ptr %.02228, align 8, !tbaa !21
  %27 = icmp eq i32 %26, %19
  br i1 %27, label %28, label %45

28:                                               ; preds = %.lr.ph
  %29 = getelementptr inbounds %struct.AtomStr, ptr %22, i64 %indvars.iv40
  %30 = load ptr, ptr %29, align 8, !tbaa !14
  %31 = getelementptr inbounds i8, ptr %.02228, i64 8
  %32 = load double, ptr %31, align 8, !tbaa !23
  %33 = getelementptr inbounds i8, ptr %.02228, i64 24
  %34 = load double, ptr %33, align 8, !tbaa !24
  %35 = trunc nsw i64 %indvars.iv to i32
  %36 = tail call i32 @FindNextBondList(i32 noundef %35, ptr noundef %30, double noundef %32, double noundef %34, i32 noundef 0)
  %37 = icmp eq i32 %36, 1
  %.pre = load ptr, ptr @atom, align 8, !tbaa !5
  br i1 %37, label %38, label %.loopexit

38:                                               ; preds = %28
  %39 = load ptr, ptr @connectionMap, align 8, !tbaa !5
  %40 = getelementptr inbounds ptr, ptr %39, i64 %indvars.iv40
  %41 = load ptr, ptr %40, align 8, !tbaa !5
  %42 = getelementptr inbounds i32, ptr %41, i64 %indvars.iv
  %43 = load i32, ptr %42, align 4, !tbaa !25
  %44 = or i32 %43, 1
  store i32 %44, ptr %42, align 4, !tbaa !25
  br label %.loopexit

45:                                               ; preds = %.lr.ph
  %46 = getelementptr inbounds i8, ptr %.02228, i64 32
  %.022 = load ptr, ptr %46, align 8, !tbaa !5
  %.not24 = icmp eq ptr %.022, null
  br i1 %.not24, label %.loopexit, label %.lr.ph, !llvm.loop !26

.loopexit:                                        ; preds = %45, %.lr.ph32, %38, %28
  %.pre4347 = phi ptr [ %.pre4348, %.lr.ph32 ], [ %.pre, %38 ], [ %.pre, %28 ], [ %.pre4348, %45 ]
  %47 = phi ptr [ %22, %.lr.ph32 ], [ %.pre, %38 ], [ %.pre, %28 ], [ %22, %45 ]
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %48 = load ptr, ptr @aminoacid, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.AAStr, ptr %48, i64 %3, i32 3
  %50 = load i32, ptr %49, align 8, !tbaa !13
  %51 = sext i32 %50 to i64
  %.not23.not = icmp slt i64 %indvars.iv, %51
  br i1 %.not23.not, label %.lr.ph32, label %._crit_edge, !llvm.loop !27
}

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, !11, i64 12}
!10 = !{!"AAStr", !7, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !12, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!10, !11, i64 16}
!14 = !{!15, !6, i64 0}
!15 = !{!"AtomStr", !6, i64 0, !6, i64 8}
!16 = !{!17, !11, i64 112}
!17 = !{!"PropertyStr", !7, i64 0, !7, i64 8, !7, i64 40, !11, i64 48, !11, i64 52, !11, i64 56, !12, i64 64, !12, i64 72, !7, i64 80, !18, i64 104, !6, i64 120, !6, i64 128}
!18 = !{!"AtomSeqStr", !11, i64 0, !11, i64 4, !11, i64 8}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!22, !11, i64 0}
!22 = !{!"ConstraintStr", !11, i64 0, !12, i64 8, !6, i64 16, !12, i64 24, !6, i64 32}
!23 = !{!22, !12, i64 8}
!24 = !{!22, !12, i64 24}
!25 = !{!11, !11, i64 0}
!26 = distinct !{!26, !20}
!27 = distinct !{!27, !20}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass