; 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.70 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.71 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.72 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.73 = external hidden unnamed_addr constant [20 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 @SaveGRO(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.70) #5
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = load i32, ptr @atomnum, align 4, !tbaa !12
  %26 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef @.str.71, i32 noundef %25) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 1, ptr %4, align 4, !tbaa !12
  br label %27

27:                                               ; preds = %118, %18
  %28 = load i32, ptr %4, align 4, !tbaa !12
  %29 = load i32, ptr @atomnum, align 4, !tbaa !12
  %30 = icmp sle i32 %28, %29
  br i1 %30, label %32, label %31

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

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

118:                                              ; preds = %32
  %119 = load i32, ptr %4, align 4, !tbaa !12
  %120 = add nsw i32 %119, 1
  store i32 %120, ptr %4, align 4, !tbaa !12
  br label %27, !llvm.loop !21

121:                                              ; preds = %31
  %122 = load ptr, ptr %3, align 8, !tbaa !5
  %123 = load double, ptr getelementptr inbounds ([4 x double], ptr @boxDimension, i64 0, i64 1), align 8, !tbaa !20
  %124 = fdiv double %123, 1.000000e+01
  %125 = load double, ptr getelementptr inbounds ([4 x double], ptr @boxDimension, i64 0, i64 2), align 16, !tbaa !20
  %126 = fdiv double %125, 1.000000e+01
  %127 = load double, ptr getelementptr inbounds ([4 x double], ptr @boxDimension, i64 0, i64 3), align 8, !tbaa !20
  %128 = fdiv double %127, 1.000000e+01
  %129 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %122, ptr noundef @.str.73, double noundef %124, double noundef %126, double noundef %128) #5
  %130 = load ptr, ptr %3, align 8, !tbaa !5
  %131 = call i32 @fflush(ptr noundef %130)
  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 = !{!11, !11, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"AtomStr", !6, i64 0, !6, i64 8}
!15 = !{!16, !11, i64 112}
!16 = !{!"PropertyStr", !7, i64 0, !7, i64 8, !7, i64 40, !11, i64 48, !11, i64 52, !11, i64 56, !17, i64 64, !17, i64 72, !7, i64 80, !18, i64 104, !6, i64 120, !6, i64 128}
!17 = !{!"double", !7, i64 0}
!18 = !{!"AtomSeqStr", !11, i64 0, !11, i64 4, !11, i64 8}
!19 = !{!14, !6, i64 8}
!20 = !{!17, !17, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"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.70 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.71 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.72 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.73 = external hidden unnamed_addr constant [20 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 @SaveGRO(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.70) #2
  %9 = load i32, ptr @atomnum, align 4, !tbaa !12
  %10 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.71, i32 noundef %9) #2
  %11 = load i32, ptr @atomnum, align 4, !tbaa !12
  %.not20 = icmp slt i32 %11, 1
  br i1 %.not20, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %6
  %12 = load double, ptr getelementptr inbounds (i8, ptr @boxDimension, i64 8), align 8, !tbaa !13
  %13 = fdiv double %12, 1.000000e+01
  %14 = load double, ptr getelementptr inbounds (i8, ptr @boxDimension, i64 16), align 16, !tbaa !13
  %15 = fdiv double %14, 1.000000e+01
  %16 = load double, ptr getelementptr inbounds (i8, ptr @boxDimension, i64 24), align 8, !tbaa !13
  %17 = fdiv double %16, 1.000000e+01
  %18 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.73, double noundef %13, double noundef %15, double noundef %17) #2
  %19 = 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 ]
  %20 = load ptr, ptr @atom, align 8, !tbaa !15
  %21 = getelementptr inbounds %struct.AtomStr, ptr %20, i64 %indvars.iv
  %22 = load ptr, ptr %21, align 8, !tbaa !16
  %23 = getelementptr inbounds i8, ptr %22, i64 112
  %24 = load i32, ptr %23, align 8, !tbaa !18
  %25 = getelementptr inbounds i8, ptr %22, i64 40
  %26 = getelementptr inbounds i8, ptr %21, i64 8
  %27 = load ptr, ptr %26, align 8, !tbaa !21
  %28 = getelementptr inbounds i8, ptr %27, i64 24
  %29 = load double, ptr %28, align 8, !tbaa !13
  %30 = fdiv double %29, 1.000000e+01
  %31 = getelementptr inbounds i8, ptr %27, i64 32
  %32 = load double, ptr %31, align 8, !tbaa !13
  %33 = fdiv double %32, 1.000000e+01
  %34 = getelementptr inbounds i8, ptr %27, i64 40
  %35 = load double, ptr %34, align 8, !tbaa !13
  %36 = fdiv double %35, 1.000000e+01
  %37 = getelementptr inbounds i8, ptr %27, i64 56
  %38 = load double, ptr %37, align 8, !tbaa !13
  %39 = getelementptr inbounds i8, ptr %27, i64 64
  %40 = load double, ptr %39, align 8, !tbaa !13
  %41 = getelementptr inbounds i8, ptr %27, i64 72
  %42 = load double, ptr %41, align 8, !tbaa !13
  %43 = trunc nuw nsw i64 %indvars.iv to i32
  %44 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.72, i32 noundef %24, ptr noundef nonnull %25, ptr noundef %22, i32 noundef %43, double noundef %30, double noundef %33, double noundef %36, double noundef %38, double noundef %40, double noundef %42) #2
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %45 = load i32, ptr @atomnum, align 4, !tbaa !12
  %46 = sext i32 %45 to i64
  %.not.not = icmp slt i64 %indvars.iv, %46
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !22
}

; 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 = !{!7, !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !8, i64 0}
!15 = !{!10, !10, i64 0}
!16 = !{!17, !10, i64 0}
!17 = !{!"AtomStr", !10, i64 0, !10, i64 8}
!18 = !{!19, !7, i64 112}
!19 = !{!"PropertyStr", !8, i64 0, !8, i64 8, !8, i64 40, !7, i64 48, !7, i64 52, !7, i64 56, !14, i64 64, !14, 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 = !{!17, !10, i64 8}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


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