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

; 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.FileStr = type { i32, [256 x i8], ptr }
%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 }

@atomnum = external global i32, align 4
@atom = external global ptr, align 8
@boxDimension = external global [4 x double], align 16
@.str.64 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.65 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.66 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.67 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.68 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.69 = external hidden unnamed_addr constant [8 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: 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 @BackupFile(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @GenerateFile(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @SavePDB(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.FileStr, ptr %5, i32 0, i32 2
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = icmp eq ptr %7, null
  %9 = xor i1 %8, true
  %10 = xor i1 %9, true
  %11 = zext i1 %10 to i32
  %12 = sext i32 %11 to i64
  %13 = call i64 @llvm.expect.i64(i64 %12, i64 0)
  %14 = icmp ne i64 %13, 0
  br i1 %14, label %15, label %18

15:                                               ; preds = %1
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  call void @BackupFile(ptr noundef %16)
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  call void @GenerateFile(ptr noundef %17)
  br label %18

18:                                               ; preds = %15, %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.FileStr, ptr %19, i32 0, i32 2
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  store ptr %21, ptr %3, align 8, !tbaa !5
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef @.str.64) #5
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef @.str.65) #5
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = load double, ptr getelementptr inbounds ([4 x double], ptr @boxDimension, i64 0, i64 1), align 8, !tbaa !12
  %28 = load double, ptr getelementptr inbounds ([4 x double], ptr @boxDimension, i64 0, i64 2), align 16, !tbaa !12
  %29 = load double, ptr getelementptr inbounds ([4 x double], ptr @boxDimension, i64 0, i64 3), align 8, !tbaa !12
  %30 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef @.str.66, double noundef %27, double noundef %28, double noundef %29) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 1, ptr %4, align 4, !tbaa !14
  br label %31

31:                                               ; preds = %114, %18
  %32 = load i32, ptr %4, align 4, !tbaa !14
  %33 = load i32, ptr @atomnum, align 4, !tbaa !14
  %34 = icmp sle i32 %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %117

36:                                               ; preds = %31
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = load i32, ptr %4, align 4, !tbaa !14
  %39 = load ptr, ptr @atom, align 8, !tbaa !5
  %40 = load i32, ptr %4, align 4, !tbaa !14
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds %struct.AtomStr, ptr %39, i64 %41
  %43 = getelementptr inbounds %struct.AtomStr, ptr %42, i32 0, i32 0
  %44 = load ptr, ptr %43, align 8, !tbaa !15
  %45 = getelementptr inbounds %struct.PropertyStr, ptr %44, i32 0, i32 0
  %46 = getelementptr inbounds [8 x i8], ptr %45, i64 0, i64 0
  %47 = load ptr, ptr @atom, align 8, !tbaa !5
  %48 = load i32, ptr %4, align 4, !tbaa !14
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds %struct.AtomStr, ptr %47, i64 %49
  %51 = getelementptr inbounds %struct.AtomStr, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !15
  %53 = getelementptr inbounds %struct.PropertyStr, ptr %52, i32 0, i32 2
  %54 = getelementptr inbounds [8 x i8], ptr %53, i64 0, i64 0
  %55 = load ptr, ptr @atom, align 8, !tbaa !5
  %56 = load i32, ptr %4, align 4, !tbaa !14
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds %struct.AtomStr, ptr %55, i64 %57
  %59 = getelementptr inbounds %struct.AtomStr, ptr %58, i32 0, i32 0
  %60 = load ptr, ptr %59, align 8, !tbaa !15
  %61 = getelementptr inbounds %struct.PropertyStr, ptr %60, i32 0, i32 9
  %62 = getelementptr inbounds %struct.AtomSeqStr, ptr %61, i32 0, i32 1
  %63 = load i32, ptr %62, align 4, !tbaa !17
  %64 = add nsw i32 %63, 65
  %65 = sub nsw i32 %64, 49
  %66 = add nsw i32 %65, 48
  %67 = load ptr, ptr @atom, align 8, !tbaa !5
  %68 = load i32, ptr %4, align 4, !tbaa !14
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds %struct.AtomStr, ptr %67, i64 %69
  %71 = getelementptr inbounds %struct.AtomStr, ptr %70, i32 0, i32 0
  %72 = load ptr, ptr %71, align 8, !tbaa !15
  %73 = getelementptr inbounds %struct.PropertyStr, ptr %72, i32 0, i32 9
  %74 = getelementptr inbounds %struct.AtomSeqStr, ptr %73, i32 0, i32 2
  %75 = load i32, ptr %74, align 8, !tbaa !20
  %76 = load ptr, ptr @atom, align 8, !tbaa !5
  %77 = load i32, ptr %4, align 4, !tbaa !14
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds %struct.AtomStr, ptr %76, i64 %78
  %80 = getelementptr inbounds %struct.AtomStr, ptr %79, i32 0, i32 1
  %81 = load ptr, ptr %80, align 8, !tbaa !21
  %82 = getelementptr inbounds %struct.DynamicStr, ptr %81, i32 0, i32 1
  %83 = getelementptr inbounds [4 x double], ptr %82, i64 0, i64 1
  %84 = load double, ptr %83, align 8, !tbaa !12
  %85 = load ptr, ptr @atom, align 8, !tbaa !5
  %86 = load i32, ptr %4, align 4, !tbaa !14
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds %struct.AtomStr, ptr %85, i64 %87
  %89 = getelementptr inbounds %struct.AtomStr, ptr %88, i32 0, i32 1
  %90 = load ptr, ptr %89, align 8, !tbaa !21
  %91 = getelementptr inbounds %struct.DynamicStr, ptr %90, i32 0, i32 1
  %92 = getelementptr inbounds [4 x double], ptr %91, i64 0, i64 2
  %93 = load double, ptr %92, align 8, !tbaa !12
  %94 = load ptr, ptr @atom, align 8, !tbaa !5
  %95 = load i32, ptr %4, align 4, !tbaa !14
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds %struct.AtomStr, ptr %94, i64 %96
  %98 = getelementptr inbounds %struct.AtomStr, ptr %97, i32 0, i32 1
  %99 = load ptr, ptr %98, align 8, !tbaa !21
  %100 = getelementptr inbounds %struct.DynamicStr, ptr %99, i32 0, i32 1
  %101 = getelementptr inbounds [4 x double], ptr %100, i64 0, i64 3
  %102 = load double, ptr %101, align 8, !tbaa !12
  %103 = load ptr, ptr @atom, align 8, !tbaa !5
  %104 = load i32, ptr %4, align 4, !tbaa !14
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds %struct.AtomStr, ptr %103, i64 %105
  %107 = getelementptr inbounds %struct.AtomStr, ptr %106, i32 0, i32 0
  %108 = load ptr, ptr %107, align 8, !tbaa !15
  %109 = getelementptr inbounds %struct.PropertyStr, ptr %108, i32 0, i32 0
  %110 = getelementptr inbounds [8 x i8], ptr %109, i64 0, i64 0
  %111 = load i8, ptr %110, align 8, !tbaa !22
  %112 = sext i8 %111 to i32
  %113 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %37, ptr noundef @.str.67, i32 noundef %38, ptr noundef %46, ptr noundef %54, i32 noundef %66, i32 noundef %75, double noundef %84, double noundef %93, double noundef %102, double noundef 1.000000e+00, double noundef 0.000000e+00, i32 noundef %112) #5
  br label %114

114:                                              ; preds = %36
  %115 = load i32, ptr %4, align 4, !tbaa !14
  %116 = add nsw i32 %115, 1
  store i32 %116, ptr %4, align 4, !tbaa !14
  br label %31, !llvm.loop !23

117:                                              ; preds = %35
  %118 = load ptr, ptr %3, align 8, !tbaa !5
  %119 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %118, ptr noundef @.str.68) #5
  %120 = load ptr, ptr %3, align 8, !tbaa !5
  %121 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %120, ptr noundef @.str.69) #5
  %122 = load ptr, ptr %3, align 8, !tbaa !5
  %123 = call i32 @fflush(ptr noundef %122)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret void
}

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #3

declare i32 @fflush(ptr noundef) #4

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 "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 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #4 = { "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 #5 = { 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 264}
!10 = !{!"FileStr", !11, i64 0, !7, i64 4, !6, i64 264}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"double", !7, i64 0}
!14 = !{!11, !11, i64 0}
!15 = !{!16, !6, i64 0}
!16 = !{!"AtomStr", !6, i64 0, !6, i64 8}
!17 = !{!18, !11, i64 108}
!18 = !{!"PropertyStr", !7, i64 0, !7, i64 8, !7, i64 40, !11, i64 48, !11, i64 52, !11, i64 56, !13, i64 64, !13, i64 72, !7, i64 80, !19, i64 104, !6, i64 120, !6, i64 128}
!19 = !{!"AtomSeqStr", !11, i64 0, !11, i64 4, !11, i64 8}
!20 = !{!18, !11, i64 112}
!21 = !{!16, !6, i64 8}
!22 = !{!7, !7, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"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.AtomStr = type { ptr, ptr }

@atomnum = external local_unnamed_addr global i32, align 4
@atom = external local_unnamed_addr global ptr, align 8
@boxDimension = external local_unnamed_addr global [4 x double], align 16
@.str.64 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.65 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.66 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.67 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.68 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.69 = external hidden unnamed_addr constant [8 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @BackupFile(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @GenerateFile(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @SavePDB(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 264
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = icmp eq ptr %3, null
  br i1 %4, label %5, label %6, !prof !11

5:                                                ; preds = %1
  tail call void @BackupFile(ptr noundef nonnull %0)
  tail call void @GenerateFile(ptr noundef nonnull %0)
  %.pre = load ptr, ptr %2, align 8, !tbaa !5
  br label %6

6:                                                ; preds = %5, %1
  %7 = phi ptr [ %.pre, %5 ], [ %3, %1 ]
  %8 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.64) #2
  %9 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.65) #2
  %10 = load double, ptr getelementptr inbounds (i8, ptr @boxDimension, i64 8), align 8, !tbaa !12
  %11 = load double, ptr getelementptr inbounds (i8, ptr @boxDimension, i64 16), align 16, !tbaa !12
  %12 = load double, ptr getelementptr inbounds (i8, ptr @boxDimension, i64 24), align 8, !tbaa !12
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.66, double noundef %10, double noundef %11, double noundef %12) #2
  %14 = load i32, ptr @atomnum, align 4, !tbaa !14
  %.not21 = icmp slt i32 %14, 1
  br i1 %.not21, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %6
  %15 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.68) #2
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.69) #2
  %17 = tail call i32 @fflush(ptr noundef %7)
  ret void

.lr.ph:                                           ; preds = %6, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %6 ]
  %18 = load ptr, ptr @atom, align 8, !tbaa !15
  %19 = getelementptr inbounds %struct.AtomStr, ptr %18, i64 %indvars.iv
  %20 = load ptr, ptr %19, align 8, !tbaa !16
  %21 = getelementptr inbounds i8, ptr %20, i64 40
  %22 = getelementptr inbounds i8, ptr %20, i64 108
  %23 = load i32, ptr %22, align 4, !tbaa !18
  %24 = add nsw i32 %23, 64
  %25 = getelementptr inbounds i8, ptr %20, i64 112
  %26 = load i32, ptr %25, align 8, !tbaa !21
  %27 = getelementptr inbounds i8, ptr %19, i64 8
  %28 = load ptr, ptr %27, align 8, !tbaa !22
  %29 = getelementptr inbounds i8, ptr %28, i64 24
  %30 = load double, ptr %29, align 8, !tbaa !12
  %31 = getelementptr inbounds i8, ptr %28, i64 32
  %32 = load double, ptr %31, align 8, !tbaa !12
  %33 = getelementptr inbounds i8, ptr %28, i64 40
  %34 = load double, ptr %33, align 8, !tbaa !12
  %35 = load i8, ptr %20, align 8, !tbaa !23
  %36 = sext i8 %35 to i32
  %37 = trunc nuw nsw i64 %indvars.iv to i32
  %38 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.67, i32 noundef %37, ptr noundef nonnull %20, ptr noundef nonnull %21, i32 noundef %24, i32 noundef %26, double noundef %30, double noundef %32, double noundef %34, double noundef 1.000000e+00, double noundef 0.000000e+00, i32 noundef %36) #2
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %39 = load i32, ptr @atomnum, align 4, !tbaa !14
  %40 = sext i32 %39 to i64
  %.not.not = icmp slt i64 %indvars.iv, %40
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !24
}

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @fflush(ptr nocapture noundef) local_unnamed_addr #1

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" }
attributes #1 = { nofree nounwind "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, !10, i64 264}
!6 = !{!"FileStr", !7, i64 0, !8, i64 4, !10, i64 264}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!12 = !{!13, !13, i64 0}
!13 = !{!"double", !8, i64 0}
!14 = !{!7, !7, i64 0}
!15 = !{!10, !10, i64 0}
!16 = !{!17, !10, i64 0}
!17 = !{!"AtomStr", !10, i64 0, !10, i64 8}
!18 = !{!19, !7, i64 108}
!19 = !{!"PropertyStr", !8, i64 0, !8, i64 8, !8, i64 40, !7, i64 48, !7, i64 52, !7, i64 56, !13, i64 64, !13, i64 72, !8, i64 80, !20, i64 104, !10, i64 120, !10, i64 128}
!20 = !{!"AtomSeqStr", !7, i64 0, !7, i64 4, !7, i64 8}
!21 = !{!19, !7, i64 112}
!22 = !{!17, !10, i64 8}
!23 = !{!8, !8, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


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