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

@totalAminoAcids = external global i32, align 4
@aminoacid = external global ptr, align 8
@.str.138 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.150 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.151 = external hidden unnamed_addr constant [4 x i8], align 1

; 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: nounwind uwtable
define dso_local void @ReadModel() #2 {
  %1 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  store i32 1, ptr %1, align 4, !tbaa !5
  br label %2

2:                                                ; preds = %52, %0
  %3 = load i32, ptr %1, align 4, !tbaa !5
  %4 = load i32, ptr @totalAminoAcids, align 4, !tbaa !5
  %5 = icmp sle i32 %3, %4
  br i1 %5, label %7, label %6

6:                                                ; preds = %2
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  br label %55

7:                                                ; preds = %2
  %8 = load i32, ptr %1, align 4, !tbaa !5
  call void @ScanAA(i32 noundef %8, i32 noundef 0)
  %9 = load ptr, ptr @aminoacid, align 8, !tbaa !9
  %10 = load i32, ptr %1, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds %struct.AAStr, ptr %9, i64 %11
  %13 = getelementptr inbounds %struct.AAStr, ptr %12, i32 0, i32 0
  %14 = getelementptr inbounds [5 x i8], ptr %13, i64 0, i64 0
  %15 = call i32 @strcmp(ptr noundef %14, ptr noundef @.str.150) #4
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %17, label %18

17:                                               ; preds = %7
  br label %52

18:                                               ; preds = %7
  %19 = load ptr, ptr @aminoacid, align 8, !tbaa !9
  %20 = load i32, ptr %1, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds %struct.AAStr, ptr %19, i64 %21
  %23 = getelementptr inbounds %struct.AAStr, ptr %22, i32 0, i32 0
  %24 = getelementptr inbounds [5 x i8], ptr %23, i64 0, i64 0
  %25 = call i32 @strcmp(ptr noundef %24, ptr noundef @.str.138) #4
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %38

27:                                               ; preds = %18
  %28 = load ptr, ptr @aminoacid, align 8, !tbaa !9
  %29 = load i32, ptr %1, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds %struct.AAStr, ptr %28, i64 %30
  %32 = getelementptr inbounds %struct.AAStr, ptr %31, i32 0, i32 0
  %33 = getelementptr inbounds [5 x i8], ptr %32, i64 0, i64 0
  %34 = call i32 @strcmp(ptr noundef %33, ptr noundef @.str.151) #4
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %38

36:                                               ; preds = %27
  %37 = load i32, ptr %1, align 4, !tbaa !5
  call void @ScanAA(i32 noundef %37, i32 noundef 1)
  br label %38

38:                                               ; preds = %36, %27, %18
  %39 = load ptr, ptr @aminoacid, align 8, !tbaa !9
  %40 = load i32, ptr %1, align 4, !tbaa !5
  %41 = add nsw i32 %40, 1
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds %struct.AAStr, ptr %39, i64 %42
  %44 = getelementptr inbounds %struct.AAStr, ptr %43, i32 0, i32 0
  %45 = getelementptr inbounds [5 x i8], ptr %44, i64 0, i64 0
  %46 = call i32 @strcmp(ptr noundef %45, ptr noundef @.str.151) #4
  %47 = icmp eq i32 %46, 0
  br i1 %47, label %48, label %50

48:                                               ; preds = %38
  %49 = load i32, ptr %1, align 4, !tbaa !5
  call void @ScanAA(i32 noundef %49, i32 noundef 2)
  br label %50

50:                                               ; preds = %48, %38
  br label %51

51:                                               ; preds = %50
  br label %52

52:                                               ; preds = %51, %17
  %53 = load i32, ptr %1, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %1, align 4, !tbaa !5
  br label %2, !llvm.loop !11

55:                                               ; preds = %6
  ret void
}

; 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 void @ScanAA(i32 noundef, i32 noundef) #2

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 = distinct !{!11, !12}
!12 = !{!"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 }

@totalAminoAcids = external local_unnamed_addr global i32, align 4
@aminoacid = external local_unnamed_addr global ptr, align 8
@.str.138 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.150 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.151 = external hidden unnamed_addr constant [4 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local void @ReadModel() local_unnamed_addr #1 {
  %1 = load i32, ptr @totalAminoAcids, align 4, !tbaa !5
  %.not11 = icmp slt i32 %1, 1
  br i1 %.not11, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %19, %0
  ret void

.lr.ph:                                           ; preds = %0, %19
  %indvars.iv = phi i64 [ %indvars.iv.next, %19 ], [ 1, %0 ]
  %2 = trunc nuw nsw i64 %indvars.iv to i32
  tail call void @ScanAA(i32 noundef %2, i32 noundef 0)
  %3 = load ptr, ptr @aminoacid, align 8, !tbaa !9
  %4 = getelementptr inbounds %struct.AAStr, ptr %3, i64 %indvars.iv
  %5 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %4, ptr noundef nonnull dereferenceable(1) @.str.150) #2
  %6 = icmp eq i32 %5, 0
  br i1 %6, label %19, label %7

7:                                                ; preds = %.lr.ph
  %8 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %4, ptr noundef nonnull dereferenceable(1) @.str.138) #2
  %.not9 = icmp eq i32 %8, 0
  br i1 %.not9, label %12, label %9

9:                                                ; preds = %7
  %10 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %4, ptr noundef nonnull dereferenceable(1) @.str.151) #2
  %.not10 = icmp eq i32 %10, 0
  br i1 %.not10, label %12, label %11

11:                                               ; preds = %9
  tail call void @ScanAA(i32 noundef %2, i32 noundef 1)
  %.pre = load ptr, ptr @aminoacid, align 8, !tbaa !9
  br label %12

12:                                               ; preds = %11, %9, %7
  %13 = phi ptr [ %.pre, %11 ], [ %3, %9 ], [ %3, %7 ]
  %14 = getelementptr inbounds %struct.AAStr, ptr %13, i64 %indvars.iv
  %15 = getelementptr inbounds i8, ptr %14, i64 32
  %16 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %15, ptr noundef nonnull dereferenceable(1) @.str.151) #2
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %18, label %19

18:                                               ; preds = %12
  tail call void @ScanAA(i32 noundef %2, i32 noundef 2)
  br label %19

19:                                               ; preds = %18, %12, %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %20 = load i32, ptr @totalAminoAcids, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %.not.not = icmp slt i64 %indvars.iv, %21
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !11
}

; Function Attrs: nounwind uwtable
declare dso_local void @ScanAA(i32 noundef, i32 noundef) local_unnamed_addr #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 = { 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 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass