; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R3Shapes/R3PlanarGrid.ll (ZNK12R3PlanarGrid9WriteGridEP8_IO_FILE)

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

%class.R3PlanarGrid = type <{ %class.R3Plane, %class.R3Affine, %class.R2Grid, %class.R3Box, i32, [4 x i8] }>
%class.R3Plane = type { %class.R3Vector, double }
%class.R3Vector = type { [3 x double] }
%class.R3Affine = type { %class.R3Transformation, %class.R4Matrix, %class.R4Matrix, %class.RNFlags }
%class.R3Transformation = type { ptr }
%class.R4Matrix = type { [4 x [4 x double]] }
%class.RNFlags = type { i64 }
%class.R2Grid = type { %class.R2Affine, %class.R2Affine, double, ptr, [2 x i32], i32, i32 }
%class.R2Affine = type <{ %class.R2Transformation, %class.R3Matrix, i32, [4 x i8] }>
%class.R2Transformation = type { ptr }
%class.R3Matrix = type { [3 x [3 x double]] }
%class.R3Box = type { %class.R3Solid, %class.R3Point, %class.R3Point }
%class.R3Solid = type { %class.R3Shape }
%class.R3Shape = type { ptr }
%class.R3Point = type { [3 x double] }

@.str.10 = external hidden unnamed_addr constant [30 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

declare void @_Z6RNFailPKcz(ptr noundef, ...) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK12R3PlanarGrid9WriteGridEP8_IO_FILE(ptr noundef nonnull align 8 dereferenceable(572) %0, ptr noundef %1) #2 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca double, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca double, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %16 = load ptr, ptr %4, align 8
  %17 = getelementptr inbounds %class.R3PlanarGrid, ptr %16, i32 0, i32 2
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = call noundef i32 @_ZNK6R2Grid9WriteGridEP8_IO_FILE(ptr noundef nonnull align 8 dereferenceable(208) %17, ptr noundef %18)
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %22, label %21

21:                                               ; preds = %2
  store i32 0, ptr %3, align 4
  br label %120

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

23:                                               ; preds = %39, %22
  %24 = load i32, ptr %6, align 4, !tbaa !9
  %25 = icmp slt i32 %24, 4
  br i1 %25, label %27, label %26

26:                                               ; preds = %23
  store i32 2, ptr %7, align 4
  br label %42

27:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %28 = getelementptr inbounds %class.R3PlanarGrid, ptr %16, i32 0, i32 0
  %29 = load i32, ptr %6, align 4, !tbaa !9
  %30 = call noundef double @_ZNK7R3PlaneixEi(ptr noundef nonnull align 8 dereferenceable(32) %28, i32 noundef %29)
  store double %30, ptr %8, align 8, !tbaa !11
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = call i64 @fwrite(ptr noundef %8, i64 noundef 8, i64 noundef 1, ptr noundef %31)
  %33 = icmp ne i64 %32, 1
  br i1 %33, label %34, label %35

34:                                               ; preds = %27
  call void (ptr, ...) @_Z6RNFailPKcz(ptr noundef @.str.10)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %36

35:                                               ; preds = %27
  store i32 0, ptr %7, align 4
  br label %36

36:                                               ; preds = %35, %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %37 = load i32, ptr %7, align 4
  switch i32 %37, label %42 [
    i32 0, label %38
  ]

38:                                               ; preds = %36
  br label %39

39:                                               ; preds = %38
  %40 = load i32, ptr %6, align 4, !tbaa !9
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %6, align 4, !tbaa !9
  br label %23, !llvm.loop !13

42:                                               ; preds = %36, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  %43 = load i32, ptr %7, align 4
  switch i32 %43, label %122 [
    i32 2, label %44
    i32 1, label %120
  ]

44:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %45

45:                                               ; preds = %74, %44
  %46 = load i32, ptr %9, align 4, !tbaa !9
  %47 = icmp slt i32 %46, 2
  br i1 %47, label %49, label %48

48:                                               ; preds = %45
  store i32 5, ptr %7, align 4
  br label %77

49:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %68, %49
  %51 = load i32, ptr %10, align 4, !tbaa !9
  %52 = icmp slt i32 %51, 3
  br i1 %52, label %54, label %53

53:                                               ; preds = %50
  store i32 8, ptr %7, align 4
  br label %71

54:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %55 = getelementptr inbounds %class.R3PlanarGrid, ptr %16, i32 0, i32 3
  %56 = load i32, ptr %9, align 4, !tbaa !9
  %57 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %55, i32 noundef %56)
  %58 = load i32, ptr %10, align 4, !tbaa !9
  %59 = call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %57, i32 noundef %58)
  store double %59, ptr %11, align 8, !tbaa !11
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = call i64 @fwrite(ptr noundef %11, i64 noundef 8, i64 noundef 1, ptr noundef %60)
  %62 = icmp ne i64 %61, 1
  br i1 %62, label %63, label %64

63:                                               ; preds = %54
  call void (ptr, ...) @_Z6RNFailPKcz(ptr noundef @.str.10)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %65

64:                                               ; preds = %54
  store i32 0, ptr %7, align 4
  br label %65

65:                                               ; preds = %64, %63
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  %66 = load i32, ptr %7, align 4
  switch i32 %66, label %71 [
    i32 0, label %67
  ]

67:                                               ; preds = %65
  br label %68

68:                                               ; preds = %67
  %69 = load i32, ptr %10, align 4, !tbaa !9
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %10, align 4, !tbaa !9
  br label %50, !llvm.loop !15

71:                                               ; preds = %65, %53
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  %72 = load i32, ptr %7, align 4
  switch i32 %72, label %77 [
    i32 8, label %73
  ]

73:                                               ; preds = %71
  br label %74

74:                                               ; preds = %73
  %75 = load i32, ptr %9, align 4, !tbaa !9
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %9, align 4, !tbaa !9
  br label %45, !llvm.loop !16

77:                                               ; preds = %71, %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  %78 = load i32, ptr %7, align 4
  switch i32 %78, label %122 [
    i32 5, label %79
    i32 1, label %120
  ]

79:                                               ; preds = %77
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %80 = getelementptr inbounds %class.R3PlanarGrid, ptr %16, i32 0, i32 1
  %81 = call noundef nonnull align 8 dereferenceable(128) ptr @_ZNK8R3Affine6MatrixEv(ptr noundef nonnull align 8 dereferenceable(272) %80)
  store ptr %81, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %82

82:                                               ; preds = %113, %79
  %83 = load i32, ptr %13, align 4, !tbaa !9
  %84 = icmp slt i32 %83, 4
  br i1 %84, label %86, label %85

85:                                               ; preds = %82
  store i32 11, ptr %7, align 4
  br label %116

86:                                               ; preds = %82
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %87

87:                                               ; preds = %107, %86
  %88 = load i32, ptr %14, align 4, !tbaa !9
  %89 = icmp slt i32 %88, 4
  br i1 %89, label %91, label %90

90:                                               ; preds = %87
  store i32 14, ptr %7, align 4
  br label %110

91:                                               ; preds = %87
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %92 = load ptr, ptr %12, align 8, !tbaa !5
  %93 = load i32, ptr %13, align 4, !tbaa !9
  %94 = call noundef ptr @_ZNK8R4MatrixixEi(ptr noundef nonnull align 8 dereferenceable(128) %92, i32 noundef %93)
  %95 = load i32, ptr %14, align 4, !tbaa !9
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds double, ptr %94, i64 %96
  %98 = load double, ptr %97, align 8, !tbaa !11
  store double %98, ptr %15, align 8, !tbaa !11
  %99 = load ptr, ptr %5, align 8, !tbaa !5
  %100 = call i64 @fwrite(ptr noundef %15, i64 noundef 8, i64 noundef 1, ptr noundef %99)
  %101 = icmp ne i64 %100, 1
  br i1 %101, label %102, label %103

102:                                              ; preds = %91
  call void (ptr, ...) @_Z6RNFailPKcz(ptr noundef @.str.10)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %104

103:                                              ; preds = %91
  store i32 0, ptr %7, align 4
  br label %104

104:                                              ; preds = %103, %102
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  %105 = load i32, ptr %7, align 4
  switch i32 %105, label %110 [
    i32 0, label %106
  ]

106:                                              ; preds = %104
  br label %107

107:                                              ; preds = %106
  %108 = load i32, ptr %14, align 4, !tbaa !9
  %109 = add nsw i32 %108, 1
  store i32 %109, ptr %14, align 4, !tbaa !9
  br label %87, !llvm.loop !17

110:                                              ; preds = %104, %90
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  %111 = load i32, ptr %7, align 4
  switch i32 %111, label %116 [
    i32 14, label %112
  ]

112:                                              ; preds = %110
  br label %113

113:                                              ; preds = %112
  %114 = load i32, ptr %13, align 4, !tbaa !9
  %115 = add nsw i32 %114, 1
  store i32 %115, ptr %13, align 4, !tbaa !9
  br label %82, !llvm.loop !18

116:                                              ; preds = %110, %85
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  %117 = load i32, ptr %7, align 4
  switch i32 %117, label %119 [
    i32 11, label %118
  ]

118:                                              ; preds = %116
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %119

119:                                              ; preds = %118, %116
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %120

120:                                              ; preds = %119, %77, %42, %21
  %121 = load i32, ptr %3, align 4
  ret i32 %121

122:                                              ; preds = %77, %42
  unreachable
}

declare noundef i32 @_ZNK6R2Grid9WriteGridEP8_IO_FILE(ptr noundef nonnull align 8 dereferenceable(208), ptr noundef) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK7R3PlaneixEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) #3 align 2

declare i64 @fwrite(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56), i32 noundef) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(128) ptr @_ZNK8R3Affine6MatrixEv(ptr noundef nonnull align 8 dereferenceable(272)) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZNK8R4MatrixixEi(ptr noundef nonnull align 8 dereferenceable(128), i32 noundef) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #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 #2 = { mustprogress 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 = { inlinehint mustprogress 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 = { inlinehint mustprogress 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 }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}


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

@.str.10 = external hidden unnamed_addr constant [30 x i8], align 1

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

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

declare void @_Z6RNFailPKcz(ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK12R3PlanarGrid9WriteGridEP8_IO_FILE(ptr noundef nonnull align 8 dereferenceable(572) %0, ptr noundef %1) local_unnamed_addr #2 align 2 {
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = getelementptr inbounds i8, ptr %0, i64 304
  %7 = tail call noundef i32 @_ZNK6R2Grid9WriteGridEP8_IO_FILE(ptr noundef nonnull align 8 dereferenceable(208) %6, ptr noundef %1)
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %.loopexit, label %.preheader69.preheader

.preheader69.preheader:                           ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %8 = tail call noundef double @_ZNK7R3PlaneixEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef 0)
  store double %8, ptr %3, align 8, !tbaa !5
  %9 = call i64 @fwrite(ptr noundef nonnull %3, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not47 = icmp eq i64 %9, 1
  br i1 %.not47, label %.critedge, label %.thread

.thread:                                          ; preds = %.critedge.2, %.critedge.1, %.critedge, %.preheader69.preheader
  tail call void (ptr, ...) @_Z6RNFailPKcz(ptr noundef nonnull @.str.10)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  br label %.loopexit

.critedge:                                        ; preds = %.preheader69.preheader
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %10 = tail call noundef double @_ZNK7R3PlaneixEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef 1)
  store double %10, ptr %3, align 8, !tbaa !5
  %11 = call i64 @fwrite(ptr noundef nonnull %3, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not47.1 = icmp eq i64 %11, 1
  br i1 %.not47.1, label %.critedge.1, label %.thread

.critedge.1:                                      ; preds = %.critedge
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %12 = tail call noundef double @_ZNK7R3PlaneixEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef 2)
  store double %12, ptr %3, align 8, !tbaa !5
  %13 = call i64 @fwrite(ptr noundef nonnull %3, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not47.2 = icmp eq i64 %13, 1
  br i1 %.not47.2, label %.critedge.2, label %.thread

.critedge.2:                                      ; preds = %.critedge.1
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %14 = tail call noundef double @_ZNK7R3PlaneixEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef 3)
  store double %14, ptr %3, align 8, !tbaa !5
  %15 = call i64 @fwrite(ptr noundef nonnull %3, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not47.3 = icmp eq i64 %15, 1
  br i1 %.not47.3, label %.critedge.3, label %.thread

.critedge.3:                                      ; preds = %.critedge.2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  %16 = getelementptr inbounds i8, ptr %0, i64 512
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %17 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %16, i32 noundef 0)
  %18 = tail call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %17, i32 noundef 0)
  store double %18, ptr %4, align 8, !tbaa !5
  %19 = call i64 @fwrite(ptr noundef nonnull %4, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not48 = icmp eq i64 %19, 1
  br i1 %.not48, label %.critedge51, label %40

.critedge51:                                      ; preds = %.critedge.3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %20 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %16, i32 noundef 0)
  %21 = tail call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %20, i32 noundef 1)
  store double %21, ptr %4, align 8, !tbaa !5
  %22 = call i64 @fwrite(ptr noundef nonnull %4, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not48.1 = icmp eq i64 %22, 1
  br i1 %.not48.1, label %.critedge51.1, label %40

.critedge51.1:                                    ; preds = %.critedge51
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %23 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %16, i32 noundef 0)
  %24 = tail call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %23, i32 noundef 2)
  store double %24, ptr %4, align 8, !tbaa !5
  %25 = call i64 @fwrite(ptr noundef nonnull %4, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not48.2 = icmp eq i64 %25, 1
  br i1 %.not48.2, label %.critedge51.2, label %40

.critedge51.2:                                    ; preds = %.critedge51.1
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %26 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %16, i32 noundef 1)
  %27 = tail call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %26, i32 noundef 0)
  store double %27, ptr %4, align 8, !tbaa !5
  %28 = call i64 @fwrite(ptr noundef nonnull %4, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not48.178 = icmp eq i64 %28, 1
  br i1 %.not48.178, label %.critedge51.179, label %40

.critedge51.179:                                  ; preds = %.critedge51.2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %29 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %16, i32 noundef 1)
  %30 = tail call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %29, i32 noundef 1)
  store double %30, ptr %4, align 8, !tbaa !5
  %31 = call i64 @fwrite(ptr noundef nonnull %4, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not48.1.1 = icmp eq i64 %31, 1
  br i1 %.not48.1.1, label %.critedge51.1.1, label %40

.critedge51.1.1:                                  ; preds = %.critedge51.179
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %32 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %16, i32 noundef 1)
  %33 = tail call noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %32, i32 noundef 2)
  store double %33, ptr %4, align 8, !tbaa !5
  %34 = call i64 @fwrite(ptr noundef nonnull %4, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not48.2.1 = icmp eq i64 %34, 1
  br i1 %.not48.2.1, label %.critedge51.2.1, label %40

.critedge51.2.1:                                  ; preds = %.critedge51.1.1
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  %35 = getelementptr inbounds i8, ptr %0, i64 32
  %36 = tail call noundef nonnull align 8 dereferenceable(128) ptr @_ZNK8R3Affine6MatrixEv(ptr noundef nonnull align 8 dereferenceable(272) %35)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %37 = tail call noundef ptr @_ZNK8R4MatrixixEi(ptr noundef nonnull align 8 dereferenceable(128) %36, i32 noundef 0)
  %38 = load double, ptr %37, align 8, !tbaa !5
  store double %38, ptr %5, align 8, !tbaa !5
  %39 = call i64 @fwrite(ptr noundef nonnull %5, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not49 = icmp eq i64 %39, 1
  br i1 %.not49, label %.critedge55, label %41

40:                                               ; preds = %.critedge51.1.1, %.critedge51.179, %.critedge51.2, %.critedge51.1, %.critedge51, %.critedge.3
  tail call void (ptr, ...) @_Z6RNFailPKcz(ptr noundef nonnull @.str.10)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  br label %.loopexit

41:                                               ; preds = %.critedge55.2.3, %.critedge55.1.3, %.critedge55.386, %.critedge55.3.2, %.critedge55.2.2, %.critedge55.1.2, %.critedge55.284, %.critedge55.3.1, %.critedge55.2.1, %.critedge55.1.1, %.critedge55.182, %.critedge55.3, %.critedge55.2, %.critedge55.1, %.critedge55, %.critedge51.2.1
  tail call void (ptr, ...) @_Z6RNFailPKcz(ptr noundef nonnull @.str.10)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  br label %.loopexit

.critedge55:                                      ; preds = %.critedge51.2.1
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %42 = tail call noundef ptr @_ZNK8R4MatrixixEi(ptr noundef nonnull align 8 dereferenceable(128) %36, i32 noundef 0)
  %43 = getelementptr inbounds i8, ptr %42, i64 8
  %44 = load double, ptr %43, align 8, !tbaa !5
  store double %44, ptr %5, align 8, !tbaa !5
  %45 = call i64 @fwrite(ptr noundef nonnull %5, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not49.1 = icmp eq i64 %45, 1
  br i1 %.not49.1, label %.critedge55.1, label %41

.critedge55.1:                                    ; preds = %.critedge55
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %46 = tail call noundef ptr @_ZNK8R4MatrixixEi(ptr noundef nonnull align 8 dereferenceable(128) %36, i32 noundef 0)
  %47 = getelementptr inbounds i8, ptr %46, i64 16
  %48 = load double, ptr %47, align 8, !tbaa !5
  store double %48, ptr %5, align 8, !tbaa !5
  %49 = call i64 @fwrite(ptr noundef nonnull %5, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not49.2 = icmp eq i64 %49, 1
  br i1 %.not49.2, label %.critedge55.2, label %41

.critedge55.2:                                    ; preds = %.critedge55.1
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %50 = tail call noundef ptr @_ZNK8R4MatrixixEi(ptr noundef nonnull align 8 dereferenceable(128) %36, i32 noundef 0)
  %51 = getelementptr inbounds i8, ptr %50, i64 24
  %52 = load double, ptr %51, align 8, !tbaa !5
  store double %52, ptr %5, align 8, !tbaa !5
  %53 = call i64 @fwrite(ptr noundef nonnull %5, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not49.3 = icmp eq i64 %53, 1
  br i1 %.not49.3, label %.critedge55.3, label %41

.critedge55.3:                                    ; preds = %.critedge55.2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %54 = tail call noundef ptr @_ZNK8R4MatrixixEi(ptr noundef nonnull align 8 dereferenceable(128) %36, i32 noundef 1)
  %55 = load double, ptr %54, align 8, !tbaa !5
  store double %55, ptr %5, align 8, !tbaa !5
  %56 = call i64 @fwrite(ptr noundef nonnull %5, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not49.181 = icmp eq i64 %56, 1
  br i1 %.not49.181, label %.critedge55.182, label %41

.critedge55.182:                                  ; preds = %.critedge55.3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %57 = tail call noundef ptr @_ZNK8R4MatrixixEi(ptr noundef nonnull align 8 dereferenceable(128) %36, i32 noundef 1)
  %58 = getelementptr inbounds i8, ptr %57, i64 8
  %59 = load double, ptr %58, align 8, !tbaa !5
  store double %59, ptr %5, align 8, !tbaa !5
  %60 = call i64 @fwrite(ptr noundef nonnull %5, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not49.1.1 = icmp eq i64 %60, 1
  br i1 %.not49.1.1, label %.critedge55.1.1, label %41

.critedge55.1.1:                                  ; preds = %.critedge55.182
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %61 = tail call noundef ptr @_ZNK8R4MatrixixEi(ptr noundef nonnull align 8 dereferenceable(128) %36, i32 noundef 1)
  %62 = getelementptr inbounds i8, ptr %61, i64 16
  %63 = load double, ptr %62, align 8, !tbaa !5
  store double %63, ptr %5, align 8, !tbaa !5
  %64 = call i64 @fwrite(ptr noundef nonnull %5, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not49.2.1 = icmp eq i64 %64, 1
  br i1 %.not49.2.1, label %.critedge55.2.1, label %41

.critedge55.2.1:                                  ; preds = %.critedge55.1.1
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %65 = tail call noundef ptr @_ZNK8R4MatrixixEi(ptr noundef nonnull align 8 dereferenceable(128) %36, i32 noundef 1)
  %66 = getelementptr inbounds i8, ptr %65, i64 24
  %67 = load double, ptr %66, align 8, !tbaa !5
  store double %67, ptr %5, align 8, !tbaa !5
  %68 = call i64 @fwrite(ptr noundef nonnull %5, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not49.3.1 = icmp eq i64 %68, 1
  br i1 %.not49.3.1, label %.critedge55.3.1, label %41

.critedge55.3.1:                                  ; preds = %.critedge55.2.1
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %69 = tail call noundef ptr @_ZNK8R4MatrixixEi(ptr noundef nonnull align 8 dereferenceable(128) %36, i32 noundef 2)
  %70 = load double, ptr %69, align 8, !tbaa !5
  store double %70, ptr %5, align 8, !tbaa !5
  %71 = call i64 @fwrite(ptr noundef nonnull %5, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not49.283 = icmp eq i64 %71, 1
  br i1 %.not49.283, label %.critedge55.284, label %41

.critedge55.284:                                  ; preds = %.critedge55.3.1
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %72 = tail call noundef ptr @_ZNK8R4MatrixixEi(ptr noundef nonnull align 8 dereferenceable(128) %36, i32 noundef 2)
  %73 = getelementptr inbounds i8, ptr %72, i64 8
  %74 = load double, ptr %73, align 8, !tbaa !5
  store double %74, ptr %5, align 8, !tbaa !5
  %75 = call i64 @fwrite(ptr noundef nonnull %5, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not49.1.2 = icmp eq i64 %75, 1
  br i1 %.not49.1.2, label %.critedge55.1.2, label %41

.critedge55.1.2:                                  ; preds = %.critedge55.284
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %76 = tail call noundef ptr @_ZNK8R4MatrixixEi(ptr noundef nonnull align 8 dereferenceable(128) %36, i32 noundef 2)
  %77 = getelementptr inbounds i8, ptr %76, i64 16
  %78 = load double, ptr %77, align 8, !tbaa !5
  store double %78, ptr %5, align 8, !tbaa !5
  %79 = call i64 @fwrite(ptr noundef nonnull %5, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not49.2.2 = icmp eq i64 %79, 1
  br i1 %.not49.2.2, label %.critedge55.2.2, label %41

.critedge55.2.2:                                  ; preds = %.critedge55.1.2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %80 = tail call noundef ptr @_ZNK8R4MatrixixEi(ptr noundef nonnull align 8 dereferenceable(128) %36, i32 noundef 2)
  %81 = getelementptr inbounds i8, ptr %80, i64 24
  %82 = load double, ptr %81, align 8, !tbaa !5
  store double %82, ptr %5, align 8, !tbaa !5
  %83 = call i64 @fwrite(ptr noundef nonnull %5, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not49.3.2 = icmp eq i64 %83, 1
  br i1 %.not49.3.2, label %.critedge55.3.2, label %41

.critedge55.3.2:                                  ; preds = %.critedge55.2.2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %84 = tail call noundef ptr @_ZNK8R4MatrixixEi(ptr noundef nonnull align 8 dereferenceable(128) %36, i32 noundef 3)
  %85 = load double, ptr %84, align 8, !tbaa !5
  store double %85, ptr %5, align 8, !tbaa !5
  %86 = call i64 @fwrite(ptr noundef nonnull %5, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not49.385 = icmp eq i64 %86, 1
  br i1 %.not49.385, label %.critedge55.386, label %41

.critedge55.386:                                  ; preds = %.critedge55.3.2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %87 = tail call noundef ptr @_ZNK8R4MatrixixEi(ptr noundef nonnull align 8 dereferenceable(128) %36, i32 noundef 3)
  %88 = getelementptr inbounds i8, ptr %87, i64 8
  %89 = load double, ptr %88, align 8, !tbaa !5
  store double %89, ptr %5, align 8, !tbaa !5
  %90 = call i64 @fwrite(ptr noundef nonnull %5, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not49.1.3 = icmp eq i64 %90, 1
  br i1 %.not49.1.3, label %.critedge55.1.3, label %41

.critedge55.1.3:                                  ; preds = %.critedge55.386
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %91 = tail call noundef ptr @_ZNK8R4MatrixixEi(ptr noundef nonnull align 8 dereferenceable(128) %36, i32 noundef 3)
  %92 = getelementptr inbounds i8, ptr %91, i64 16
  %93 = load double, ptr %92, align 8, !tbaa !5
  store double %93, ptr %5, align 8, !tbaa !5
  %94 = call i64 @fwrite(ptr noundef nonnull %5, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not49.2.3 = icmp eq i64 %94, 1
  br i1 %.not49.2.3, label %.critedge55.2.3, label %41

.critedge55.2.3:                                  ; preds = %.critedge55.1.3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %95 = tail call noundef ptr @_ZNK8R4MatrixixEi(ptr noundef nonnull align 8 dereferenceable(128) %36, i32 noundef 3)
  %96 = getelementptr inbounds i8, ptr %95, i64 24
  %97 = load double, ptr %96, align 8, !tbaa !5
  store double %97, ptr %5, align 8, !tbaa !5
  %98 = call i64 @fwrite(ptr noundef nonnull %5, i64 noundef 8, i64 noundef 1, ptr noundef %1)
  %.not49.3.3 = icmp eq i64 %98, 1
  br i1 %.not49.3.3, label %.critedge55.3.3, label %41

.critedge55.3.3:                                  ; preds = %.critedge55.2.3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  br label %.loopexit

.loopexit:                                        ; preds = %41, %.critedge55.3.3, %40, %.thread, %2
  %.14 = phi i32 [ 0, %40 ], [ 0, %2 ], [ 0, %.thread ], [ 0, %41 ], [ 1, %.critedge55.3.3 ]
  ret i32 %.14
}

declare noundef i32 @_ZNK6R2Grid9WriteGridEP8_IO_FILE(ptr noundef nonnull align 8 dereferenceable(208), ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK7R3PlaneixEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) local_unnamed_addr #3 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56), i32 noundef) local_unnamed_addr #5 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(128) ptr @_ZNK8R3Affine6MatrixEv(ptr noundef nonnull align 8 dereferenceable(272)) local_unnamed_addr #5 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZNK8R4MatrixixEi(ptr noundef nonnull align 8 dereferenceable(128), i32 noundef) local_unnamed_addr #3 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #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 #2 = { mustprogress 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 = { inlinehint mustprogress 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 = { 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 #5 = { inlinehint mustprogress 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 #6 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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