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

@totalAminoAcids = external global i32, align 4
@atom = external global ptr, align 8
@aminoacid = 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: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr 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 i32 @FindTargetAtom(i32 noundef %0, ptr noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %10 = load ptr, ptr %5, align 8, !tbaa !9
  %11 = getelementptr inbounds i8, ptr %10, i64 0
  %12 = load i8, ptr %11, align 1, !tbaa !11
  %13 = sext i8 %12 to i32
  %14 = icmp eq i32 %13, 43
  br i1 %14, label %15, label %51

15:                                               ; preds = %2
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = load i32, ptr @totalAminoAcids, align 4, !tbaa !5
  %18 = icmp eq i32 %16, %17
  br i1 %18, label %34, label %19

19:                                               ; preds = %15
  %20 = load ptr, ptr @aminoacid, align 8, !tbaa !9
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = add nsw i32 %21, 1
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds %struct.AAStr, ptr %20, i64 %23
  %25 = getelementptr inbounds %struct.AAStr, ptr %24, i32 0, i32 4
  %26 = load i32, ptr %25, align 4, !tbaa !12
  %27 = load ptr, ptr @aminoacid, align 8, !tbaa !9
  %28 = load i32, ptr %4, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds %struct.AAStr, ptr %27, i64 %29
  %31 = getelementptr inbounds %struct.AAStr, ptr %30, i32 0, i32 4
  %32 = load i32, ptr %31, align 4, !tbaa !12
  %33 = icmp ne i32 %26, %32
  br i1 %33, label %34, label %35

34:                                               ; preds = %19, %15
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %103

35:                                               ; preds = %19
  %36 = load ptr, ptr @aminoacid, align 8, !tbaa !9
  %37 = load i32, ptr %4, align 4, !tbaa !5
  %38 = add nsw i32 %37, 1
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds %struct.AAStr, ptr %36, i64 %39
  %41 = getelementptr inbounds %struct.AAStr, ptr %40, i32 0, i32 2
  %42 = load i32, ptr %41, align 4, !tbaa !15
  store i32 %42, ptr %6, align 4, !tbaa !5
  %43 = load ptr, ptr @aminoacid, align 8, !tbaa !9
  %44 = load i32, ptr %4, align 4, !tbaa !5
  %45 = add 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 3
  %49 = load i32, ptr %48, align 8, !tbaa !16
  store i32 %49, ptr %7, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %35
  br label %64

51:                                               ; preds = %2
  %52 = load ptr, ptr @aminoacid, align 8, !tbaa !9
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds %struct.AAStr, ptr %52, i64 %54
  %56 = getelementptr inbounds %struct.AAStr, ptr %55, i32 0, i32 2
  %57 = load i32, ptr %56, align 4, !tbaa !15
  store i32 %57, ptr %6, align 4, !tbaa !5
  %58 = load ptr, ptr @aminoacid, align 8, !tbaa !9
  %59 = load i32, ptr %4, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds %struct.AAStr, ptr %58, i64 %60
  %62 = getelementptr inbounds %struct.AAStr, ptr %61, i32 0, i32 3
  %63 = load i32, ptr %62, align 8, !tbaa !16
  store i32 %63, ptr %7, align 4, !tbaa !5
  br label %64

64:                                               ; preds = %51, %50
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %65 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %65, ptr %9, align 4, !tbaa !5
  br label %66

66:                                               ; preds = %97, %64
  %67 = load i32, ptr %9, align 4, !tbaa !5
  %68 = load i32, ptr %7, align 4, !tbaa !5
  %69 = icmp sle i32 %67, %68
  br i1 %69, label %71, label %70

70:                                               ; preds = %66
  store i32 2, ptr %8, align 4
  br label %100

71:                                               ; preds = %66
  %72 = load ptr, ptr @atom, align 8, !tbaa !9
  %73 = load i32, ptr %9, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds %struct.AtomStr, ptr %72, i64 %74
  %76 = getelementptr inbounds %struct.AtomStr, ptr %75, i32 0, i32 0
  %77 = load ptr, ptr %76, align 8, !tbaa !17
  %78 = getelementptr inbounds %struct.PropertyStr, ptr %77, i32 0, i32 0
  %79 = getelementptr inbounds [8 x i8], ptr %78, i64 0, i64 0
  %80 = load ptr, ptr %5, align 8, !tbaa !9
  %81 = getelementptr inbounds i8, ptr %80, i64 0
  %82 = load i8, ptr %81, align 1, !tbaa !11
  %83 = sext i8 %82 to i32
  %84 = icmp eq i32 %83, 43
  br i1 %84, label %85, label %88

85:                                               ; preds = %71
  %86 = load ptr, ptr %5, align 8, !tbaa !9
  %87 = getelementptr inbounds i8, ptr %86, i64 1
  br label %90

88:                                               ; preds = %71
  %89 = load ptr, ptr %5, align 8, !tbaa !9
  br label %90

90:                                               ; preds = %88, %85
  %91 = phi ptr [ %87, %85 ], [ %89, %88 ]
  %92 = call i32 @strcmp(ptr noundef %79, ptr noundef %91) #4
  %93 = icmp eq i32 %92, 0
  br i1 %93, label %94, label %96

94:                                               ; preds = %90
  %95 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %95, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %100

96:                                               ; preds = %90
  br label %97

97:                                               ; preds = %96
  %98 = load i32, ptr %9, align 4, !tbaa !5
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr %9, align 4, !tbaa !5
  br label %66, !llvm.loop !19

100:                                              ; preds = %94, %70
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  %101 = load i32, ptr %8, align 4
  switch i32 %101, label %103 [
    i32 2, label %102
  ]

102:                                              ; preds = %100
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %103

103:                                              ; preds = %102, %100, %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %104 = load i32, ptr %3, align 4
  ret i32 %104
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind willreturn memory(read) "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 }
attributes #4 = { nounwind willreturn memory(read) }

!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 = !{!7, !7, i64 0}
!12 = !{!13, !6, i64 20}
!13 = !{!"AAStr", !7, i64 0, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !14, i64 24}
!14 = !{!"double", !7, i64 0}
!15 = !{!13, !6, i64 12}
!16 = !{!13, !6, i64 16}
!17 = !{!18, !10, i64 0}
!18 = !{!"AtomStr", !10, i64 0, !10, i64 8}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


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

@totalAminoAcids = external local_unnamed_addr global i32, align 4
@atom = external local_unnamed_addr global ptr, align 8
@aminoacid = external local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local i32 @FindTargetAtom(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 {
  %3 = load i8, ptr %1, align 1, !tbaa !5
  %4 = icmp eq i8 %3, 43
  br i1 %4, label %5, label %19

5:                                                ; preds = %2
  %6 = load i32, ptr @totalAminoAcids, align 4, !tbaa !8
  %7 = icmp eq i32 %6, %0
  br i1 %7, label %.loopexit, label %8

8:                                                ; preds = %5
  %9 = load ptr, ptr @aminoacid, align 8, !tbaa !10
  %10 = sext i32 %0 to i64
  %11 = getelementptr %struct.AAStr, ptr %9, i64 %10
  %12 = getelementptr i8, ptr %11, i64 52
  %13 = load i32, ptr %12, align 4, !tbaa !12
  %14 = getelementptr inbounds %struct.AAStr, ptr %9, i64 %10, i32 4
  %15 = load i32, ptr %14, align 4, !tbaa !12
  %.not = icmp eq i32 %13, %15
  br i1 %.not, label %16, label %.loopexit

16:                                               ; preds = %8
  %17 = getelementptr i8, ptr %11, i64 44
  %18 = getelementptr i8, ptr %11, i64 48
  br label %25

19:                                               ; preds = %2
  %20 = load ptr, ptr @aminoacid, align 8, !tbaa !10
  %21 = sext i32 %0 to i64
  %22 = getelementptr inbounds %struct.AAStr, ptr %20, i64 %21
  %23 = getelementptr inbounds i8, ptr %22, i64 12
  %24 = getelementptr inbounds i8, ptr %22, i64 16
  br label %25

25:                                               ; preds = %19, %16
  %.020.in = phi ptr [ %17, %16 ], [ %23, %19 ]
  %.019.in = phi ptr [ %18, %16 ], [ %24, %19 ]
  %.019 = load i32, ptr %.019.in, align 8, !tbaa !15
  %.020 = load i32, ptr %.020.in, align 4, !tbaa !16
  %.not2324 = icmp sgt i32 %.020, %.019
  br i1 %.not2324, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %25
  %26 = load ptr, ptr @atom, align 8, !tbaa !10
  %.idx = zext i1 %4 to i64
  %27 = getelementptr inbounds i8, ptr %1, i64 %.idx
  %28 = sext i32 %.020 to i64
  %29 = add i32 %.019, 1
  br label %30

30:                                               ; preds = %.lr.ph, %35
  %indvars.iv = phi i64 [ %28, %.lr.ph ], [ %indvars.iv.next, %35 ]
  %31 = getelementptr inbounds %struct.AtomStr, ptr %26, i64 %indvars.iv
  %32 = load ptr, ptr %31, align 8, !tbaa !17
  %33 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %32, ptr noundef nonnull dereferenceable(1) %27) #2
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %.loopexit.loopexit.split.loop.exit29, label %35

35:                                               ; preds = %30
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
  %exitcond.not = icmp eq i32 %29, %lftr.wideiv
  br i1 %exitcond.not, label %.loopexit, label %30, !llvm.loop !19

.loopexit.loopexit.split.loop.exit29:             ; preds = %30
  %36 = trunc nsw i64 %indvars.iv to i32
  br label %.loopexit

.loopexit:                                        ; preds = %35, %.loopexit.loopexit.split.loop.exit29, %25, %5, %8
  %.1 = phi i32 [ -1, %8 ], [ -1, %5 ], [ 0, %25 ], [ %36, %.loopexit.loopexit.split.loop.exit29 ], [ 0, %35 ]
  ret i32 %.1
}

attributes #0 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { nofree nounwind 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" }
attributes #2 = { nounwind willreturn memory(read) }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!12 = !{!13, !9, i64 20}
!13 = !{!"AAStr", !6, i64 0, !9, i64 8, !9, i64 12, !9, i64 16, !9, i64 20, !14, i64 24}
!14 = !{!"double", !6, i64 0}
!15 = !{!13, !9, i64 16}
!16 = !{!13, !9, i64 12}
!17 = !{!18, !11, i64 0}
!18 = !{!"AtomStr", !11, i64 0, !11, i64 8}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


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