; LLVM IR from alexzheng42/sDMD :: analysis (SystemInformation)

; 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] }
%struct.SectionStr = type { i64, double, double, double, double, [20 x i8], %struct.WallStr, %struct.DynamicWallStr, %struct.ObstructionStr, %struct.TunnelStr, %struct.FlowStr }
%struct.WallStr = type { [20 x i8], [20 x i8], %struct.AtomStr }
%struct.AtomStr = type { ptr, ptr }
%struct.DynamicWallStr = type { [16 x i8], i32, i32, double, double, double, double, [4 x double] }
%struct.ObstructionStr = type { i32, i32, ptr, ptr, ptr }
%struct.TunnelStr = type { i32, double, double, double, %struct.AtomStr }
%struct.FlowStr = type { i32, %struct.ConstVStr, %struct.ForceStr, %struct.ChargeStr }
%struct.ConstVStr = type { [4 x double] }
%struct.ForceStr = type { [4 x double], ptr, ptr }
%struct.ChargeStr = type { i32, i32, ptr, ptr, ptr, ptr }

@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@path = external global [1024 x i8], align 16
@files = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@sectInfo = 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
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #1

declare noalias ptr @fopen(ptr noundef, ptr noundef) #2

declare i64 @fread(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #2

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare i32 @fclose(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @ReadObst(i32 noundef %0, i32 noundef %1) #4 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca [1024 x i8], align 16
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1024, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %11 = getelementptr inbounds [1024 x i8], ptr %5, i64 0, i64 0
  %12 = load ptr, ptr @files, align 8, !tbaa !9
  %13 = getelementptr inbounds ptr, ptr %12, i64 2
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = load i32, ptr %3, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds %struct.FileStr, ptr %14, i64 %16
  %18 = getelementptr inbounds %struct.FileStr, ptr %17, i32 0, i32 1
  %19 = getelementptr inbounds [256 x i8], ptr %18, i64 0, i64 0
  %20 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %11, ptr noundef @.str.1, ptr noundef @path, ptr noundef %19) #5
  %21 = getelementptr inbounds [1024 x i8], ptr %5, i64 0, i64 0
  %22 = call noalias ptr @fopen(ptr noundef %21, ptr noundef @.str.2)
  store ptr %22, ptr %6, align 8, !tbaa !9
  %23 = load ptr, ptr %6, align 8, !tbaa !9
  %24 = icmp eq ptr %23, null
  br i1 %24, label %25, label %26

25:                                               ; preds = %2
  store i32 1, ptr %7, align 4
  br label %77

26:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %71, %26
  %28 = load i32, ptr %8, align 4, !tbaa !5
  %29 = load ptr, ptr @sectInfo, align 8, !tbaa !9
  %30 = load i32, ptr %4, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds %struct.SectionStr, ptr %29, i64 %31
  %33 = getelementptr inbounds %struct.SectionStr, ptr %32, i32 0, i32 8
  %34 = getelementptr inbounds %struct.ObstructionStr, ptr %33, i32 0, i32 1
  %35 = load i32, ptr %34, align 4, !tbaa !11
  %36 = icmp slt i32 %28, %35
  br i1 %36, label %38, label %37

37:                                               ; preds = %27
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %74

38:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %39 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 136) #6
  store ptr %39, ptr %9, align 8, !tbaa !9
  %40 = load ptr, ptr %9, align 8, !tbaa !9
  %41 = load ptr, ptr %6, align 8, !tbaa !9
  %42 = call i64 @fread(ptr noundef %40, i64 noundef 136, i64 noundef 1, ptr noundef %41)
  %43 = load ptr, ptr %9, align 8, !tbaa !9
  %44 = load ptr, ptr @sectInfo, align 8, !tbaa !9
  %45 = load i32, ptr %4, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds %struct.SectionStr, ptr %44, i64 %46
  %48 = getelementptr inbounds %struct.SectionStr, ptr %47, i32 0, i32 8
  %49 = getelementptr inbounds %struct.ObstructionStr, ptr %48, i32 0, i32 4
  %50 = load ptr, ptr %49, align 8, !tbaa !24
  %51 = load i32, ptr %8, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds %struct.AtomStr, ptr %50, i64 %52
  %54 = getelementptr inbounds %struct.AtomStr, ptr %53, i32 0, i32 0
  store ptr %43, ptr %54, align 8, !tbaa !25
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %55 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 176) #6
  store ptr %55, ptr %10, align 8, !tbaa !9
  %56 = load ptr, ptr %10, align 8, !tbaa !9
  %57 = load ptr, ptr %6, align 8, !tbaa !9
  %58 = call i64 @fread(ptr noundef %56, i64 noundef 176, i64 noundef 1, ptr noundef %57)
  %59 = load ptr, ptr %10, align 8, !tbaa !9
  %60 = load ptr, ptr @sectInfo, align 8, !tbaa !9
  %61 = load i32, ptr %4, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds %struct.SectionStr, ptr %60, i64 %62
  %64 = getelementptr inbounds %struct.SectionStr, ptr %63, i32 0, i32 8
  %65 = getelementptr inbounds %struct.ObstructionStr, ptr %64, i32 0, i32 4
  %66 = load ptr, ptr %65, align 8, !tbaa !24
  %67 = load i32, ptr %8, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds %struct.AtomStr, ptr %66, i64 %68
  %70 = getelementptr inbounds %struct.AtomStr, ptr %69, i32 0, i32 1
  store ptr %59, ptr %70, align 8, !tbaa !26
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %71

71:                                               ; preds = %38
  %72 = load i32, ptr %8, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %8, align 4, !tbaa !5
  br label %27, !llvm.loop !27

74:                                               ; preds = %37
  %75 = load ptr, ptr %6, align 8, !tbaa !9
  %76 = call i32 @fclose(ptr noundef %75)
  store i32 1, ptr %7, align 4
  br label %77

77:                                               ; preds = %74, %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 1024, ptr %5) #5
  ret void
}

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

!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 212}
!12 = !{!"SectionStr", !13, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !7, i64 40, !15, i64 64, !17, i64 120, !18, i64 208, !19, i64 240, !20, i64 288}
!13 = !{!"long", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!"WallStr", !7, i64 0, !7, i64 20, !16, i64 40}
!16 = !{!"AtomStr", !10, i64 0, !10, i64 8}
!17 = !{!"DynamicWallStr", !7, i64 0, !6, i64 16, !6, i64 20, !14, i64 24, !14, i64 32, !14, i64 40, !14, i64 48, !7, i64 56}
!18 = !{!"ObstructionStr", !6, i64 0, !6, i64 4, !10, i64 8, !10, i64 16, !10, i64 24}
!19 = !{!"TunnelStr", !6, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !16, i64 32}
!20 = !{!"FlowStr", !6, i64 0, !21, i64 8, !22, i64 40, !23, i64 88}
!21 = !{!"ConstVStr", !7, i64 0}
!22 = !{!"ForceStr", !7, i64 0, !10, i64 32, !10, i64 40}
!23 = !{!"ChargeStr", !6, i64 0, !6, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!24 = !{!12, !10, i64 232}
!25 = !{!16, !10, i64 0}
!26 = !{!16, !10, i64 8}
!27 = distinct !{!27, !28}
!28 = !{!"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.FileStr = type { i32, [256 x i8] }
%struct.SectionStr = type { i64, double, double, double, double, [20 x i8], %struct.WallStr, %struct.DynamicWallStr, %struct.ObstructionStr, %struct.TunnelStr, %struct.FlowStr }
%struct.WallStr = type { [20 x i8], [20 x i8], %struct.AtomStr }
%struct.AtomStr = type { ptr, ptr }
%struct.DynamicWallStr = type { [16 x i8], i32, i32, double, double, double, double, [4 x double] }
%struct.ObstructionStr = type { i32, i32, ptr, ptr, ptr }
%struct.TunnelStr = type { i32, double, double, double, %struct.AtomStr }
%struct.FlowStr = type { i32, %struct.ConstVStr, %struct.ForceStr, %struct.ChargeStr }
%struct.ConstVStr = type { [4 x double] }
%struct.ForceStr = type { [4 x double], ptr, ptr }
%struct.ChargeStr = type { i32, i32, ptr, ptr, ptr, ptr }

@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@path = external global [1024 x i8], align 16
@files = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@sectInfo = external local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i64 @fread(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nofree nounwind uwtable
define dso_local void @ReadObst(i32 noundef %0, i32 noundef %1) local_unnamed_addr #3 {
  %3 = alloca [1024 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %3) #4
  %4 = load ptr, ptr @files, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 16
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = sext i32 %0 to i64
  %8 = getelementptr inbounds %struct.FileStr, ptr %6, i64 %7, i32 1
  %9 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) @.str.1, ptr noundef nonnull @path, ptr noundef nonnull %8) #4
  %10 = call noalias ptr @fopen(ptr noundef nonnull %3, ptr noundef nonnull @.str.2)
  %11 = icmp eq ptr %10, null
  br i1 %11, label %35, label %.preheader

.preheader:                                       ; preds = %2
  %12 = sext i32 %1 to i64
  %13 = load ptr, ptr @sectInfo, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.SectionStr, ptr %13, i64 %12, i32 8, i32 1
  %15 = load i32, ptr %14, align 4, !tbaa !9
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %17 = tail call i32 @fclose(ptr noundef nonnull %10)
  br label %35

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader ]
  %18 = tail call noalias dereferenceable_or_null(136) ptr @calloc(i64 noundef 1, i64 noundef 136) #5
  %19 = tail call i64 @fread(ptr noundef %18, i64 noundef 136, i64 noundef 1, ptr noundef nonnull %10)
  %20 = load ptr, ptr @sectInfo, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.SectionStr, ptr %20, i64 %12, i32 8, i32 4
  %22 = load ptr, ptr %21, align 8, !tbaa !23
  %23 = getelementptr inbounds %struct.AtomStr, ptr %22, i64 %indvars.iv
  store ptr %18, ptr %23, align 8, !tbaa !24
  %24 = tail call noalias dereferenceable_or_null(176) ptr @calloc(i64 noundef 1, i64 noundef 176) #5
  %25 = tail call i64 @fread(ptr noundef %24, i64 noundef 176, i64 noundef 1, ptr noundef nonnull %10)
  %26 = load ptr, ptr @sectInfo, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.SectionStr, ptr %26, i64 %12, i32 8, i32 4
  %28 = load ptr, ptr %27, align 8, !tbaa !23
  %29 = getelementptr inbounds %struct.AtomStr, ptr %28, i64 %indvars.iv, i32 1
  store ptr %24, ptr %29, align 8, !tbaa !25
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %30 = load ptr, ptr @sectInfo, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.SectionStr, ptr %30, i64 %12, i32 8, i32 1
  %32 = load i32, ptr %31, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = icmp slt i64 %indvars.iv.next, %33
  br i1 %34, label %.lr.ph, label %._crit_edge, !llvm.loop !26

35:                                               ; preds = %2, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %3) #4
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nofree 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 #4 = { nounwind }
attributes #5 = { nounwind allocsize(0,1) }

!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, !16, i64 212}
!10 = !{!"SectionStr", !11, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !7, i64 40, !13, i64 64, !15, i64 120, !17, i64 208, !18, i64 240, !19, i64 288}
!11 = !{!"long", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!"WallStr", !7, i64 0, !7, i64 20, !14, i64 40}
!14 = !{!"AtomStr", !6, i64 0, !6, i64 8}
!15 = !{!"DynamicWallStr", !7, i64 0, !16, i64 16, !16, i64 20, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !7, i64 56}
!16 = !{!"int", !7, i64 0}
!17 = !{!"ObstructionStr", !16, i64 0, !16, i64 4, !6, i64 8, !6, i64 16, !6, i64 24}
!18 = !{!"TunnelStr", !16, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !14, i64 32}
!19 = !{!"FlowStr", !16, i64 0, !20, i64 8, !21, i64 40, !22, i64 88}
!20 = !{!"ConstVStr", !7, i64 0}
!21 = !{!"ForceStr", !7, i64 0, !6, i64 32, !6, i64 40}
!22 = !{!"ChargeStr", !16, i64 0, !16, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!23 = !{!10, !6, i64 232}
!24 = !{!14, !6, i64 0}
!25 = !{!14, !6, i64 8}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}


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