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

; 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.R3Grid = type { %class.R3Affine, %class.R3Affine, double, double, ptr, [3 x i32], i32, i32, i32 }
%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 }

@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [88 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: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592), i32 noundef, i32 noundef, i32 noundef) #5 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592)) #6 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592)) #6 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592)) #6 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6R3Grid12SetGridValueEiiid(ptr noundef nonnull align 8 dereferenceable(592), i32 noundef, i32 noundef, i32 noundef, double noundef) #5 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R3Grid11PadWithZeroEiiiiii(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) #7 align 2 personality ptr @__gxx_personality_v0 {
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca %class.R3Grid, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca double, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store i32 %2, ptr %10, align 4, !tbaa !9
  store i32 %3, ptr %11, align 4, !tbaa !9
  store i32 %4, ptr %12, align 4, !tbaa !9
  store i32 %5, ptr %13, align 4, !tbaa !9
  store i32 %6, ptr %14, align 4, !tbaa !9
  %24 = load ptr, ptr %8, align 8
  %25 = call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %24)
  %26 = load i32, ptr %9, align 4, !tbaa !9
  %27 = icmp sge i32 %25, %26
  br i1 %27, label %28, label %37

28:                                               ; preds = %7
  %29 = call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %24)
  %30 = load i32, ptr %10, align 4, !tbaa !9
  %31 = icmp sge i32 %29, %30
  br i1 %31, label %32, label %37

32:                                               ; preds = %28
  %33 = call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %24)
  %34 = load i32, ptr %11, align 4, !tbaa !9
  %35 = icmp sge i32 %33, %34
  br i1 %35, label %36, label %37

36:                                               ; preds = %32
  br label %205

37:                                               ; preds = %32, %28, %7
  call void @llvm.lifetime.start.p0(i64 592, ptr %15) #8
  call void @_ZN6R3GridC1ERKS_(ptr noundef nonnull align 8 dereferenceable(592) %15, ptr noundef nonnull align 8 dereferenceable(592) %24)
  %38 = load i32, ptr %9, align 4, !tbaa !9
  %39 = getelementptr inbounds %class.R3Grid, ptr %24, i32 0, i32 5
  %40 = getelementptr inbounds [3 x i32], ptr %39, i64 0, i64 0
  store i32 %38, ptr %40, align 8, !tbaa !9
  %41 = load i32, ptr %10, align 4, !tbaa !9
  %42 = getelementptr inbounds %class.R3Grid, ptr %24, i32 0, i32 5
  %43 = getelementptr inbounds [3 x i32], ptr %42, i64 0, i64 1
  store i32 %41, ptr %43, align 4, !tbaa !9
  %44 = load i32, ptr %11, align 4, !tbaa !9
  %45 = getelementptr inbounds %class.R3Grid, ptr %24, i32 0, i32 5
  %46 = getelementptr inbounds [3 x i32], ptr %45, i64 0, i64 2
  store i32 %44, ptr %46, align 8, !tbaa !9
  %47 = load i32, ptr %9, align 4, !tbaa !9
  %48 = getelementptr inbounds %class.R3Grid, ptr %24, i32 0, i32 6
  store i32 %47, ptr %48, align 4, !tbaa !11
  %49 = getelementptr inbounds %class.R3Grid, ptr %24, i32 0, i32 6
  %50 = load i32, ptr %49, align 4, !tbaa !11
  %51 = load i32, ptr %10, align 4, !tbaa !9
  %52 = mul nsw i32 %50, %51
  %53 = getelementptr inbounds %class.R3Grid, ptr %24, i32 0, i32 7
  store i32 %52, ptr %53, align 8, !tbaa !19
  %54 = getelementptr inbounds %class.R3Grid, ptr %24, i32 0, i32 7
  %55 = load i32, ptr %54, align 8, !tbaa !19
  %56 = load i32, ptr %11, align 4, !tbaa !9
  %57 = mul nsw i32 %55, %56
  %58 = getelementptr inbounds %class.R3Grid, ptr %24, i32 0, i32 8
  store i32 %57, ptr %58, align 4, !tbaa !20
  %59 = getelementptr inbounds %class.R3Grid, ptr %24, i32 0, i32 4
  %60 = load ptr, ptr %59, align 8, !tbaa !21
  %61 = icmp ne ptr %60, null
  br i1 %61, label %62, label %68

62:                                               ; preds = %37
  %63 = getelementptr inbounds %class.R3Grid, ptr %24, i32 0, i32 4
  %64 = load ptr, ptr %63, align 8, !tbaa !21
  %65 = icmp eq ptr %64, null
  br i1 %65, label %67, label %66

66:                                               ; preds = %62
  call void @_ZdaPv(ptr noundef %64) #9
  br label %67

67:                                               ; preds = %66, %62
  br label %68

68:                                               ; preds = %67, %37
  %69 = getelementptr inbounds %class.R3Grid, ptr %24, i32 0, i32 8
  %70 = load i32, ptr %69, align 4, !tbaa !20
  %71 = icmp eq i32 %70, 0
  br i1 %71, label %72, label %74

72:                                               ; preds = %68
  %73 = getelementptr inbounds %class.R3Grid, ptr %24, i32 0, i32 4
  store ptr null, ptr %73, align 8, !tbaa !21
  br label %89

74:                                               ; preds = %68
  %75 = getelementptr inbounds %class.R3Grid, ptr %24, i32 0, i32 8
  %76 = load i32, ptr %75, align 4, !tbaa !20
  %77 = sext i32 %76 to i64
  %78 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %77, i64 8)
  %79 = extractvalue { i64, i1 } %78, 1
  %80 = extractvalue { i64, i1 } %78, 0
  %81 = select i1 %79, i64 -1, i64 %80
  %82 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %81) #10
          to label %83 unwind label %85

83:                                               ; preds = %74
  %84 = getelementptr inbounds %class.R3Grid, ptr %24, i32 0, i32 4
  store ptr %82, ptr %84, align 8, !tbaa !21
  br label %89

85:                                               ; preds = %97, %74
  %86 = landingpad { ptr, i32 }
          cleanup
  %87 = extractvalue { ptr, i32 } %86, 0
  store ptr %87, ptr %16, align 8
  %88 = extractvalue { ptr, i32 } %86, 1
  store i32 %88, ptr %17, align 4
  br label %206

89:                                               ; preds = %83, %72
  %90 = getelementptr inbounds %class.R3Grid, ptr %24, i32 0, i32 8
  %91 = load i32, ptr %90, align 4, !tbaa !20
  %92 = icmp ne i32 %91, 0
  br i1 %92, label %93, label %99

93:                                               ; preds = %89
  %94 = getelementptr inbounds %class.R3Grid, ptr %24, i32 0, i32 4
  %95 = load ptr, ptr %94, align 8, !tbaa !21
  %96 = icmp ne ptr %95, null
  br i1 %96, label %99, label %97

97:                                               ; preds = %93
  invoke void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1826, ptr noundef @.str.2)
          to label %98 unwind label %85

98:                                               ; preds = %97
  br label %99

99:                                               ; preds = %98, %93, %89
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #8
  store i32 0, ptr %18, align 4, !tbaa !9
  br label %100

100:                                              ; preds = %112, %99
  %101 = load i32, ptr %18, align 4, !tbaa !9
  %102 = getelementptr inbounds %class.R3Grid, ptr %24, i32 0, i32 8
  %103 = load i32, ptr %102, align 4, !tbaa !20
  %104 = icmp slt i32 %101, %103
  br i1 %104, label %106, label %105

105:                                              ; preds = %100
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #8
  br label %115

106:                                              ; preds = %100
  %107 = getelementptr inbounds %class.R3Grid, ptr %24, i32 0, i32 4
  %108 = load ptr, ptr %107, align 8, !tbaa !21
  %109 = load i32, ptr %18, align 4, !tbaa !9
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds double, ptr %108, i64 %110
  store double 0.000000e+00, ptr %111, align 8, !tbaa !22
  br label %112

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

115:                                              ; preds = %105
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #8
  store i32 0, ptr %19, align 4, !tbaa !9
  br label %116

116:                                              ; preds = %200, %115
  %117 = load i32, ptr %19, align 4, !tbaa !9
  %118 = invoke noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %15)
          to label %119 unwind label %122

119:                                              ; preds = %116
  %120 = icmp slt i32 %117, %118
  br i1 %120, label %126, label %121

121:                                              ; preds = %119
  store i32 5, ptr %20, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #8
  br label %204

122:                                              ; preds = %116
  %123 = landingpad { ptr, i32 }
          cleanup
  %124 = extractvalue { ptr, i32 } %123, 0
  store ptr %124, ptr %16, align 8
  %125 = extractvalue { ptr, i32 } %123, 1
  store i32 %125, ptr %17, align 4
  br label %203

126:                                              ; preds = %119
  %127 = load i32, ptr %19, align 4, !tbaa !9
  %128 = load i32, ptr %14, align 4, !tbaa !9
  %129 = add nsw i32 %127, %128
  %130 = load i32, ptr %11, align 4, !tbaa !9
  %131 = icmp sge i32 %129, %130
  br i1 %131, label %132, label %133

132:                                              ; preds = %126
  br label %200

133:                                              ; preds = %126
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #8
  store i32 0, ptr %21, align 4, !tbaa !9
  br label %134

134:                                              ; preds = %195, %133
  %135 = load i32, ptr %21, align 4, !tbaa !9
  %136 = invoke noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %15)
          to label %137 unwind label %140

137:                                              ; preds = %134
  %138 = icmp slt i32 %135, %136
  br i1 %138, label %144, label %139

139:                                              ; preds = %137
  store i32 8, ptr %20, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #8
  br label %199

140:                                              ; preds = %134
  %141 = landingpad { ptr, i32 }
          cleanup
  %142 = extractvalue { ptr, i32 } %141, 0
  store ptr %142, ptr %16, align 8
  %143 = extractvalue { ptr, i32 } %141, 1
  store i32 %143, ptr %17, align 4
  br label %198

144:                                              ; preds = %137
  %145 = load i32, ptr %21, align 4, !tbaa !9
  %146 = load i32, ptr %13, align 4, !tbaa !9
  %147 = add nsw i32 %145, %146
  %148 = load i32, ptr %10, align 4, !tbaa !9
  %149 = icmp sge i32 %147, %148
  br i1 %149, label %150, label %151

150:                                              ; preds = %144
  br label %195

151:                                              ; preds = %144
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #8
  store i32 0, ptr %22, align 4, !tbaa !9
  br label %152

152:                                              ; preds = %186, %151
  %153 = load i32, ptr %22, align 4, !tbaa !9
  %154 = invoke noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %15)
          to label %155 unwind label %158

155:                                              ; preds = %152
  %156 = icmp slt i32 %153, %154
  br i1 %156, label %162, label %157

157:                                              ; preds = %155
  store i32 11, ptr %20, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #8
  br label %194

158:                                              ; preds = %152
  %159 = landingpad { ptr, i32 }
          cleanup
  %160 = extractvalue { ptr, i32 } %159, 0
  store ptr %160, ptr %16, align 8
  %161 = extractvalue { ptr, i32 } %159, 1
  store i32 %161, ptr %17, align 4
  br label %193

162:                                              ; preds = %155
  %163 = load i32, ptr %22, align 4, !tbaa !9
  %164 = load i32, ptr %12, align 4, !tbaa !9
  %165 = add nsw i32 %163, %164
  %166 = load i32, ptr %9, align 4, !tbaa !9
  %167 = icmp sge i32 %165, %166
  br i1 %167, label %168, label %169

168:                                              ; preds = %162
  br label %186

169:                                              ; preds = %162
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #8
  %170 = load i32, ptr %22, align 4, !tbaa !9
  %171 = load i32, ptr %21, align 4, !tbaa !9
  %172 = load i32, ptr %19, align 4, !tbaa !9
  %173 = invoke noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %15, i32 noundef %170, i32 noundef %171, i32 noundef %172)
          to label %174 unwind label %189

174:                                              ; preds = %169
  store double %173, ptr %23, align 8, !tbaa !22
  %175 = load i32, ptr %22, align 4, !tbaa !9
  %176 = load i32, ptr %12, align 4, !tbaa !9
  %177 = add nsw i32 %175, %176
  %178 = load i32, ptr %21, align 4, !tbaa !9
  %179 = load i32, ptr %13, align 4, !tbaa !9
  %180 = add nsw i32 %178, %179
  %181 = load i32, ptr %19, align 4, !tbaa !9
  %182 = load i32, ptr %14, align 4, !tbaa !9
  %183 = add nsw i32 %181, %182
  %184 = load double, ptr %23, align 8, !tbaa !22
  invoke void @_ZN6R3Grid12SetGridValueEiiid(ptr noundef nonnull align 8 dereferenceable(592) %24, i32 noundef %177, i32 noundef %180, i32 noundef %183, double noundef %184)
          to label %185 unwind label %189

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

186:                                              ; preds = %185, %168
  %187 = load i32, ptr %22, align 4, !tbaa !9
  %188 = add nsw i32 %187, 1
  store i32 %188, ptr %22, align 4, !tbaa !9
  br label %152, !llvm.loop !25

189:                                              ; preds = %174, %169
  %190 = landingpad { ptr, i32 }
          cleanup
  %191 = extractvalue { ptr, i32 } %190, 0
  store ptr %191, ptr %16, align 8
  %192 = extractvalue { ptr, i32 } %190, 1
  store i32 %192, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #8
  br label %193

193:                                              ; preds = %189, %158
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #8
  br label %198

194:                                              ; preds = %157
  br label %195

195:                                              ; preds = %194, %150
  %196 = load i32, ptr %21, align 4, !tbaa !9
  %197 = add nsw i32 %196, 1
  store i32 %197, ptr %21, align 4, !tbaa !9
  br label %134, !llvm.loop !26

198:                                              ; preds = %193, %140
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #8
  br label %203

199:                                              ; preds = %139
  br label %200

200:                                              ; preds = %199, %132
  %201 = load i32, ptr %19, align 4, !tbaa !9
  %202 = add nsw i32 %201, 1
  store i32 %202, ptr %19, align 4, !tbaa !9
  br label %116, !llvm.loop !27

203:                                              ; preds = %198, %122
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #8
  br label %206

204:                                              ; preds = %121
  call void @_ZN6R3GridD1Ev(ptr noundef nonnull align 8 dereferenceable(592) %15) #8
  call void @llvm.lifetime.end.p0(i64 592, ptr %15) #8
  br label %205

205:                                              ; preds = %204, %36
  ret void

206:                                              ; preds = %203, %85
  call void @_ZN6R3GridD1Ev(ptr noundef nonnull align 8 dereferenceable(592) %15) #8
  call void @llvm.lifetime.end.p0(i64 592, ptr %15) #8
  br label %207

207:                                              ; preds = %206
  %208 = load ptr, ptr %16, align 8
  %209 = load i32, ptr %17, align 4
  %210 = insertvalue { ptr, i32 } poison, ptr %208, 0
  %211 = insertvalue { ptr, i32 } %210, i32 %209, 1
  resume { ptr, i32 } %211
}

declare void @_ZN6R3GridC1ERKS_(ptr, ptr)

declare void @_ZN6R3GridD1Ev(ptr)

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 = { 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 = { 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 #6 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #7 = { 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 #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, !10, i64 580}
!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 584}
!20 = !{!12, !10, i64 588}
!21 = !{!12, !6, i64 560}
!22 = !{!18, !18, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = distinct !{!25, !24}
!26 = distinct !{!26, !24}
!27 = distinct !{!27, !24}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%class.R3Grid = type { %class.R3Affine, %class.R3Affine, double, double, ptr, [3 x i32], i32, i32, i32 }
%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 }

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592)) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592)) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592)) local_unnamed_addr #4 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R3Grid11PadWithZeroEiiiiii(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) local_unnamed_addr #5 align 2 personality ptr @__gxx_personality_v0 {
  %8 = alloca %class.R3Grid, align 8
  %9 = tail call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %.not = icmp slt i32 %9, %1
  br i1 %.not, label %14, label %10

10:                                               ; preds = %7
  %11 = tail call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %.not49 = icmp slt i32 %11, %2
  br i1 %.not49, label %14, label %12

12:                                               ; preds = %10
  %13 = tail call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %0)
  %.not50 = icmp slt i32 %13, %3
  br i1 %.not50, label %14, label %65

14:                                               ; preds = %12, %10, %7
  call void @llvm.lifetime.start.p0(i64 592, ptr nonnull %8) #7
  call void @_ZN6R3GridC1ERKS_(ptr noundef nonnull align 8 dereferenceable(592) %8, ptr noundef nonnull align 8 dereferenceable(592) %0)
  %15 = getelementptr inbounds i8, ptr %0, i64 568
  store i32 %1, ptr %15, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %0, i64 572
  store i32 %2, ptr %16, align 4, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %0, i64 576
  store i32 %3, ptr %17, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %0, i64 580
  store i32 %1, ptr %18, align 4, !tbaa !9
  %19 = mul nsw i32 %2, %1
  %20 = getelementptr inbounds i8, ptr %0, i64 584
  store i32 %19, ptr %20, align 8, !tbaa !18
  %21 = mul nsw i32 %19, %3
  %22 = getelementptr inbounds i8, ptr %0, i64 588
  store i32 %21, ptr %22, align 4, !tbaa !19
  %23 = getelementptr inbounds i8, ptr %0, i64 560
  %24 = load ptr, ptr %23, align 8, !tbaa !20
  %.not51 = icmp eq ptr %24, null
  br i1 %.not51, label %26, label %25

25:                                               ; preds = %14
  call void @_ZdaPv(ptr noundef nonnull %24) #8
  %.pr = load i32, ptr %22, align 4, !tbaa !19
  br label %26

26:                                               ; preds = %25, %14
  %27 = phi i32 [ %.pr, %25 ], [ %21, %14 ]
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %.thread, label %29

.thread:                                          ; preds = %26
  store ptr null, ptr %23, align 8, !tbaa !20
  br label %.preheader60

29:                                               ; preds = %26
  %30 = sext i32 %27 to i64
  %31 = icmp slt i32 %27, 0
  %32 = shl nsw i64 %30, 3
  %33 = select i1 %31, i64 -1, i64 %32
  %34 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %33) #9
          to label %37 unwind label %35

35:                                               ; preds = %29
  %36 = landingpad { ptr, i32 }
          cleanup
  br label %66

37:                                               ; preds = %29
  store ptr %34, ptr %23, align 8, !tbaa !20
  %38 = icmp sgt i32 %27, 0
  br i1 %38, label %.lr.ph, label %.preheader60

.lr.ph:                                           ; preds = %37
  %39 = zext nneg i32 %27 to i64
  %40 = shl nuw nsw i64 %39, 3
  call void @llvm.memset.p0.i64(ptr nonnull align 8 %34, i8 0, i64 %40, i1 false), !tbaa !21
  br label %.preheader60

.preheader60:                                     ; preds = %.thread, %.lr.ph, %37
  %41 = call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %8)
  %42 = icmp sgt i32 %41, 0
  br i1 %42, label %.lr.ph67, label %._crit_edge

._crit_edge:                                      ; preds = %.loopexit59, %.preheader60
  call void @_ZN6R3GridD1Ev(ptr noundef nonnull align 8 dereferenceable(592) %8) #7
  call void @llvm.lifetime.end.p0(i64 592, ptr nonnull %8) #7
  br label %65

.lr.ph67:                                         ; preds = %.preheader60, %.loopexit59
  %.04166 = phi i32 [ %62, %.loopexit59 ], [ 0, %.preheader60 ]
  %43 = add nsw i32 %.04166, %6
  %.not54 = icmp slt i32 %43, %3
  br i1 %.not54, label %.preheader58, label %.loopexit59

.preheader58:                                     ; preds = %.lr.ph67
  %44 = call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %8)
  %45 = icmp sgt i32 %44, 0
  br i1 %45, label %.lr.ph65, label %.loopexit59

.lr.ph65:                                         ; preds = %.preheader58, %.loopexit
  %.04064 = phi i32 [ %59, %.loopexit ], [ 0, %.preheader58 ]
  %46 = add nsw i32 %.04064, %5
  %.not55 = icmp slt i32 %46, %2
  br i1 %.not55, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %.lr.ph65
  %47 = call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %8)
  %48 = icmp sgt i32 %47, 0
  br i1 %48, label %.lr.ph63, label %.loopexit

.lr.ph63:                                         ; preds = %.preheader, %53
  %.03962 = phi i32 [ %54, %53 ], [ 0, %.preheader ]
  %49 = add nsw i32 %.03962, %4
  %.not56 = icmp slt i32 %49, %1
  br i1 %.not56, label %50, label %53

50:                                               ; preds = %.lr.ph63
  %51 = invoke noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %8, i32 noundef %.03962, i32 noundef %.04064, i32 noundef %.04166)
          to label %52 unwind label %57

52:                                               ; preds = %50
  invoke void @_ZN6R3Grid12SetGridValueEiiid(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef %49, i32 noundef %46, i32 noundef %43, double noundef %51)
          to label %53 unwind label %57

53:                                               ; preds = %52, %.lr.ph63
  %54 = add nuw nsw i32 %.03962, 1
  %55 = call noundef i32 @_ZNK6R3Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %8)
  %56 = icmp slt i32 %54, %55
  br i1 %56, label %.lr.ph63, label %.loopexit, !llvm.loop !22

57:                                               ; preds = %52, %50
  %58 = landingpad { ptr, i32 }
          cleanup
  br label %66

.loopexit:                                        ; preds = %53, %.preheader, %.lr.ph65
  %59 = add nuw nsw i32 %.04064, 1
  %60 = call noundef i32 @_ZNK6R3Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %8)
  %61 = icmp slt i32 %59, %60
  br i1 %61, label %.lr.ph65, label %.loopexit59, !llvm.loop !24

.loopexit59:                                      ; preds = %.loopexit, %.preheader58, %.lr.ph67
  %62 = add nuw nsw i32 %.04166, 1
  %63 = call noundef i32 @_ZNK6R3Grid11ZResolutionEv(ptr noundef nonnull align 8 dereferenceable(592) %8)
  %64 = icmp slt i32 %62, %63
  br i1 %64, label %.lr.ph67, label %._crit_edge, !llvm.loop !25

65:                                               ; preds = %12, %._crit_edge
  ret void

66:                                               ; preds = %57, %35
  %.pn = phi { ptr, i32 } [ %58, %57 ], [ %36, %35 ]
  call void @_ZN6R3GridD1Ev(ptr noundef nonnull align 8 dereferenceable(592) %8) #7
  call void @llvm.lifetime.end.p0(i64 592, ptr nonnull %8) #7
  resume { ptr, i32 } %.pn
}

declare void @_ZN6R3GridC1ERKS_(ptr, ptr) local_unnamed_addr

declare void @_ZN6R3GridD1Ev(ptr) local_unnamed_addr

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { 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 #3 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 580}
!10 = !{!"_ZTS6R3Grid", !11, i64 0, !11, i64 272, !16, i64 544, !16, i64 552, !17, i64 560, !7, i64 568, !6, i64 580, !6, i64 584, !6, i64 588}
!11 = !{!"_ZTS8R3Affine", !12, i64 0, !13, i64 8, !13, i64 136, !14, i64 264}
!12 = !{!"_ZTS16R3Transformation"}
!13 = !{!"_ZTS8R4Matrix", !7, i64 0}
!14 = !{!"_ZTS7RNFlags", !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!"double", !7, i64 0}
!17 = !{!"any pointer", !7, i64 0}
!18 = !{!10, !6, i64 584}
!19 = !{!10, !6, i64 588}
!20 = !{!10, !17, i64 560}
!21 = !{!16, !16, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = distinct !{!24, !23}
!25 = distinct !{!25, !23}


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