; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R2Shapes/R2Grid.ll (ZN6R2Grid11ReadRAWFileEPKc)

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

@R2identity_affine = external global %class.R2Affine, align 8
@RN_EPSILON = external global double, align 8
@stderr = external global ptr, align 8
@.str.40 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [31 x i8], align 1

; 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

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

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

; 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)) #3 align 2

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #4

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN6R2Grid11ReadRAWFileEPKc(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr noundef %1) #6 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca [4 x i32], align 16
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %17 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #8
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = call noalias ptr @fopen(ptr noundef %18, ptr noundef @.str.40)
  store ptr %19, ptr %6, align 8, !tbaa !5
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %26, label %22

22:                                               ; preds = %2
  %23 = load ptr, ptr @stderr, align 8, !tbaa !5
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef @.str.41, ptr noundef %24) #8
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %190

26:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #8
  %27 = getelementptr inbounds [4 x i32], ptr %8, i64 0, i64 0
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = call i64 @fread(ptr noundef %27, i64 noundef 4, i64 noundef 4, ptr noundef %28)
  %30 = icmp ne i64 %29, 4
  br i1 %30, label %31, label %35

31:                                               ; preds = %26
  %32 = load ptr, ptr @stderr, align 8, !tbaa !5
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef @.str.42, ptr noundef %33) #8
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %189

35:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  store i32 54321, ptr %9, align 4, !tbaa !9
  %36 = getelementptr inbounds [4 x i32], ptr %8, i64 0, i64 0
  %37 = load i32, ptr %36, align 16, !tbaa !9
  %38 = icmp ne i32 %37, 54321
  br i1 %38, label %39, label %43

39:                                               ; preds = %35
  %40 = load ptr, ptr @stderr, align 8, !tbaa !5
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %40, ptr noundef @.str.43, ptr noundef %41) #8
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %188

43:                                               ; preds = %35
  %44 = getelementptr inbounds [4 x i32], ptr %8, i64 0, i64 3
  %45 = load i32, ptr %44, align 4, !tbaa !9
  %46 = icmp ne i32 %45, 1
  br i1 %46, label %47, label %53

47:                                               ; preds = %43
  %48 = load ptr, ptr @stderr, align 8, !tbaa !5
  %49 = getelementptr inbounds [4 x i32], ptr %8, i64 0, i64 3
  %50 = load i32, ptr %49, align 4, !tbaa !9
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %48, ptr noundef @.str.44, i32 noundef %50, ptr noundef %51) #8
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %188

53:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  %54 = getelementptr inbounds [4 x i32], ptr %8, i64 0, i64 1
  %55 = load i32, ptr %54, align 4, !tbaa !9
  store i32 %55, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  %56 = getelementptr inbounds [4 x i32], ptr %8, i64 0, i64 2
  %57 = load i32, ptr %56, align 8, !tbaa !9
  store i32 %57, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  %58 = load i32, ptr %10, align 4, !tbaa !9
  %59 = load i32, ptr %11, align 4, !tbaa !9
  %60 = mul nsw i32 %58, %59
  store i32 %60, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #8
  %61 = load i32, ptr %12, align 4, !tbaa !9
  %62 = zext i32 %61 to i64
  %63 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %62, i64 4)
  %64 = extractvalue { i64, i1 } %63, 1
  %65 = extractvalue { i64, i1 } %63, 0
  %66 = select i1 %64, i64 -1, i64 %65
  %67 = call noalias noundef nonnull ptr @_Znam(i64 noundef %66) #9
  store ptr %67, ptr %13, align 8, !tbaa !5
  %68 = load ptr, ptr %13, align 8, !tbaa !5
  %69 = icmp ne ptr %68, null
  br i1 %69, label %74, label %70

70:                                               ; preds = %53
  %71 = load ptr, ptr @stderr, align 8, !tbaa !5
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %71, ptr noundef @.str.45, ptr noundef %72) #8
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %187

74:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  %75 = load i32, ptr %12, align 4, !tbaa !9
  store i32 %75, ptr %14, align 4, !tbaa !9
  br label %76

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

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

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

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

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

103:                                              ; preds = %101
  br label %76, !llvm.loop !11

104:                                              ; preds = %76
  %105 = load i32, ptr %10, align 4, !tbaa !9
  %106 = getelementptr inbounds %class.R2Grid, ptr %17, i32 0, i32 4
  %107 = getelementptr inbounds [2 x i32], ptr %106, i64 0, i64 0
  store i32 %105, ptr %107, align 8, !tbaa !9
  %108 = load i32, ptr %11, align 4, !tbaa !9
  %109 = getelementptr inbounds %class.R2Grid, ptr %17, i32 0, i32 4
  %110 = getelementptr inbounds [2 x i32], ptr %109, i64 0, i64 1
  store i32 %108, ptr %110, align 4, !tbaa !9
  %111 = load i32, ptr %10, align 4, !tbaa !9
  %112 = getelementptr inbounds %class.R2Grid, ptr %17, i32 0, i32 5
  store i32 %111, ptr %112, align 8, !tbaa !13
  %113 = load i32, ptr %12, align 4, !tbaa !9
  %114 = getelementptr inbounds %class.R2Grid, ptr %17, i32 0, i32 6
  store i32 %113, ptr %114, align 4, !tbaa !19
  %115 = getelementptr inbounds %class.R2Grid, ptr %17, i32 0, i32 2
  store double 1.000000e+00, ptr %115, align 8, !tbaa !20
  %116 = getelementptr inbounds %class.R2Grid, ptr %17, i32 0, i32 1
  %117 = call noundef nonnull align 8 dereferenceable(84) ptr @_ZN8R2AffineaSERKS_(ptr noundef nonnull align 8 dereferenceable(84) %116, ptr noundef nonnull align 8 dereferenceable(84) @R2identity_affine)
  %118 = getelementptr inbounds %class.R2Grid, ptr %17, i32 0, i32 0
  %119 = call noundef nonnull align 8 dereferenceable(84) ptr @_ZN8R2AffineaSERKS_(ptr noundef nonnull align 8 dereferenceable(84) %118, ptr noundef nonnull align 8 dereferenceable(84) @R2identity_affine)
  %120 = getelementptr inbounds %class.R2Grid, ptr %17, i32 0, i32 3
  %121 = load ptr, ptr %120, align 8, !tbaa !21
  %122 = icmp ne ptr %121, null
  br i1 %122, label %123, label %129

123:                                              ; preds = %104
  %124 = getelementptr inbounds %class.R2Grid, ptr %17, i32 0, i32 3
  %125 = load ptr, ptr %124, align 8, !tbaa !21
  %126 = icmp eq ptr %125, null
  br i1 %126, label %128, label %127

127:                                              ; preds = %123
  call void @_ZdaPv(ptr noundef %125) #10
  br label %128

128:                                              ; preds = %127, %123
  br label %129

129:                                              ; preds = %128, %104
  %130 = getelementptr inbounds %class.R2Grid, ptr %17, i32 0, i32 6
  %131 = load i32, ptr %130, align 4, !tbaa !19
  %132 = sext i32 %131 to i64
  %133 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %132, i64 8)
  %134 = extractvalue { i64, i1 } %133, 1
  %135 = extractvalue { i64, i1 } %133, 0
  %136 = select i1 %134, i64 -1, i64 %135
  %137 = call noalias noundef nonnull ptr @_Znam(i64 noundef %136) #9
  %138 = getelementptr inbounds %class.R2Grid, ptr %17, i32 0, i32 3
  store ptr %137, ptr %138, align 8, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #8
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %139

139:                                              ; preds = %174, %129
  %140 = load i32, ptr %16, align 4, !tbaa !9
  %141 = getelementptr inbounds %class.R2Grid, ptr %17, i32 0, i32 6
  %142 = load i32, ptr %141, align 4, !tbaa !19
  %143 = icmp slt i32 %140, %142
  br i1 %143, label %145, label %144

144:                                              ; preds = %139
  store i32 4, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  br label %177

145:                                              ; preds = %139
  %146 = load ptr, ptr %13, align 8, !tbaa !5
  %147 = load i32, ptr %16, align 4, !tbaa !9
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds float, ptr %146, i64 %148
  %150 = load float, ptr %149, align 4, !tbaa !22
  %151 = fpext float %150 to double
  %152 = load double, ptr @RN_EPSILON, align 8, !tbaa !24
  %153 = call noundef i32 @_Z9RNIsEqualddd(double noundef %151, double noundef -3.210000e+02, double noundef %152)
  %154 = icmp ne i32 %153, 0
  br i1 %154, label %155, label %161

155:                                              ; preds = %145
  %156 = getelementptr inbounds %class.R2Grid, ptr %17, i32 0, i32 3
  %157 = load ptr, ptr %156, align 8, !tbaa !21
  %158 = load i32, ptr %16, align 4, !tbaa !9
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds double, ptr %157, i64 %159
  store double -3.210000e+02, ptr %160, align 8, !tbaa !24
  br label %173

161:                                              ; preds = %145
  %162 = load ptr, ptr %13, align 8, !tbaa !5
  %163 = load i32, ptr %16, align 4, !tbaa !9
  %164 = sext i32 %163 to i64
  %165 = getelementptr inbounds float, ptr %162, i64 %164
  %166 = load float, ptr %165, align 4, !tbaa !22
  %167 = fpext float %166 to double
  %168 = getelementptr inbounds %class.R2Grid, ptr %17, i32 0, i32 3
  %169 = load ptr, ptr %168, align 8, !tbaa !21
  %170 = load i32, ptr %16, align 4, !tbaa !9
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds double, ptr %169, i64 %171
  store double %167, ptr %172, align 8, !tbaa !24
  br label %173

173:                                              ; preds = %161, %155
  br label %174

174:                                              ; preds = %173
  %175 = load i32, ptr %16, align 4, !tbaa !9
  %176 = add nsw i32 %175, 1
  store i32 %176, ptr %16, align 4, !tbaa !9
  br label %139, !llvm.loop !25

177:                                              ; preds = %144
  %178 = load ptr, ptr %13, align 8, !tbaa !5
  %179 = icmp eq ptr %178, null
  br i1 %179, label %181, label %180

180:                                              ; preds = %177
  call void @_ZdaPv(ptr noundef %178) #10
  br label %181

181:                                              ; preds = %180, %177
  %182 = load ptr, ptr %6, align 8, !tbaa !5
  %183 = call i32 @fclose(ptr noundef %182)
  %184 = getelementptr inbounds %class.R2Grid, ptr %17, i32 0, i32 6
  %185 = load i32, ptr %184, align 4, !tbaa !19
  store i32 %185, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %186

186:                                              ; preds = %181, %101
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  br label %187

187:                                              ; preds = %186, %70
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  br label %188

188:                                              ; preds = %187, %47, %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  br label %189

189:                                              ; preds = %188, %31
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #8
  br label %190

190:                                              ; preds = %189, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #8
  %191 = load i32, ptr %3, align 4
  ret i32 %191
}

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

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

declare i32 @fclose(ptr noundef) #7

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


; 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]] }

@R2identity_affine = external global %class.R2Affine, align 8
@RN_EPSILON = external local_unnamed_addr global double, align 8
@stderr = external local_unnamed_addr global ptr, align 8
@.str.40 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [31 x i8], align 1

; 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: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #3

; 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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN6R2Grid11ReadRAWFileEPKc(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr noundef %1) local_unnamed_addr #5 align 2 {
  %3 = alloca [4 x i32], align 16
  %4 = tail call noalias ptr @fopen(ptr noundef %1, ptr noundef nonnull @.str.40)
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %5, label %8

5:                                                ; preds = %2
  %6 = load ptr, ptr @stderr, align 8, !tbaa !5
  %7 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %6, ptr noundef nonnull @.str.41, ptr noundef %1) #6
  br label %78

8:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #7
  %9 = call i64 @fread(ptr noundef nonnull %3, i64 noundef 4, i64 noundef 4, ptr noundef nonnull %4)
  %.not47 = icmp eq i64 %9, 4
  br i1 %.not47, label %13, label %10

10:                                               ; preds = %8
  %11 = load ptr, ptr @stderr, align 8, !tbaa !5
  %12 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.42, ptr noundef %1) #6
  br label %77

13:                                               ; preds = %8
  %14 = load i32, ptr %3, align 16, !tbaa !9
  %.not48 = icmp eq i32 %14, 54321
  br i1 %.not48, label %18, label %15

15:                                               ; preds = %13
  %16 = load ptr, ptr @stderr, align 8, !tbaa !5
  %17 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str.43, ptr noundef %1) #6
  br label %77

18:                                               ; preds = %13
  %19 = getelementptr inbounds i8, ptr %3, i64 12
  %20 = load i32, ptr %19, align 4, !tbaa !9
  %.not49 = icmp eq i32 %20, 1
  br i1 %.not49, label %24, label %21

21:                                               ; preds = %18
  %22 = load ptr, ptr @stderr, align 8, !tbaa !5
  %23 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef nonnull @.str.44, i32 noundef %20, ptr noundef %1) #6
  br label %77

24:                                               ; preds = %18
  %25 = getelementptr inbounds i8, ptr %3, i64 4
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = getelementptr inbounds i8, ptr %3, i64 8
  %28 = load i32, ptr %27, align 8, !tbaa !9
  %29 = mul nsw i32 %28, %26
  %30 = zext i32 %29 to i64
  %31 = shl nuw nsw i64 %30, 2
  %32 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %31) #8
  %33 = icmp sgt i32 %29, 0
  br i1 %33, label %.lr.ph, label %._crit_edge

34:                                               ; preds = %.lr.ph
  %35 = sub nsw i32 %.04053, %42
  %36 = icmp sgt i32 %35, 0
  br i1 %36, label %.lr.ph, label %._crit_edge, !llvm.loop !11

.lr.ph:                                           ; preds = %24, %34
  %.04053 = phi i32 [ %35, %34 ], [ %29, %24 ]
  %37 = sub nsw i32 %29, %.04053
  %38 = zext i32 %37 to i64
  %39 = getelementptr inbounds float, ptr %32, i64 %38
  %40 = zext nneg i32 %.04053 to i64
  %41 = tail call i64 @fread(ptr noundef nonnull %39, i64 noundef 4, i64 noundef %40, ptr noundef nonnull %4)
  %42 = trunc i64 %41 to i32
  %43 = icmp sgt i32 %42, -1
  br i1 %43, label %34, label %.thread

.thread:                                          ; preds = %.lr.ph
  %44 = load ptr, ptr @stderr, align 8, !tbaa !5
  %45 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %44, ptr noundef nonnull @.str.46, ptr noundef %1) #6
  br label %77

._crit_edge:                                      ; preds = %34, %24
  %46 = getelementptr inbounds i8, ptr %0, i64 192
  store i32 %26, ptr %46, align 8, !tbaa !9
  %47 = getelementptr inbounds i8, ptr %0, i64 196
  store i32 %28, ptr %47, align 4, !tbaa !9
  %48 = getelementptr inbounds i8, ptr %0, i64 200
  store i32 %26, ptr %48, align 8, !tbaa !13
  %49 = getelementptr inbounds i8, ptr %0, i64 204
  store i32 %29, ptr %49, align 4, !tbaa !19
  %50 = getelementptr inbounds i8, ptr %0, i64 176
  store double 1.000000e+00, ptr %50, align 8, !tbaa !20
  %51 = getelementptr inbounds i8, ptr %0, i64 88
  %52 = tail call noundef nonnull align 8 dereferenceable(84) ptr @_ZN8R2AffineaSERKS_(ptr noundef nonnull align 8 dereferenceable(84) %51, ptr noundef nonnull align 8 dereferenceable(84) @R2identity_affine)
  %53 = tail call noundef nonnull align 8 dereferenceable(84) ptr @_ZN8R2AffineaSERKS_(ptr noundef nonnull align 8 dereferenceable(84) %0, ptr noundef nonnull align 8 dereferenceable(84) @R2identity_affine)
  %54 = getelementptr inbounds i8, ptr %0, i64 184
  %55 = load ptr, ptr %54, align 8, !tbaa !21
  %.not50 = icmp eq ptr %55, null
  br i1 %.not50, label %57, label %56

56:                                               ; preds = %._crit_edge
  tail call void @_ZdaPv(ptr noundef nonnull %55) #9
  br label %57

57:                                               ; preds = %56, %._crit_edge
  %58 = load i32, ptr %49, align 4, !tbaa !19
  %59 = sext i32 %58 to i64
  %60 = icmp slt i32 %58, 0
  %61 = shl nsw i64 %59, 3
  %62 = select i1 %60, i64 -1, i64 %61
  %63 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %62) #8
  store ptr %63, ptr %54, align 8, !tbaa !21
  %64 = icmp sgt i32 %58, 0
  br i1 %64, label %.lr.ph56, label %._crit_edge57

.lr.ph56:                                         ; preds = %57, %.lr.ph56
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph56 ], [ 0, %57 ]
  %65 = getelementptr inbounds float, ptr %32, i64 %indvars.iv
  %66 = load float, ptr %65, align 4, !tbaa !22
  %67 = fpext float %66 to double
  %68 = load double, ptr @RN_EPSILON, align 8, !tbaa !24
  %69 = tail call noundef i32 @_Z9RNIsEqualddd(double noundef %67, double noundef -3.210000e+02, double noundef %68)
  %.not51 = icmp eq i32 %69, 0
  %70 = load ptr, ptr %54, align 8, !tbaa !21
  %71 = getelementptr inbounds double, ptr %70, i64 %indvars.iv
  %. = select i1 %.not51, double %67, double -3.210000e+02
  store double %., ptr %71, align 8, !tbaa !24
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %72 = load i32, ptr %49, align 4, !tbaa !19
  %73 = sext i32 %72 to i64
  %74 = icmp slt i64 %indvars.iv.next, %73
  br i1 %74, label %.lr.ph56, label %._crit_edge57, !llvm.loop !25

._crit_edge57:                                    ; preds = %.lr.ph56, %57
  tail call void @_ZdaPv(ptr noundef nonnull %32) #9
  %75 = tail call i32 @fclose(ptr noundef nonnull %4)
  %76 = load i32, ptr %49, align 4, !tbaa !19
  br label %77

77:                                               ; preds = %.thread, %15, %21, %._crit_edge57, %10
  %.5 = phi i32 [ -1, %10 ], [ -1, %15 ], [ -1, %21 ], [ %76, %._crit_edge57 ], [ 0, %.thread ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #7
  br label %78

78:                                               ; preds = %77, %5
  %.6 = phi i32 [ %.5, %77 ], [ 0, %5 ]
  ret i32 %.6
}

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

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

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

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 = { nobuiltin 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 = { 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 #6 = { cold nounwind }
attributes #7 = { nounwind }
attributes #8 = { builtin allocsize(0) }
attributes #9 = { builtin 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !10, i64 200}
!14 = !{!"_ZTS6R2Grid", !15, i64 0, !15, i64 88, !18, i64 176, !6, i64 184, !7, i64 192, !10, i64 200, !10, i64 204}
!15 = !{!"_ZTS8R2Affine", !16, i64 0, !17, i64 8, !10, i64 80}
!16 = !{!"_ZTS16R2Transformation"}
!17 = !{!"_ZTS8R3Matrix", !7, i64 0}
!18 = !{!"double", !7, i64 0}
!19 = !{!14, !10, i64 204}
!20 = !{!14, !18, i64 176}
!21 = !{!14, !6, i64 184}
!22 = !{!23, !23, i64 0}
!23 = !{!"float", !7, i64 0}
!24 = !{!18, !18, i64 0}
!25 = distinct !{!25, !12}


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