; LLVM IR from dssgabriel/lattice-boltzmann-method :: v0-base/src (display)

; 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.lbm_data_file_s = type { ptr, %struct.lbm_file_header_s, ptr }
%struct.lbm_file_header_s = type { i32, i32, i32, i32 }
%struct.lbm_file_entry_s = type { float, float }

@.str.11 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [2 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
define dso_local void @print_current_frame_gnuplot(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.lbm_data_file_s, ptr %9, i32 0, i32 1
  %11 = getelementptr inbounds %struct.lbm_file_header_s, ptr %10, i32 0, i32 2
  %12 = load i32, ptr %11, align 8, !tbaa !9
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.lbm_data_file_s, ptr %13, i32 0, i32 1
  %15 = getelementptr inbounds %struct.lbm_file_header_s, ptr %14, i32 0, i32 3
  %16 = load i32, ptr %15, align 4, !tbaa !13
  %17 = udiv i32 %12, %16
  store i32 %17, ptr %3, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store i64 0, ptr %4, align 8, !tbaa !15
  br label %18

18:                                               ; preds = %95, %1
  %19 = load i64, ptr %4, align 8, !tbaa !15
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.lbm_data_file_s, ptr %20, i32 0, i32 1
  %22 = getelementptr inbounds %struct.lbm_file_header_s, ptr %21, i32 0, i32 1
  %23 = load i32, ptr %22, align 4, !tbaa !17
  %24 = zext i32 %23 to i64
  %25 = icmp ult i64 %19, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %18
  store i32 2, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %98

27:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !15
  br label %28

28:                                               ; preds = %90, %27
  %29 = load i64, ptr %6, align 8, !tbaa !15
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.lbm_data_file_s, ptr %30, i32 0, i32 1
  %32 = getelementptr inbounds %struct.lbm_file_header_s, ptr %31, i32 0, i32 3
  %33 = load i32, ptr %32, align 4, !tbaa !13
  %34 = zext i32 %33 to i64
  %35 = icmp ult i64 %29, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %28
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %93

37:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store i64 0, ptr %7, align 8, !tbaa !15
  br label %38

38:                                               ; preds = %86, %37
  %39 = load i64, ptr %7, align 8, !tbaa !15
  %40 = load i32, ptr %3, align 4, !tbaa !14
  %41 = zext i32 %40 to i64
  %42 = icmp ult i64 %39, %41
  br i1 %42, label %44, label %43

43:                                               ; preds = %38
  store i32 8, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %89

44:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %45 = load i32, ptr %3, align 4, !tbaa !14
  %46 = zext i32 %45 to i64
  %47 = load i64, ptr %4, align 8, !tbaa !15
  %48 = mul i64 %46, %47
  %49 = load i64, ptr %7, align 8, !tbaa !15
  %50 = add i64 %48, %49
  %51 = load i64, ptr %6, align 8, !tbaa !15
  %52 = load i32, ptr %3, align 4, !tbaa !14
  %53 = zext i32 %52 to i64
  %54 = mul i64 %51, %53
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.lbm_data_file_s, ptr %55, i32 0, i32 1
  %57 = getelementptr inbounds %struct.lbm_file_header_s, ptr %56, i32 0, i32 1
  %58 = load i32, ptr %57, align 4, !tbaa !17
  %59 = zext i32 %58 to i64
  %60 = mul i64 %54, %59
  %61 = add i64 %50, %60
  store i64 %61, ptr %8, align 8, !tbaa !15
  %62 = load i64, ptr %4, align 8, !tbaa !15
  %63 = load i64, ptr %7, align 8, !tbaa !15
  %64 = load i64, ptr %6, align 8, !tbaa !15
  %65 = load i32, ptr %3, align 4, !tbaa !14
  %66 = zext i32 %65 to i64
  %67 = mul i64 %64, %66
  %68 = add i64 %63, %67
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.lbm_data_file_s, ptr %69, i32 0, i32 2
  %71 = load ptr, ptr %70, align 8, !tbaa !18
  %72 = load i64, ptr %8, align 8, !tbaa !15
  %73 = getelementptr inbounds %struct.lbm_file_entry_s, ptr %71, i64 %72
  %74 = getelementptr inbounds %struct.lbm_file_entry_s, ptr %73, i32 0, i32 1
  %75 = load float, ptr %74, align 4, !tbaa !19
  %76 = fpext float %75 to double
  %77 = load ptr, ptr %2, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.lbm_data_file_s, ptr %77, i32 0, i32 2
  %79 = load ptr, ptr %78, align 8, !tbaa !18
  %80 = load i64, ptr %8, align 8, !tbaa !15
  %81 = getelementptr inbounds %struct.lbm_file_entry_s, ptr %79, i64 %80
  %82 = getelementptr inbounds %struct.lbm_file_entry_s, ptr %81, i32 0, i32 0
  %83 = load float, ptr %82, align 4, !tbaa !22
  %84 = fpext float %83 to double
  %85 = call i32 (ptr, ...) @printf(ptr noundef @.str.11, i64 noundef %62, i64 noundef %68, double noundef %76, double noundef %84)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %86

86:                                               ; preds = %44
  %87 = load i64, ptr %7, align 8, !tbaa !15
  %88 = add i64 %87, 1
  store i64 %88, ptr %7, align 8, !tbaa !15
  br label %38, !llvm.loop !23

89:                                               ; preds = %43
  br label %90

90:                                               ; preds = %89
  %91 = load i64, ptr %6, align 8, !tbaa !15
  %92 = add i64 %91, 1
  store i64 %92, ptr %6, align 8, !tbaa !15
  br label %28, !llvm.loop !25

93:                                               ; preds = %36
  %94 = call i32 (ptr, ...) @printf(ptr noundef @.str.12)
  br label %95

95:                                               ; preds = %93
  %96 = load i64, ptr %4, align 8, !tbaa !15
  %97 = add i64 %96, 1
  store i64 %97, ptr %4, align 8, !tbaa !15
  br label %18, !llvm.loop !26

98:                                               ; preds = %26
  %99 = call i32 (ptr, ...) @printf(ptr noundef @.str.12)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret void
}

declare i32 @printf(ptr noundef, ...) #2

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 = { "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 }

!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, !12, i64 16}
!10 = !{!"lbm_data_file_s", !6, i64 0, !11, i64 8, !6, i64 24}
!11 = !{!"lbm_file_header_s", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !12, i64 20}
!14 = !{!12, !12, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!10, !12, i64 12}
!18 = !{!10, !6, i64 24}
!19 = !{!20, !21, i64 4}
!20 = !{!"lbm_file_entry_s", !21, i64 0, !21, i64 4}
!21 = !{!"float", !7, i64 0}
!22 = !{!20, !21, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = distinct !{!25, !24}
!26 = distinct !{!26, !24}


; 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.lbm_file_entry_s = type { float, float }

@.str.11 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local void @print_current_frame_gnuplot(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 20
  %3 = getelementptr inbounds i8, ptr %0, i64 12
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %._crit_edge, label %.preheader27.lr.ph

.preheader27.lr.ph:                               ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load i32, ptr %5, align 8, !tbaa !12
  %7 = load i32, ptr %2, align 4, !tbaa !13
  %8 = udiv i32 %6, %7
  %9 = zext i32 %8 to i64
  %10 = icmp ule i32 %7, %6
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %.fr = freeze i1 %10
  br i1 %.fr, label %.preheader27.us, label %.preheader27

.preheader27.us:                                  ; preds = %.preheader27.lr.ph, %._crit_edge30.split.us.us
  %.031.us = phi i64 [ %14, %._crit_edge30.split.us.us ], [ 0, %.preheader27.lr.ph ]
  %12 = load i32, ptr %2, align 4, !tbaa !13
  %.not34 = icmp eq i32 %12, 0
  br i1 %.not34, label %._crit_edge30.split.us.us, label %.preheader.lr.ph.us

._crit_edge30.split.us.us:                        ; preds = %._crit_edge.us.us, %.preheader27.us
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12)
  %14 = add nuw nsw i64 %.031.us, 1
  %15 = load i32, ptr %3, align 4, !tbaa !5
  %16 = zext i32 %15 to i64
  %17 = icmp ult i64 %14, %16
  br i1 %17, label %.preheader27.us, label %._crit_edge, !llvm.loop !14

.preheader.lr.ph.us:                              ; preds = %.preheader27.us
  %18 = mul nuw i64 %.031.us, %9
  br label %.preheader.us.us

.preheader.us.us:                                 ; preds = %._crit_edge.us.us, %.preheader.lr.ph.us
  %.02529.us.us = phi i64 [ 0, %.preheader.lr.ph.us ], [ %37, %._crit_edge.us.us ]
  %19 = mul nuw i64 %.02529.us.us, %9
  br label %20

20:                                               ; preds = %20, %.preheader.us.us
  %.02428.us.us = phi i64 [ 0, %.preheader.us.us ], [ %35, %20 ]
  %21 = load i32, ptr %3, align 4, !tbaa !5
  %22 = zext i32 %21 to i64
  %23 = mul i64 %19, %22
  %24 = add nuw i64 %.02428.us.us, %19
  %25 = load ptr, ptr %11, align 8, !tbaa !16
  %26 = getelementptr %struct.lbm_file_entry_s, ptr %25, i64 %18
  %27 = getelementptr %struct.lbm_file_entry_s, ptr %26, i64 %.02428.us.us
  %28 = getelementptr %struct.lbm_file_entry_s, ptr %27, i64 %23
  %29 = getelementptr inbounds i8, ptr %28, i64 4
  %30 = load float, ptr %29, align 4, !tbaa !17
  %31 = fpext float %30 to double
  %32 = load float, ptr %28, align 4, !tbaa !20
  %33 = fpext float %32 to double
  %34 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, i64 noundef %.031.us, i64 noundef %24, double noundef %31, double noundef %33)
  %35 = add nuw nsw i64 %.02428.us.us, 1
  %36 = icmp ult i64 %35, %9
  br i1 %36, label %20, label %._crit_edge.us.us, !llvm.loop !21

._crit_edge.us.us:                                ; preds = %20
  %37 = add nuw nsw i64 %.02529.us.us, 1
  %38 = load i32, ptr %2, align 4, !tbaa !13
  %39 = zext i32 %38 to i64
  %40 = icmp ult i64 %37, %39
  br i1 %40, label %.preheader.us.us, label %._crit_edge30.split.us.us, !llvm.loop !22

.preheader27:                                     ; preds = %.preheader27.lr.ph, %.preheader27
  %.031 = phi i64 [ %42, %.preheader27 ], [ 0, %.preheader27.lr.ph ]
  %41 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12)
  %42 = add nuw nsw i64 %.031, 1
  %43 = load i32, ptr %3, align 4, !tbaa !5
  %44 = zext i32 %43 to i64
  %45 = icmp ult i64 %42, %44
  br i1 %45, label %.preheader27, label %._crit_edge, !llvm.loop !14

._crit_edge:                                      ; preds = %.preheader27, %._crit_edge30.split.us.us, %1
  %46 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12)
  ret void
}

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

attributes #0 = { 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 #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" }

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


; Effective O3 passes: ADCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass