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

; 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.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.R3Grid = type { %class.R3Affine, %class.R3Affine, double, double, ptr, [3 x i32], 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
@stderr = external global ptr, align 8
@.str.10 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.49 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.126 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.127 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.139 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.140 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.156 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.157 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.158 = external hidden unnamed_addr constant [22 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: nounwind
declare void @_ZN8R3AffineD1Ev(ptr noundef nonnull align 8 dereferenceable(272)) unnamed_addr #4

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6R3Grid28SetWorldToGridTransformationERK8R3Affine(ptr noundef nonnull align 8 dereferenceable(592), ptr noundef nonnull align 8 dereferenceable(272)) #6 align 2

declare void @_ZN8R3AffineC1ERK8R4Matrixi(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef nonnull align 8 dereferenceable(128), i32 noundef) unnamed_addr #2

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

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

declare i32 @fclose(ptr noundef) #2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN6R3Grid13ReadASCIIFileEPKc(ptr noundef nonnull align 8 dereferenceable(592) %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 ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca [3 x i32], align 4
  %9 = alloca [16 x double], align 16
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca %class.R3Affine, align 8
  %15 = alloca %class.R4Matrix, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %18 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = call noalias ptr @fopen(ptr noundef %19, ptr noundef @.str.126)
  store ptr %20, ptr %6, align 8, !tbaa !5
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %27, label %23

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

27:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 12, ptr %8) #7
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds [3 x i32], ptr %8, i64 0, i64 0
  %30 = getelementptr inbounds [3 x i32], ptr %8, i64 0, i64 1
  %31 = getelementptr inbounds [3 x i32], ptr %8, i64 0, i64 2
  %32 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %28, ptr noundef @.str.156, ptr noundef %29, ptr noundef %30, ptr noundef %31)
  %33 = icmp ne i32 %32, 3
  br i1 %33, label %34, label %40

34:                                               ; preds = %27
  %35 = load ptr, ptr @stderr, align 8, !tbaa !5
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %35, ptr noundef @.str.157, ptr noundef %36) #7
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = call i32 @fclose(ptr noundef %38)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %185

40:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 128, ptr %9) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %59, %40
  %42 = load i32, ptr %10, align 4, !tbaa !9
  %43 = icmp slt i32 %42, 16
  br i1 %43, label %45, label %44

44:                                               ; preds = %41
  store i32 2, ptr %7, align 4
  br label %62

45:                                               ; preds = %41
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = load i32, ptr %10, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [16 x double], ptr %9, i64 0, i64 %48
  %50 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %46, ptr noundef @.str.139, ptr noundef %49)
  %51 = icmp ne i32 %50, 1
  br i1 %51, label %52, label %58

52:                                               ; preds = %45
  %53 = load ptr, ptr @stderr, align 8, !tbaa !5
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %53, ptr noundef @.str.158, ptr noundef %54) #7
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = call i32 @fclose(ptr noundef %56)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %62

58:                                               ; preds = %45
  br label %59

59:                                               ; preds = %58
  %60 = load i32, ptr %10, align 4, !tbaa !9
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %10, align 4, !tbaa !9
  br label %41, !llvm.loop !11

62:                                               ; preds = %52, %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  %63 = load i32, ptr %7, align 4
  switch i32 %63, label %184 [
    i32 2, label %64
  ]

64:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  %65 = getelementptr inbounds [3 x i32], ptr %8, i64 0, i64 0
  %66 = load i32, ptr %65, align 4, !tbaa !9
  %67 = getelementptr inbounds [3 x i32], ptr %8, i64 0, i64 1
  %68 = load i32, ptr %67, align 4, !tbaa !9
  %69 = mul nsw i32 %66, %68
  %70 = getelementptr inbounds [3 x i32], ptr %8, i64 0, i64 2
  %71 = load i32, ptr %70, align 4, !tbaa !9
  %72 = mul nsw i32 %69, %71
  store i32 %72, ptr %11, align 4, !tbaa !9
  %73 = getelementptr inbounds %class.R3Grid, ptr %18, i32 0, i32 4
  %74 = load ptr, ptr %73, align 8, !tbaa !13
  %75 = icmp ne ptr %74, null
  br i1 %75, label %76, label %81

76:                                               ; preds = %64
  %77 = load i32, ptr %11, align 4, !tbaa !9
  %78 = getelementptr inbounds %class.R3Grid, ptr %18, i32 0, i32 8
  %79 = load i32, ptr %78, align 4, !tbaa !21
  %80 = icmp sgt i32 %77, %79
  br i1 %80, label %81, label %105

81:                                               ; preds = %76, %64
  %82 = getelementptr inbounds %class.R3Grid, ptr %18, i32 0, i32 4
  %83 = load ptr, ptr %82, align 8, !tbaa !13
  %84 = icmp ne ptr %83, null
  br i1 %84, label %85, label %91

85:                                               ; preds = %81
  %86 = getelementptr inbounds %class.R3Grid, ptr %18, i32 0, i32 4
  %87 = load ptr, ptr %86, align 8, !tbaa !13
  %88 = icmp eq ptr %87, null
  br i1 %88, label %90, label %89

89:                                               ; preds = %85
  call void @_ZdaPv(ptr noundef %87) #8
  br label %90

90:                                               ; preds = %89, %85
  br label %91

91:                                               ; preds = %90, %81
  %92 = load i32, ptr %11, align 4, !tbaa !9
  %93 = sext i32 %92 to i64
  %94 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %93, i64 8)
  %95 = extractvalue { i64, i1 } %94, 1
  %96 = extractvalue { i64, i1 } %94, 0
  %97 = select i1 %95, i64 -1, i64 %96
  %98 = call noalias noundef nonnull ptr @_Znam(i64 noundef %97) #9
  %99 = getelementptr inbounds %class.R3Grid, ptr %18, i32 0, i32 4
  store ptr %98, ptr %99, align 8, !tbaa !13
  %100 = getelementptr inbounds %class.R3Grid, ptr %18, i32 0, i32 4
  %101 = load ptr, ptr %100, align 8, !tbaa !13
  %102 = icmp ne ptr %101, null
  br i1 %102, label %104, label %103

103:                                              ; preds = %91
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.10, i32 noundef 4434, ptr noundef @.str.2)
  br label %104

104:                                              ; preds = %103, %91
  br label %105

105:                                              ; preds = %104, %76
  %106 = getelementptr inbounds [3 x i32], ptr %8, i64 0, i64 0
  %107 = load i32, ptr %106, align 4, !tbaa !9
  %108 = getelementptr inbounds %class.R3Grid, ptr %18, i32 0, i32 5
  %109 = getelementptr inbounds [3 x i32], ptr %108, i64 0, i64 0
  store i32 %107, ptr %109, align 8, !tbaa !9
  %110 = getelementptr inbounds [3 x i32], ptr %8, i64 0, i64 1
  %111 = load i32, ptr %110, align 4, !tbaa !9
  %112 = getelementptr inbounds %class.R3Grid, ptr %18, i32 0, i32 5
  %113 = getelementptr inbounds [3 x i32], ptr %112, i64 0, i64 1
  store i32 %111, ptr %113, align 4, !tbaa !9
  %114 = getelementptr inbounds [3 x i32], ptr %8, i64 0, i64 2
  %115 = load i32, ptr %114, align 4, !tbaa !9
  %116 = getelementptr inbounds %class.R3Grid, ptr %18, i32 0, i32 5
  %117 = getelementptr inbounds [3 x i32], ptr %116, i64 0, i64 2
  store i32 %115, ptr %117, align 8, !tbaa !9
  %118 = getelementptr inbounds %class.R3Grid, ptr %18, i32 0, i32 5
  %119 = getelementptr inbounds [3 x i32], ptr %118, i64 0, i64 0
  %120 = load i32, ptr %119, align 8, !tbaa !9
  %121 = getelementptr inbounds %class.R3Grid, ptr %18, i32 0, i32 6
  store i32 %120, ptr %121, align 4, !tbaa !22
  %122 = getelementptr inbounds %class.R3Grid, ptr %18, i32 0, i32 6
  %123 = load i32, ptr %122, align 4, !tbaa !22
  %124 = getelementptr inbounds %class.R3Grid, ptr %18, i32 0, i32 5
  %125 = getelementptr inbounds [3 x i32], ptr %124, i64 0, i64 1
  %126 = load i32, ptr %125, align 4, !tbaa !9
  %127 = mul nsw i32 %123, %126
  %128 = getelementptr inbounds %class.R3Grid, ptr %18, i32 0, i32 7
  store i32 %127, ptr %128, align 8, !tbaa !23
  %129 = getelementptr inbounds %class.R3Grid, ptr %18, i32 0, i32 7
  %130 = load i32, ptr %129, align 8, !tbaa !23
  %131 = getelementptr inbounds %class.R3Grid, ptr %18, i32 0, i32 5
  %132 = getelementptr inbounds [3 x i32], ptr %131, i64 0, i64 2
  %133 = load i32, ptr %132, align 8, !tbaa !9
  %134 = mul nsw i32 %130, %133
  %135 = getelementptr inbounds %class.R3Grid, ptr %18, i32 0, i32 8
  store i32 %134, ptr %135, align 4, !tbaa !21
  %136 = getelementptr inbounds %class.R3Grid, ptr %18, i32 0, i32 8
  %137 = load i32, ptr %136, align 4, !tbaa !21
  %138 = icmp sle i32 %137, 0
  br i1 %138, label %139, label %144

139:                                              ; preds = %105
  %140 = getelementptr inbounds %class.R3Grid, ptr %18, i32 0, i32 8
  %141 = load i32, ptr %140, align 4, !tbaa !21
  call void (ptr, ...) @_Z6RNFailPKcz(ptr noundef @.str.49, i32 noundef %141)
  %142 = load ptr, ptr %6, align 8, !tbaa !5
  %143 = call i32 @fclose(ptr noundef %142)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %183

144:                                              ; preds = %105
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %145 = getelementptr inbounds %class.R3Grid, ptr %18, i32 0, i32 4
  %146 = load ptr, ptr %145, align 8, !tbaa !13
  store ptr %146, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %147

147:                                              ; preds = %166, %144
  %148 = load i32, ptr %13, align 4, !tbaa !9
  %149 = getelementptr inbounds %class.R3Grid, ptr %18, i32 0, i32 8
  %150 = load i32, ptr %149, align 4, !tbaa !21
  %151 = icmp slt i32 %148, %150
  br i1 %151, label %153, label %152

152:                                              ; preds = %147
  store i32 5, ptr %7, align 4
  br label %169

153:                                              ; preds = %147
  %154 = load ptr, ptr %6, align 8, !tbaa !5
  %155 = load ptr, ptr %12, align 8, !tbaa !5
  %156 = getelementptr inbounds double, ptr %155, i32 1
  store ptr %156, ptr %12, align 8, !tbaa !5
  %157 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %154, ptr noundef @.str.139, ptr noundef %155)
  %158 = icmp ne i32 %157, 1
  br i1 %158, label %159, label %165

159:                                              ; preds = %153
  %160 = load ptr, ptr @stderr, align 8, !tbaa !5
  %161 = load ptr, ptr %5, align 8, !tbaa !5
  %162 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %160, ptr noundef @.str.140, ptr noundef %161) #7
  %163 = load ptr, ptr %6, align 8, !tbaa !5
  %164 = call i32 @fclose(ptr noundef %163)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %169

165:                                              ; preds = %153
  br label %166

166:                                              ; preds = %165
  %167 = load i32, ptr %13, align 4, !tbaa !9
  %168 = add nsw i32 %167, 1
  store i32 %168, ptr %13, align 4, !tbaa !9
  br label %147, !llvm.loop !24

169:                                              ; preds = %159, %152
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  %170 = load i32, ptr %7, align 4
  switch i32 %170, label %182 [
    i32 5, label %171
  ]

171:                                              ; preds = %169
  call void @llvm.lifetime.start.p0(i64 272, ptr %14) #7
  call void @llvm.lifetime.start.p0(i64 128, ptr %15) #7
  %172 = getelementptr inbounds [16 x double], ptr %9, i64 0, i64 0
  call void @_ZN8R4MatrixC1EPKd(ptr noundef nonnull align 8 dereferenceable(128) %15, ptr noundef %172)
  call void @_ZN8R3AffineC1ERK8R4Matrixi(ptr noundef nonnull align 8 dereferenceable(272) %14, ptr noundef nonnull align 8 dereferenceable(128) %15, i32 noundef 0)
  invoke void @_ZN6R3Grid28SetWorldToGridTransformationERK8R3Affine(ptr noundef nonnull align 8 dereferenceable(592) %18, ptr noundef nonnull align 8 dereferenceable(272) %14)
          to label %173 unwind label %178

173:                                              ; preds = %171
  call void @_ZN8R3AffineD1Ev(ptr noundef nonnull align 8 dereferenceable(272) %14) #7
  call void @llvm.lifetime.end.p0(i64 128, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 272, ptr %14) #7
  %174 = load ptr, ptr %6, align 8, !tbaa !5
  %175 = call i32 @fclose(ptr noundef %174)
  %176 = getelementptr inbounds %class.R3Grid, ptr %18, i32 0, i32 8
  %177 = load i32, ptr %176, align 4, !tbaa !21
  store i32 %177, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %182

178:                                              ; preds = %171
  %179 = landingpad { ptr, i32 }
          cleanup
  %180 = extractvalue { ptr, i32 } %179, 0
  store ptr %180, ptr %16, align 8
  %181 = extractvalue { ptr, i32 } %179, 1
  store i32 %181, ptr %17, align 4
  call void @_ZN8R3AffineD1Ev(ptr noundef nonnull align 8 dereferenceable(272) %14) #7
  call void @llvm.lifetime.end.p0(i64 128, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 272, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 128, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  br label %188

182:                                              ; preds = %173, %169
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %183

183:                                              ; preds = %182, %139
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %184

184:                                              ; preds = %183, %62
  call void @llvm.lifetime.end.p0(i64 128, ptr %9) #7
  br label %185

185:                                              ; preds = %184, %34
  call void @llvm.lifetime.end.p0(i64 12, ptr %8) #7
  br label %186

186:                                              ; preds = %185, %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  %187 = load i32, ptr %3, align 4
  ret i32 %187

188:                                              ; preds = %178
  %189 = load ptr, ptr %16, align 8
  %190 = load i32, ptr %17, align 4
  %191 = insertvalue { ptr, i32 } poison, ptr %189, 0
  %192 = insertvalue { ptr, i32 } %191, i32 %190, 1
  resume { ptr, i32 } %192
}

declare void @_ZN8R4MatrixC1EPKd(ptr noundef nonnull align 8 dereferenceable(128), 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 = { 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 = { 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 #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 nounwind }
attributes #9 = { 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !6, i64 560}
!14 = !{!"_ZTS6R3Grid", !15, i64 0, !15, i64 272, !20, i64 544, !20, i64 552, !6, i64 560, !7, i64 568, !10, i64 580, !10, i64 584, !10, i64 588}
!15 = !{!"_ZTS8R3Affine", !16, i64 0, !17, i64 8, !17, i64 136, !18, i64 264}
!16 = !{!"_ZTS16R3Transformation"}
!17 = !{!"_ZTS8R4Matrix", !7, i64 0}
!18 = !{!"_ZTS7RNFlags", !19, i64 0}
!19 = !{!"long", !7, i64 0}
!20 = !{!"double", !7, i64 0}
!21 = !{!14, !10, i64 588}
!22 = !{!14, !10, i64 580}
!23 = !{!14, !10, i64 584}
!24 = distinct !{!24, !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.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 }

@stderr = external local_unnamed_addr global ptr, align 8
@.str.49 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.126 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.127 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.139 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.140 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.156 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.157 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.158 = external hidden unnamed_addr constant [22 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: nounwind
declare void @_ZN8R3AffineD1Ev(ptr noundef nonnull align 8 dereferenceable(272)) unnamed_addr #2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6R3Grid28SetWorldToGridTransformationERK8R3Affine(ptr noundef nonnull align 8 dereferenceable(592), ptr noundef nonnull align 8 dereferenceable(272)) local_unnamed_addr #5 align 2

declare void @_ZN8R3AffineC1ERK8R4Matrixi(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef nonnull align 8 dereferenceable(128), i32 noundef) unnamed_addr #6

declare void @_Z6RNFailPKcz(ptr noundef, ...) local_unnamed_addr #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 i32 @fclose(ptr nocapture noundef) local_unnamed_addr #4

declare i32 @__isoc99_fscanf(ptr noundef, ptr noundef, ...) local_unnamed_addr #6

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN6R3Grid13ReadASCIIFileEPKc(ptr noundef nonnull align 8 dereferenceable(592) %0, ptr noundef %1) local_unnamed_addr #5 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca [3 x i32], align 4
  %4 = alloca [16 x double], align 16
  %5 = alloca %class.R3Affine, align 8
  %6 = alloca %class.R4Matrix, align 8
  %7 = tail call noalias ptr @fopen(ptr noundef %1, ptr noundef nonnull @.str.126)
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %8, label %11

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

11:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %3) #8
  %12 = getelementptr inbounds i8, ptr %3, i64 4
  %13 = getelementptr inbounds i8, ptr %3, i64 8
  %14 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %7, ptr noundef nonnull @.str.156, ptr noundef nonnull %3, ptr noundef nonnull %12, ptr noundef nonnull %13)
  %.not35 = icmp eq i32 %14, 3
  br i1 %.not35, label %19, label %15

15:                                               ; preds = %11
  %16 = load ptr, ptr @stderr, align 8, !tbaa !5
  %17 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str.157, ptr noundef %1) #7
  %18 = call i32 @fclose(ptr noundef nonnull %7)
  br label %116

19:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %4) #8
  %20 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %7, ptr noundef nonnull @.str.139, ptr noundef nonnull %4)
  %.not36 = icmp eq i32 %20, 1
  br i1 %.not36, label %21, label %76

21:                                               ; preds = %19
  %22 = getelementptr inbounds i8, ptr %4, i64 8
  %23 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %7, ptr noundef nonnull @.str.139, ptr noundef nonnull %22)
  %.not36.1 = icmp eq i32 %23, 1
  br i1 %.not36.1, label %24, label %76

24:                                               ; preds = %21
  %25 = getelementptr inbounds i8, ptr %4, i64 16
  %26 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %7, ptr noundef nonnull @.str.139, ptr noundef nonnull %25)
  %.not36.2 = icmp eq i32 %26, 1
  br i1 %.not36.2, label %27, label %76

27:                                               ; preds = %24
  %28 = getelementptr inbounds i8, ptr %4, i64 24
  %29 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %7, ptr noundef nonnull @.str.139, ptr noundef nonnull %28)
  %.not36.3 = icmp eq i32 %29, 1
  br i1 %.not36.3, label %30, label %76

30:                                               ; preds = %27
  %31 = getelementptr inbounds i8, ptr %4, i64 32
  %32 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %7, ptr noundef nonnull @.str.139, ptr noundef nonnull %31)
  %.not36.4 = icmp eq i32 %32, 1
  br i1 %.not36.4, label %33, label %76

33:                                               ; preds = %30
  %34 = getelementptr inbounds i8, ptr %4, i64 40
  %35 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %7, ptr noundef nonnull @.str.139, ptr noundef nonnull %34)
  %.not36.5 = icmp eq i32 %35, 1
  br i1 %.not36.5, label %36, label %76

36:                                               ; preds = %33
  %37 = getelementptr inbounds i8, ptr %4, i64 48
  %38 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %7, ptr noundef nonnull @.str.139, ptr noundef nonnull %37)
  %.not36.6 = icmp eq i32 %38, 1
  br i1 %.not36.6, label %39, label %76

39:                                               ; preds = %36
  %40 = getelementptr inbounds i8, ptr %4, i64 56
  %41 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %7, ptr noundef nonnull @.str.139, ptr noundef nonnull %40)
  %.not36.7 = icmp eq i32 %41, 1
  br i1 %.not36.7, label %42, label %76

42:                                               ; preds = %39
  %43 = getelementptr inbounds i8, ptr %4, i64 64
  %44 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %7, ptr noundef nonnull @.str.139, ptr noundef nonnull %43)
  %.not36.8 = icmp eq i32 %44, 1
  br i1 %.not36.8, label %45, label %76

45:                                               ; preds = %42
  %46 = getelementptr inbounds i8, ptr %4, i64 72
  %47 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %7, ptr noundef nonnull @.str.139, ptr noundef nonnull %46)
  %.not36.9 = icmp eq i32 %47, 1
  br i1 %.not36.9, label %48, label %76

48:                                               ; preds = %45
  %49 = getelementptr inbounds i8, ptr %4, i64 80
  %50 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %7, ptr noundef nonnull @.str.139, ptr noundef nonnull %49)
  %.not36.10 = icmp eq i32 %50, 1
  br i1 %.not36.10, label %51, label %76

51:                                               ; preds = %48
  %52 = getelementptr inbounds i8, ptr %4, i64 88
  %53 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %7, ptr noundef nonnull @.str.139, ptr noundef nonnull %52)
  %.not36.11 = icmp eq i32 %53, 1
  br i1 %.not36.11, label %54, label %76

54:                                               ; preds = %51
  %55 = getelementptr inbounds i8, ptr %4, i64 96
  %56 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %7, ptr noundef nonnull @.str.139, ptr noundef nonnull %55)
  %.not36.12 = icmp eq i32 %56, 1
  br i1 %.not36.12, label %57, label %76

57:                                               ; preds = %54
  %58 = getelementptr inbounds i8, ptr %4, i64 104
  %59 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %7, ptr noundef nonnull @.str.139, ptr noundef nonnull %58)
  %.not36.13 = icmp eq i32 %59, 1
  br i1 %.not36.13, label %60, label %76

60:                                               ; preds = %57
  %61 = getelementptr inbounds i8, ptr %4, i64 112
  %62 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %7, ptr noundef nonnull @.str.139, ptr noundef nonnull %61)
  %.not36.14 = icmp eq i32 %62, 1
  br i1 %.not36.14, label %63, label %76

63:                                               ; preds = %60
  %64 = getelementptr inbounds i8, ptr %4, i64 120
  %65 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %7, ptr noundef nonnull @.str.139, ptr noundef nonnull %64)
  %.not36.15 = icmp eq i32 %65, 1
  br i1 %.not36.15, label %.critedge, label %76

.critedge:                                        ; preds = %63
  %66 = load i32, ptr %3, align 4, !tbaa !9
  %67 = load i32, ptr %12, align 4, !tbaa !9
  %68 = mul nsw i32 %67, %66
  %69 = load i32, ptr %13, align 4, !tbaa !9
  %70 = mul nsw i32 %68, %69
  %71 = getelementptr inbounds i8, ptr %0, i64 560
  %72 = load ptr, ptr %71, align 8, !tbaa !11
  %.not37 = icmp eq ptr %72, null
  %73 = getelementptr inbounds i8, ptr %0, i64 588
  %74 = load i32, ptr %73, align 4
  %75 = icmp sgt i32 %70, %74
  %or.cond = select i1 %.not37, i1 true, i1 %75
  br i1 %or.cond, label %80, label %88

76:                                               ; preds = %63, %60, %57, %54, %51, %48, %45, %42, %39, %36, %33, %30, %27, %24, %21, %19
  %77 = load ptr, ptr @stderr, align 8, !tbaa !5
  %78 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %77, ptr noundef nonnull @.str.158, ptr noundef %1) #7
  %79 = call i32 @fclose(ptr noundef nonnull %7)
  br label %115

80:                                               ; preds = %.critedge
  br i1 %.not37, label %82, label %81

81:                                               ; preds = %80
  call void @_ZdaPv(ptr noundef nonnull %72) #9
  %.pre.pre = load i32, ptr %3, align 4, !tbaa !9
  %.pre50.pre = load i32, ptr %12, align 4, !tbaa !9
  %.pre51.pre = load i32, ptr %13, align 4, !tbaa !9
  %.pre58 = mul nsw i32 %.pre50.pre, %.pre.pre
  %.pre59 = mul nsw i32 %.pre51.pre, %.pre58
  br label %82

82:                                               ; preds = %81, %80
  %.pre56.pre-phi = phi i32 [ %.pre59, %81 ], [ %70, %80 ]
  %.pre55.pre-phi = phi i32 [ %.pre58, %81 ], [ %68, %80 ]
  %.pre51 = phi i32 [ %.pre51.pre, %81 ], [ %69, %80 ]
  %.pre50 = phi i32 [ %.pre50.pre, %81 ], [ %67, %80 ]
  %.pre = phi i32 [ %.pre.pre, %81 ], [ %66, %80 ]
  %83 = sext i32 %70 to i64
  %84 = icmp slt i32 %70, 0
  %85 = shl nsw i64 %83, 3
  %86 = select i1 %84, i64 -1, i64 %85
  %87 = call noalias noundef nonnull ptr @_Znam(i64 noundef %86) #10
  store ptr %87, ptr %71, align 8, !tbaa !11
  br label %88

88:                                               ; preds = %.critedge, %82
  %.pre-phi57 = phi i32 [ %70, %.critedge ], [ %.pre56.pre-phi, %82 ]
  %.pre-phi = phi i32 [ %68, %.critedge ], [ %.pre55.pre-phi, %82 ]
  %89 = phi ptr [ %72, %.critedge ], [ %87, %82 ]
  %90 = phi i32 [ %69, %.critedge ], [ %.pre51, %82 ]
  %91 = phi i32 [ %67, %.critedge ], [ %.pre50, %82 ]
  %92 = phi i32 [ %66, %.critedge ], [ %.pre, %82 ]
  %93 = getelementptr inbounds i8, ptr %0, i64 568
  store i32 %92, ptr %93, align 8, !tbaa !9
  %94 = getelementptr inbounds i8, ptr %0, i64 572
  store i32 %91, ptr %94, align 4, !tbaa !9
  %95 = getelementptr inbounds i8, ptr %0, i64 576
  store i32 %90, ptr %95, align 8, !tbaa !9
  %96 = getelementptr inbounds i8, ptr %0, i64 580
  store i32 %92, ptr %96, align 4, !tbaa !19
  %97 = getelementptr inbounds i8, ptr %0, i64 584
  store i32 %.pre-phi, ptr %97, align 8, !tbaa !20
  store i32 %.pre-phi57, ptr %73, align 4, !tbaa !21
  %98 = icmp slt i32 %.pre-phi57, 1
  br i1 %98, label %99, label %.lr.ph

99:                                               ; preds = %88
  call void (ptr, ...) @_Z6RNFailPKcz(ptr noundef nonnull @.str.49, i32 noundef %.pre-phi57)
  %100 = call i32 @fclose(ptr noundef nonnull %7)
  br label %115

.lr.ph:                                           ; preds = %88, %106
  %.03048 = phi i32 [ %108, %106 ], [ 0, %88 ]
  %.03147 = phi ptr [ %107, %106 ], [ %89, %88 ]
  %101 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %7, ptr noundef nonnull @.str.139, ptr noundef nonnull %.03147)
  %.not39 = icmp eq i32 %101, 1
  br i1 %.not39, label %106, label %102

102:                                              ; preds = %.lr.ph
  %103 = load ptr, ptr @stderr, align 8, !tbaa !5
  %104 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %103, ptr noundef nonnull @.str.140, ptr noundef %1) #7
  %105 = call i32 @fclose(ptr noundef nonnull %7)
  br label %115

106:                                              ; preds = %.lr.ph
  %107 = getelementptr inbounds i8, ptr %.03147, i64 8
  %108 = add nuw nsw i32 %.03048, 1
  %109 = load i32, ptr %73, align 4, !tbaa !21
  %.not40 = icmp slt i32 %108, %109
  br i1 %.not40, label %.lr.ph, label %.critedge44, !llvm.loop !22

.critedge44:                                      ; preds = %106
  call void @llvm.lifetime.start.p0(i64 272, ptr nonnull %5) #8
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %6) #8
  call void @_ZN8R4MatrixC1EPKd(ptr noundef nonnull align 8 dereferenceable(128) %6, ptr noundef nonnull %4)
  call void @_ZN8R3AffineC1ERK8R4Matrixi(ptr noundef nonnull align 8 dereferenceable(272) %5, ptr noundef nonnull align 8 dereferenceable(128) %6, i32 noundef 0)
  invoke void @_ZN6R3Grid28SetWorldToGridTransformationERK8R3Affine(ptr noundef nonnull align 8 dereferenceable(592) %0, ptr noundef nonnull align 8 dereferenceable(272) %5)
          to label %110 unwind label %113

110:                                              ; preds = %.critedge44
  call void @_ZN8R3AffineD1Ev(ptr noundef nonnull align 8 dereferenceable(272) %5) #8
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %6) #8
  call void @llvm.lifetime.end.p0(i64 272, ptr nonnull %5) #8
  %111 = call i32 @fclose(ptr noundef nonnull %7)
  %112 = load i32, ptr %73, align 4, !tbaa !21
  br label %115

113:                                              ; preds = %.critedge44
  %114 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN8R3AffineD1Ev(ptr noundef nonnull align 8 dereferenceable(272) %5) #8
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %6) #8
  call void @llvm.lifetime.end.p0(i64 272, ptr nonnull %5) #8
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %4) #8
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #8
  resume { ptr, i32 } %114

115:                                              ; preds = %102, %76, %99, %110
  %.4 = phi i32 [ 0, %76 ], [ 0, %99 ], [ %112, %110 ], [ 0, %102 ]
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %4) #8
  br label %116

116:                                              ; preds = %115, %15
  %.5 = phi i32 [ 0, %15 ], [ %.4, %115 ]
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #8
  br label %117

117:                                              ; preds = %116, %8
  %.6 = phi i32 [ %.5, %116 ], [ 0, %8 ]
  ret i32 %.6
}

declare void @_ZN8R4MatrixC1EPKd(ptr noundef nonnull align 8 dereferenceable(128), ptr noundef) unnamed_addr #6

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 = { 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 #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 = { "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 = { cold nounwind }
attributes #8 = { nounwind }
attributes #9 = { builtin nounwind }
attributes #10 = { 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, !6, i64 560}
!12 = !{!"_ZTS6R3Grid", !13, i64 0, !13, i64 272, !18, i64 544, !18, i64 552, !6, i64 560, !7, i64 568, !10, i64 580, !10, i64 584, !10, i64 588}
!13 = !{!"_ZTS8R3Affine", !14, i64 0, !15, i64 8, !15, i64 136, !16, i64 264}
!14 = !{!"_ZTS16R3Transformation"}
!15 = !{!"_ZTS8R4Matrix", !7, i64 0}
!16 = !{!"_ZTS7RNFlags", !17, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = !{!"double", !7, i64 0}
!19 = !{!12, !10, i64 580}
!20 = !{!12, !10, i64 584}
!21 = !{!12, !10, i64 588}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


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