; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R2Shapes/R2Grid.ll (ZN6R2Grid8ReadGridEP8_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.R2Affine = type <{ %class.R2Transformation, %class.R3Matrix, i32, [4 x i8] }>
%class.R2Transformation = type { ptr }
%class.R3Matrix = type { [3 x [3 x double]] }
%class.R2Grid = type { %class.R2Affine, %class.R2Affine, double, ptr, [2 x i32], i32, i32 }

@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [88 x i8], align 1
@RN_EPSILON = external global double, align 8
@stderr = external global ptr, align 8
@.str.27 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.69 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.70 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.71 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.72 = external hidden unnamed_addr constant [33 x i8], align 1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #0

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #1

declare void @_Z7RNAbortPKcz(ptr noundef, ...) #2

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(84) ptr @_ZN8R2AffineaSERKS_(ptr noundef nonnull align 8 dereferenceable(84), ptr noundef nonnull align 8 dereferenceable(84)) #4 align 2

; Function Attrs: nounwind
declare void @_ZN16R2TransformationD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #5

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK8R2Affine7InverseEv(ptr dead_on_unwind noalias writable sret(%class.R2Affine) align 8, ptr noundef nonnull align 8 dereferenceable(84)) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z9RNIsEqualddd(double noundef, double noundef, double noundef) #4

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

declare noundef double @_ZNK8R2Affine11ScaleFactorEv(ptr noundef nonnull align 8 dereferenceable(84)) #2

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN6R2Grid8ReadGridEP8_IO_FILE(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr noundef %1) #6 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca [9 x double], align 16
  %7 = alloca i32, align 4
  %8 = alloca %class.R3Matrix, align 8
  %9 = alloca %class.R2Affine, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %15 = load ptr, ptr %4, align 8
  %16 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 4
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = call i64 @fread(ptr noundef %16, i64 noundef 4, i64 noundef 2, ptr noundef %17)
  %19 = icmp ne i64 %18, 2
  br i1 %19, label %20, label %21

20:                                               ; preds = %2
  call void (ptr, ...) @_Z6RNFailPKcz(ptr noundef @.str.69)
  store i32 0, ptr %3, align 4
  br label %136

21:                                               ; preds = %2
  %22 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 4
  %23 = getelementptr inbounds [2 x i32], ptr %22, i64 0, i64 0
  %24 = load i32, ptr %23, align 8, !tbaa !9
  %25 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 5
  store i32 %24, ptr %25, align 8, !tbaa !11
  %26 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 5
  %27 = load i32, ptr %26, align 8, !tbaa !11
  %28 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 4
  %29 = getelementptr inbounds [2 x i32], ptr %28, i64 0, i64 1
  %30 = load i32, ptr %29, align 4, !tbaa !9
  %31 = mul nsw i32 %27, %30
  %32 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 6
  store i32 %31, ptr %32, align 4, !tbaa !17
  %33 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 6
  %34 = load i32, ptr %33, align 4, !tbaa !17
  %35 = icmp sle i32 %34, 0
  br i1 %35, label %36, label %39

36:                                               ; preds = %21
  %37 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 6
  %38 = load i32, ptr %37, align 4, !tbaa !17
  call void (ptr, ...) @_Z6RNFailPKcz(ptr noundef @.str.70, i32 noundef %38)
  store i32 0, ptr %3, align 4
  br label %136

39:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 72, ptr %6) #7
  %40 = getelementptr inbounds [9 x double], ptr %6, i64 0, i64 0
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = call i64 @fread(ptr noundef %40, i64 noundef 8, i64 noundef 9, ptr noundef %41)
  %43 = icmp ne i64 %42, 9
  br i1 %43, label %44, label %45

44:                                               ; preds = %39
  call void (ptr, ...) @_Z6RNFailPKcz(ptr noundef @.str.71)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %135

45:                                               ; preds = %39
  %46 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 72, ptr %8) #7
  %47 = getelementptr inbounds [9 x double], ptr %6, i64 0, i64 0
  call void @_ZN8R3MatrixC1EPKd(ptr noundef nonnull align 8 dereferenceable(72) %8, ptr noundef %47)
  call void @_ZN8R2Affine5ResetERK8R3Matrixi(ptr noundef nonnull align 8 dereferenceable(84) %46, ptr noundef nonnull align 8 dereferenceable(72) %8, i32 noundef 0)
  call void @llvm.lifetime.end.p0(i64 72, ptr %8) #7
  %48 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 1
  %49 = call noundef double @_ZNK8R2Affine11ScaleFactorEv(ptr noundef nonnull align 8 dereferenceable(84) %48)
  %50 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 2
  store double %49, ptr %50, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 88, ptr %9) #7
  %51 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 1
  call void @_ZNK8R2Affine7InverseEv(ptr dead_on_unwind writable sret(%class.R2Affine) align 8 %9, ptr noundef nonnull align 8 dereferenceable(84) %51)
  %52 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 0
  %53 = invoke noundef nonnull align 8 dereferenceable(84) ptr @_ZN8R2AffineaSERKS_(ptr noundef nonnull align 8 dereferenceable(84) %52, ptr noundef nonnull align 8 dereferenceable(84) %9)
          to label %54 unwind label %68

54:                                               ; preds = %45
  call void @_ZN16R2TransformationD2Ev(ptr noundef nonnull align 8 dereferenceable(84) %9) #7
  call void @llvm.lifetime.end.p0(i64 88, ptr %9) #7
  %55 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 6
  %56 = load i32, ptr %55, align 4, !tbaa !17
  %57 = sext i32 %56 to i64
  %58 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %57, i64 8)
  %59 = extractvalue { i64, i1 } %58, 1
  %60 = extractvalue { i64, i1 } %58, 0
  %61 = select i1 %59, i64 -1, i64 %60
  %62 = call noalias noundef nonnull ptr @_Znam(i64 noundef %61) #8
  %63 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 3
  store ptr %62, ptr %63, align 8, !tbaa !19
  %64 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 3
  %65 = load ptr, ptr %64, align 8, !tbaa !19
  %66 = icmp ne ptr %65, null
  br i1 %66, label %72, label %67

67:                                               ; preds = %54
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.27, i32 noundef 3821, ptr noundef @.str.2)
  br label %72

68:                                               ; preds = %45
  %69 = landingpad { ptr, i32 }
          cleanup
  %70 = extractvalue { ptr, i32 } %69, 0
  store ptr %70, ptr %10, align 8
  %71 = extractvalue { ptr, i32 } %69, 1
  store i32 %71, ptr %11, align 4
  call void @_ZN16R2TransformationD2Ev(ptr noundef nonnull align 8 dereferenceable(84) %9) #7
  call void @llvm.lifetime.end.p0(i64 88, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 72, ptr %6) #7
  br label %138

72:                                               ; preds = %67, %54
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %73 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 6
  %74 = load i32, ptr %73, align 4, !tbaa !17
  store i32 %74, ptr %12, align 4, !tbaa !9
  br label %75

75:                                               ; preds = %103, %72
  %76 = load i32, ptr %12, align 4, !tbaa !9
  %77 = icmp sgt i32 %76, 0
  br i1 %77, label %78, label %104

78:                                               ; preds = %75
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  %79 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 3
  %80 = load ptr, ptr %79, align 8, !tbaa !19
  %81 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 6
  %82 = load i32, ptr %81, align 4, !tbaa !17
  %83 = load i32, ptr %12, align 4, !tbaa !9
  %84 = sub nsw i32 %82, %83
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds double, ptr %80, i64 %85
  %87 = load i32, ptr %12, align 4, !tbaa !9
  %88 = sext i32 %87 to i64
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = call i64 @fread(ptr noundef %86, i64 noundef 8, i64 noundef %88, ptr noundef %89)
  %91 = trunc i64 %90 to i32
  store i32 %91, ptr %13, align 4, !tbaa !9
  %92 = load i32, ptr %13, align 4, !tbaa !9
  %93 = icmp slt i32 %92, 0
  br i1 %93, label %94, label %97

94:                                               ; preds = %78
  %95 = load ptr, ptr @stderr, align 8, !tbaa !5
  %96 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %95, ptr noundef @.str.72) #7
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %101

97:                                               ; preds = %78
  %98 = load i32, ptr %13, align 4, !tbaa !9
  %99 = load i32, ptr %12, align 4, !tbaa !9
  %100 = sub nsw i32 %99, %98
  store i32 %100, ptr %12, align 4, !tbaa !9
  store i32 0, ptr %7, align 4
  br label %101

101:                                              ; preds = %97, %94
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  %102 = load i32, ptr %7, align 4
  switch i32 %102, label %134 [
    i32 0, label %103
  ]

103:                                              ; preds = %101
  br label %75, !llvm.loop !20

104:                                              ; preds = %75
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %105

105:                                              ; preds = %128, %104
  %106 = load i32, ptr %14, align 4, !tbaa !9
  %107 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 6
  %108 = load i32, ptr %107, align 4, !tbaa !17
  %109 = icmp slt i32 %106, %108
  br i1 %109, label %111, label %110

110:                                              ; preds = %105
  store i32 4, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %131

111:                                              ; preds = %105
  %112 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 3
  %113 = load ptr, ptr %112, align 8, !tbaa !19
  %114 = load i32, ptr %14, align 4, !tbaa !9
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds double, ptr %113, i64 %115
  %117 = load double, ptr %116, align 8, !tbaa !22
  %118 = load double, ptr @RN_EPSILON, align 8, !tbaa !22
  %119 = call noundef i32 @_Z9RNIsEqualddd(double noundef %117, double noundef -3.210000e+02, double noundef %118)
  %120 = icmp ne i32 %119, 0
  br i1 %120, label %121, label %127

121:                                              ; preds = %111
  %122 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 3
  %123 = load ptr, ptr %122, align 8, !tbaa !19
  %124 = load i32, ptr %14, align 4, !tbaa !9
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds double, ptr %123, i64 %125
  store double -3.210000e+02, ptr %126, align 8, !tbaa !22
  br label %127

127:                                              ; preds = %121, %111
  br label %128

128:                                              ; preds = %127
  %129 = load i32, ptr %14, align 4, !tbaa !9
  %130 = add nsw i32 %129, 1
  store i32 %130, ptr %14, align 4, !tbaa !9
  br label %105, !llvm.loop !23

131:                                              ; preds = %110
  %132 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 6
  %133 = load i32, ptr %132, align 4, !tbaa !17
  store i32 %133, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %134

134:                                              ; preds = %131, %101
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %135

135:                                              ; preds = %134, %44
  call void @llvm.lifetime.end.p0(i64 72, ptr %6) #7
  br label %136

136:                                              ; preds = %135, %36, %20
  %137 = load i32, ptr %3, align 4
  ret i32 %137

138:                                              ; preds = %68
  %139 = load ptr, ptr %10, align 8
  %140 = load i32, ptr %11, align 4
  %141 = insertvalue { ptr, i32 } poison, ptr %139, 0
  %142 = insertvalue { ptr, i32 } %141, i32 %140, 1
  resume { ptr, i32 } %142
}

declare void @_ZN8R2Affine5ResetERK8R3Matrixi(ptr noundef nonnull align 8 dereferenceable(84), ptr noundef nonnull align 8 dereferenceable(72), i32 noundef) #2

declare void @_ZN8R3MatrixC1EPKd(ptr noundef nonnull align 8 dereferenceable(72), ptr noundef) unnamed_addr #2

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

!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, !10, i64 200}
!12 = !{!"_ZTS6R2Grid", !13, i64 0, !13, i64 88, !16, i64 176, !6, i64 184, !7, i64 192, !10, i64 200, !10, i64 204}
!13 = !{!"_ZTS8R2Affine", !14, i64 0, !15, i64 8, !10, i64 80}
!14 = !{!"_ZTS16R2Transformation"}
!15 = !{!"_ZTS8R3Matrix", !7, i64 0}
!16 = !{!"double", !7, i64 0}
!17 = !{!12, !10, i64 204}
!18 = !{!12, !16, i64 176}
!19 = !{!12, !6, i64 184}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!16, !16, i64 0}
!23 = distinct !{!23, !21}


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

%class.R2Affine = type <{ %class.R2Transformation, %class.R3Matrix, i32, [4 x i8] }>
%class.R2Transformation = type { ptr }
%class.R3Matrix = type { [3 x [3 x double]] }

@RN_EPSILON = external local_unnamed_addr global double, align 8
@stderr = external local_unnamed_addr global ptr, align 8
@.str.69 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.70 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.71 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.72 = external hidden unnamed_addr constant [33 x i8], align 1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #0

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(84) ptr @_ZN8R2AffineaSERKS_(ptr noundef nonnull align 8 dereferenceable(84), ptr noundef nonnull align 8 dereferenceable(84)) local_unnamed_addr #2 align 2

; Function Attrs: nounwind
declare void @_ZN16R2TransformationD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK8R2Affine7InverseEv(ptr dead_on_unwind noalias writable sret(%class.R2Affine) align 8, ptr noundef nonnull align 8 dereferenceable(84)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z9RNIsEqualddd(double noundef, double noundef, double noundef) local_unnamed_addr #2

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

declare noundef double @_ZNK8R2Affine11ScaleFactorEv(ptr noundef nonnull align 8 dereferenceable(84)) local_unnamed_addr #5

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN6R2Grid8ReadGridEP8_IO_FILE(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr nocapture noundef %1) local_unnamed_addr #6 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca [9 x double], align 16
  %4 = alloca %class.R3Matrix, align 8
  %5 = alloca %class.R2Affine, align 8
  %6 = getelementptr inbounds i8, ptr %0, i64 192
  %7 = tail call i64 @fread(ptr noundef nonnull %6, i64 noundef 4, i64 noundef 2, ptr noundef %1)
  %.not = icmp eq i64 %7, 2
  br i1 %.not, label %9, label %8

8:                                                ; preds = %2
  tail call void (ptr, ...) @_Z6RNFailPKcz(ptr noundef nonnull @.str.69)
  br label %64

9:                                                ; preds = %2
  %10 = load i32, ptr %6, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 200
  store i32 %10, ptr %11, align 8, !tbaa !9
  %12 = getelementptr inbounds i8, ptr %0, i64 196
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = mul nsw i32 %13, %10
  %15 = getelementptr inbounds i8, ptr %0, i64 204
  store i32 %14, ptr %15, align 4, !tbaa !16
  %16 = icmp slt i32 %14, 1
  br i1 %16, label %17, label %18

17:                                               ; preds = %9
  tail call void (ptr, ...) @_Z6RNFailPKcz(ptr noundef nonnull @.str.70, i32 noundef %14)
  br label %64

18:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %3) #7
  %19 = call i64 @fread(ptr noundef nonnull %3, i64 noundef 8, i64 noundef 9, ptr noundef %1)
  %.not24 = icmp eq i64 %19, 9
  br i1 %.not24, label %21, label %20

20:                                               ; preds = %18
  tail call void (ptr, ...) @_Z6RNFailPKcz(ptr noundef nonnull @.str.71)
  br label %.loopexit

21:                                               ; preds = %18
  %22 = getelementptr inbounds i8, ptr %0, i64 88
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %4) #7
  call void @_ZN8R3MatrixC1EPKd(ptr noundef nonnull align 8 dereferenceable(72) %4, ptr noundef nonnull %3)
  call void @_ZN8R2Affine5ResetERK8R3Matrixi(ptr noundef nonnull align 8 dereferenceable(84) %22, ptr noundef nonnull align 8 dereferenceable(72) %4, i32 noundef 0)
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %4) #7
  %23 = call noundef double @_ZNK8R2Affine11ScaleFactorEv(ptr noundef nonnull align 8 dereferenceable(84) %22)
  %24 = getelementptr inbounds i8, ptr %0, i64 176
  store double %23, ptr %24, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 88, ptr nonnull %5) #7
  call void @_ZNK8R2Affine7InverseEv(ptr dead_on_unwind nonnull writable sret(%class.R2Affine) align 8 %5, ptr noundef nonnull align 8 dereferenceable(84) %22)
  %25 = invoke noundef nonnull align 8 dereferenceable(84) ptr @_ZN8R2AffineaSERKS_(ptr noundef nonnull align 8 dereferenceable(84) %0, ptr noundef nonnull align 8 dereferenceable(84) %5)
          to label %26 unwind label %35

26:                                               ; preds = %21
  call void @_ZN16R2TransformationD2Ev(ptr noundef nonnull align 8 dereferenceable(84) %5) #7
  call void @llvm.lifetime.end.p0(i64 88, ptr nonnull %5) #7
  %27 = load i32, ptr %15, align 4, !tbaa !16
  %28 = sext i32 %27 to i64
  %29 = icmp slt i32 %27, 0
  %30 = shl nsw i64 %28, 3
  %31 = select i1 %29, i64 -1, i64 %30
  %32 = call noalias noundef nonnull ptr @_Znam(i64 noundef %31) #8
  %33 = getelementptr inbounds i8, ptr %0, i64 184
  store ptr %32, ptr %33, align 8, !tbaa !18
  %34 = icmp sgt i32 %27, 0
  br i1 %34, label %.lr.ph, label %.loopexit

35:                                               ; preds = %21
  %36 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN16R2TransformationD2Ev(ptr noundef nonnull align 8 dereferenceable(84) %5) #7
  call void @llvm.lifetime.end.p0(i64 88, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %3) #7
  resume { ptr, i32 } %36

37:                                               ; preds = %.lr.ph
  %38 = sub nsw i32 %.01827, %48
  %39 = icmp sgt i32 %38, 0
  br i1 %39, label %.lr.ph, label %.preheader, !llvm.loop !19

.preheader:                                       ; preds = %37
  %.pre = load i32, ptr %15, align 4, !tbaa !16
  %40 = icmp sgt i32 %.pre, 0
  br i1 %40, label %.lr.ph29, label %.loopexit

.lr.ph:                                           ; preds = %26, %37
  %.01827 = phi i32 [ %38, %37 ], [ %27, %26 ]
  %41 = load ptr, ptr %33, align 8, !tbaa !18
  %42 = load i32, ptr %15, align 4, !tbaa !16
  %43 = sub nsw i32 %42, %.01827
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds double, ptr %41, i64 %44
  %46 = zext nneg i32 %.01827 to i64
  %47 = call i64 @fread(ptr noundef %45, i64 noundef 8, i64 noundef %46, ptr noundef %1)
  %48 = trunc i64 %47 to i32
  %49 = icmp sgt i32 %48, -1
  br i1 %49, label %37, label %.thread

.thread:                                          ; preds = %.lr.ph
  %50 = load ptr, ptr @stderr, align 8, !tbaa !21
  %51 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %50, ptr noundef nonnull @.str.72) #9
  br label %.loopexit

.lr.ph29:                                         ; preds = %.preheader, %60
  %indvars.iv = phi i64 [ %indvars.iv.next, %60 ], [ 0, %.preheader ]
  %52 = load ptr, ptr %33, align 8, !tbaa !18
  %53 = getelementptr inbounds double, ptr %52, i64 %indvars.iv
  %54 = load double, ptr %53, align 8, !tbaa !22
  %55 = load double, ptr @RN_EPSILON, align 8, !tbaa !22
  %56 = call noundef i32 @_Z9RNIsEqualddd(double noundef %54, double noundef -3.210000e+02, double noundef %55)
  %.not25 = icmp eq i32 %56, 0
  br i1 %.not25, label %60, label %57

57:                                               ; preds = %.lr.ph29
  %58 = load ptr, ptr %33, align 8, !tbaa !18
  %59 = getelementptr inbounds double, ptr %58, i64 %indvars.iv
  store double -3.210000e+02, ptr %59, align 8, !tbaa !22
  br label %60

60:                                               ; preds = %.lr.ph29, %57
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %61 = load i32, ptr %15, align 4, !tbaa !16
  %62 = sext i32 %61 to i64
  %63 = icmp slt i64 %indvars.iv.next, %62
  br i1 %63, label %.lr.ph29, label %.loopexit, !llvm.loop !23

.loopexit:                                        ; preds = %60, %26, %.preheader, %.thread, %20
  %.3 = phi i32 [ 0, %20 ], [ 0, %.thread ], [ %.pre, %.preheader ], [ %27, %26 ], [ %61, %60 ]
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %3) #7
  br label %64

64:                                               ; preds = %.loopexit, %17, %8
  %.4 = phi i32 [ 0, %8 ], [ 0, %17 ], [ %.3, %.loopexit ]
  ret i32 %.4
}

declare void @_ZN8R2Affine5ResetERK8R3Matrixi(ptr noundef nonnull align 8 dereferenceable(84), ptr noundef nonnull align 8 dereferenceable(72), i32 noundef) local_unnamed_addr #5

declare void @_ZN8R3MatrixC1EPKd(ptr noundef nonnull align 8 dereferenceable(72), ptr noundef) unnamed_addr #5

attributes #0 = { nobuiltin allocsize(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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #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 = { "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 = { 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 #7 = { nounwind }
attributes #8 = { builtin allocsize(0) }
attributes #9 = { cold 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 200}
!10 = !{!"_ZTS6R2Grid", !11, i64 0, !11, i64 88, !14, i64 176, !15, i64 184, !7, i64 192, !6, i64 200, !6, i64 204}
!11 = !{!"_ZTS8R2Affine", !12, i64 0, !13, i64 8, !6, i64 80}
!12 = !{!"_ZTS16R2Transformation"}
!13 = !{!"_ZTS8R3Matrix", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!"any pointer", !7, i64 0}
!16 = !{!10, !6, i64 204}
!17 = !{!10, !14, i64 176}
!18 = !{!10, !15, i64 184}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!15, !15, i64 0}
!22 = !{!14, !14, i64 0}
!23 = distinct !{!23, !20}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass