; LLVM IR from erwincoumans/tiny-differentiable-simulator :: src/visualizer/opengl (tiny_opengl3_app)

; 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.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.TinyOpenGL3App = type { %struct.TinyCommonGraphicsApp.base, ptr, ptr, ptr }
%struct.TinyCommonGraphicsApp.base = type <{ ptr, ptr, ptr, ptr, ptr, i8, i8, i8, i8, float, float, float, float, i8, [3 x i8], [3 x float] }>
%struct.TinyOpenGL3AppInternalData = type { i32, i32, ptr, ptr, ptr, ptr, i32, i32, i32, ptr, ptr, ptr, ptr, i32, i32, i32, i32 }

@_ZL21point_sphere_vertices = external hidden constant [9 x float], align 16
@_ZL20point_sphere_indices = external hidden constant [1 x i32], align 4
@_ZL19low_sphere_vertices = external hidden constant [2160 x float], align 16
@_ZL18low_sphere_indices = external hidden constant [240 x i32], align 16
@_ZL33textured_detailed_sphere_vertices = external hidden constant [48384 x float], align 16
@_ZL32textured_detailed_sphere_indices = external hidden constant [5376 x i32], align 16

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN14TinyOpenGL3App35register_graphics_unit_sphere_shapeE23EnumSphereLevelOfDetaili(ptr noundef nonnull align 8 dereferenceable(104) %0, i32 noundef %1, i32 noundef %2) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %"class.std::vector.0", align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %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 i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  %27 = alloca i32, align 4
  %28 = alloca i32, align 4
  %29 = alloca i32, align 4
  %30 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !11
  %31 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 255, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !11
  %32 = load i32, ptr %6, align 4, !tbaa !11
  %33 = icmp slt i32 %32, 0
  br i1 %33, label %34, label %155

34:                                               ; preds = %3
  %35 = getelementptr inbounds %struct.TinyOpenGL3App, ptr %31, i32 0, i32 1
  %36 = load ptr, ptr %35, align 8, !tbaa !13
  %37 = getelementptr inbounds %struct.TinyOpenGL3AppInternalData, ptr %36, i32 0, i32 8
  %38 = load i32, ptr %37, align 8, !tbaa !18
  %39 = icmp slt i32 %38, 0
  br i1 %39, label %40, label %150

40:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 1024, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 1024, ptr %11, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 24, ptr %12) #3
  call void @_ZNSt6vectorIhSaIhEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %12) #3
  %41 = load i32, ptr %10, align 4, !tbaa !11
  %42 = load i32, ptr %11, align 4, !tbaa !11
  %43 = mul nsw i32 %41, %42
  %44 = mul nsw i32 %43, 3
  %45 = sext i32 %44 to i64
  invoke void @_ZNSt6vectorIhSaIhEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef %45)
          to label %46 unwind label %55

46:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  store i32 0, ptr %15, align 4, !tbaa !11
  br label %47

47:                                               ; preds = %63, %46
  %48 = load i32, ptr %15, align 4, !tbaa !11
  %49 = load i32, ptr %10, align 4, !tbaa !11
  %50 = load i32, ptr %11, align 4, !tbaa !11
  %51 = mul nsw i32 %49, %50
  %52 = mul nsw i32 %51, 3
  %53 = icmp slt i32 %48, %52
  br i1 %53, label %59, label %54

54:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  br label %66

55:                                               ; preds = %136, %40
  %56 = landingpad { ptr, i32 }
          cleanup
  %57 = extractvalue { ptr, i32 } %56, 0
  store ptr %57, ptr %13, align 8
  %58 = extractvalue { ptr, i32 } %56, 1
  store i32 %58, ptr %14, align 4
  call void @_ZNSt6vectorIhSaIhEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %12) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %216

59:                                               ; preds = %47
  %60 = load i32, ptr %15, align 4, !tbaa !11
  %61 = sext i32 %60 to i64
  %62 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef %61) #3
  store i8 -1, ptr %62, align 1, !tbaa !20
  br label %63

63:                                               ; preds = %59
  %64 = load i32, ptr %15, align 4, !tbaa !11
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %15, align 4, !tbaa !11
  br label %47, !llvm.loop !21

66:                                               ; preds = %54
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  store i32 0, ptr %16, align 4, !tbaa !11
  br label %67

67:                                               ; preds = %133, %66
  %68 = load i32, ptr %16, align 4, !tbaa !11
  %69 = load i32, ptr %10, align 4, !tbaa !11
  %70 = icmp slt i32 %68, %69
  br i1 %70, label %72, label %71

71:                                               ; preds = %67
  store i32 5, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  br label %136

72:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  store i32 0, ptr %18, align 4, !tbaa !11
  br label %73

73:                                               ; preds = %129, %72
  %74 = load i32, ptr %18, align 4, !tbaa !11
  %75 = load i32, ptr %11, align 4, !tbaa !11
  %76 = icmp slt i32 %74, %75
  br i1 %76, label %78, label %77

77:                                               ; preds = %73
  store i32 8, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  br label %132

78:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  %79 = load i32, ptr %16, align 4, !tbaa !11
  %80 = load i32, ptr %10, align 4, !tbaa !11
  %81 = sdiv i32 %80, 2
  %82 = icmp slt i32 %79, %81
  %83 = zext i1 %82 to i64
  %84 = select i1 %82, i32 1, i32 0
  store i32 %84, ptr %19, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  %85 = load i32, ptr %18, align 4, !tbaa !11
  %86 = load i32, ptr %10, align 4, !tbaa !11
  %87 = sdiv i32 %86, 2
  %88 = icmp slt i32 %85, %87
  %89 = zext i1 %88 to i64
  %90 = select i1 %88, i32 1, i32 0
  store i32 %90, ptr %20, align 4, !tbaa !11
  %91 = load i32, ptr %19, align 4, !tbaa !11
  %92 = load i32, ptr %20, align 4, !tbaa !11
  %93 = icmp eq i32 %91, %92
  br i1 %93, label %94, label %128

94:                                               ; preds = %78
  %95 = load i32, ptr %7, align 4, !tbaa !11
  %96 = trunc i32 %95 to i8
  %97 = load i32, ptr %16, align 4, !tbaa !11
  %98 = load i32, ptr %18, align 4, !tbaa !11
  %99 = load i32, ptr %10, align 4, !tbaa !11
  %100 = mul nsw i32 %98, %99
  %101 = add nsw i32 %97, %100
  %102 = mul nsw i32 %101, 3
  %103 = add nsw i32 %102, 0
  %104 = sext i32 %103 to i64
  %105 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef %104) #3
  store i8 %96, ptr %105, align 1, !tbaa !20
  %106 = load i32, ptr %8, align 4, !tbaa !11
  %107 = trunc i32 %106 to i8
  %108 = load i32, ptr %16, align 4, !tbaa !11
  %109 = load i32, ptr %18, align 4, !tbaa !11
  %110 = load i32, ptr %10, align 4, !tbaa !11
  %111 = mul nsw i32 %109, %110
  %112 = add nsw i32 %108, %111
  %113 = mul nsw i32 %112, 3
  %114 = add nsw i32 %113, 1
  %115 = sext i32 %114 to i64
  %116 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef %115) #3
  store i8 %107, ptr %116, align 1, !tbaa !20
  %117 = load i32, ptr %9, align 4, !tbaa !11
  %118 = trunc i32 %117 to i8
  %119 = load i32, ptr %16, align 4, !tbaa !11
  %120 = load i32, ptr %18, align 4, !tbaa !11
  %121 = load i32, ptr %10, align 4, !tbaa !11
  %122 = mul nsw i32 %120, %121
  %123 = add nsw i32 %119, %122
  %124 = mul nsw i32 %123, 3
  %125 = add nsw i32 %124, 2
  %126 = sext i32 %125 to i64
  %127 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef %126) #3
  store i8 %118, ptr %127, align 1, !tbaa !20
  br label %128

128:                                              ; preds = %94, %78
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  br label %129

129:                                              ; preds = %128
  %130 = load i32, ptr %18, align 4, !tbaa !11
  %131 = add nsw i32 %130, 1
  store i32 %131, ptr %18, align 4, !tbaa !11
  br label %73, !llvm.loop !23

132:                                              ; preds = %77
  br label %133

133:                                              ; preds = %132
  %134 = load i32, ptr %16, align 4, !tbaa !11
  %135 = add nsw i32 %134, 1
  store i32 %135, ptr %16, align 4, !tbaa !11
  br label %67, !llvm.loop !24

136:                                              ; preds = %71
  %137 = getelementptr inbounds %struct.TinyOpenGL3App, ptr %31, i32 0, i32 3
  %138 = load ptr, ptr %137, align 8, !tbaa !25
  %139 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef 0) #3
  %140 = load i32, ptr %10, align 4, !tbaa !11
  %141 = load i32, ptr %11, align 4, !tbaa !11
  %142 = load ptr, ptr %138, align 8, !tbaa !26
  %143 = getelementptr inbounds ptr, ptr %142, i64 11
  %144 = load ptr, ptr %143, align 8
  %145 = invoke noundef i32 %144(ptr noundef nonnull align 8 dereferenceable(60) %138, ptr noundef %139, i32 noundef %140, i32 noundef %141, i1 noundef zeroext true)
          to label %146 unwind label %55

146:                                              ; preds = %136
  %147 = getelementptr inbounds %struct.TinyOpenGL3App, ptr %31, i32 0, i32 1
  %148 = load ptr, ptr %147, align 8, !tbaa !13
  %149 = getelementptr inbounds %struct.TinyOpenGL3AppInternalData, ptr %148, i32 0, i32 8
  store i32 %145, ptr %149, align 8, !tbaa !18
  call void @_ZNSt6vectorIhSaIhEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %12) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %150

150:                                              ; preds = %146, %34
  %151 = getelementptr inbounds %struct.TinyOpenGL3App, ptr %31, i32 0, i32 1
  %152 = load ptr, ptr %151, align 8, !tbaa !13
  %153 = getelementptr inbounds %struct.TinyOpenGL3AppInternalData, ptr %152, i32 0, i32 8
  %154 = load i32, ptr %153, align 8, !tbaa !18
  store i32 %154, ptr %6, align 4, !tbaa !11
  br label %155

155:                                              ; preds = %150, %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  store i32 36, ptr %21, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  store i32 -1, ptr %22, align 4, !tbaa !11
  %156 = load i32, ptr %5, align 4, !tbaa !9
  switch i32 %156, label %200 [
    i32 0, label %157
    i32 1, label %171
    i32 2, label %185
    i32 3, label %199
  ]

157:                                              ; preds = %155
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #3
  %158 = load i32, ptr %21, align 4, !tbaa !11
  %159 = sext i32 %158 to i64
  %160 = udiv i64 36, %159
  %161 = trunc i64 %160 to i32
  store i32 %161, ptr %23, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #3
  store i32 1, ptr %24, align 4, !tbaa !11
  %162 = getelementptr inbounds %struct.TinyOpenGL3App, ptr %31, i32 0, i32 3
  %163 = load ptr, ptr %162, align 8, !tbaa !25
  %164 = load i32, ptr %23, align 4, !tbaa !11
  %165 = load i32, ptr %24, align 4, !tbaa !11
  %166 = load i32, ptr %6, align 4, !tbaa !11
  %167 = load ptr, ptr %163, align 8, !tbaa !26
  %168 = getelementptr inbounds ptr, ptr %167, i64 9
  %169 = load ptr, ptr %168, align 8
  %170 = call noundef i32 %169(ptr noundef nonnull align 8 dereferenceable(60) %163, ptr noundef @_ZL21point_sphere_vertices, i32 noundef %164, ptr noundef @_ZL20point_sphere_indices, i32 noundef %165, i32 noundef 2, i32 noundef %166)
  store i32 %170, ptr %22, align 4, !tbaa !11
  store i32 11, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #3
  br label %214

171:                                              ; preds = %155
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #3
  %172 = load i32, ptr %21, align 4, !tbaa !11
  %173 = sext i32 %172 to i64
  %174 = udiv i64 8640, %173
  %175 = trunc i64 %174 to i32
  store i32 %175, ptr %25, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #3
  store i32 240, ptr %26, align 4, !tbaa !11
  %176 = getelementptr inbounds %struct.TinyOpenGL3App, ptr %31, i32 0, i32 3
  %177 = load ptr, ptr %176, align 8, !tbaa !25
  %178 = load i32, ptr %25, align 4, !tbaa !11
  %179 = load i32, ptr %26, align 4, !tbaa !11
  %180 = load i32, ptr %6, align 4, !tbaa !11
  %181 = load ptr, ptr %177, align 8, !tbaa !26
  %182 = getelementptr inbounds ptr, ptr %181, i64 9
  %183 = load ptr, ptr %182, align 8
  %184 = call noundef i32 %183(ptr noundef nonnull align 8 dereferenceable(60) %177, ptr noundef @_ZL19low_sphere_vertices, i32 noundef %178, ptr noundef @_ZL18low_sphere_indices, i32 noundef %179, i32 noundef 1, i32 noundef %180)
  store i32 %184, ptr %22, align 4, !tbaa !11
  store i32 11, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #3
  br label %214

185:                                              ; preds = %155
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #3
  %186 = load i32, ptr %21, align 4, !tbaa !11
  %187 = sext i32 %186 to i64
  %188 = udiv i64 193536, %187
  %189 = trunc i64 %188 to i32
  store i32 %189, ptr %27, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %28) #3
  store i32 5376, ptr %28, align 4, !tbaa !11
  %190 = getelementptr inbounds %struct.TinyOpenGL3App, ptr %31, i32 0, i32 3
  %191 = load ptr, ptr %190, align 8, !tbaa !25
  %192 = load i32, ptr %27, align 4, !tbaa !11
  %193 = load i32, ptr %28, align 4, !tbaa !11
  %194 = load i32, ptr %6, align 4, !tbaa !11
  %195 = load ptr, ptr %191, align 8, !tbaa !26
  %196 = getelementptr inbounds ptr, ptr %195, i64 9
  %197 = load ptr, ptr %196, align 8
  %198 = call noundef i32 %197(ptr noundef nonnull align 8 dereferenceable(60) %191, ptr noundef @_ZL33textured_detailed_sphere_vertices, i32 noundef %192, ptr noundef @_ZL32textured_detailed_sphere_indices, i32 noundef %193, i32 noundef 1, i32 noundef %194)
  store i32 %198, ptr %22, align 4, !tbaa !11
  store i32 11, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %28) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #3
  br label %214

199:                                              ; preds = %155
  br label %200

200:                                              ; preds = %199, %155
  call void @llvm.lifetime.start.p0(i64 4, ptr %29) #3
  %201 = load i32, ptr %21, align 4, !tbaa !11
  %202 = sext i32 %201 to i64
  %203 = udiv i64 193536, %202
  %204 = trunc i64 %203 to i32
  store i32 %204, ptr %29, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %30) #3
  store i32 5376, ptr %30, align 4, !tbaa !11
  %205 = getelementptr inbounds %struct.TinyOpenGL3App, ptr %31, i32 0, i32 3
  %206 = load ptr, ptr %205, align 8, !tbaa !25
  %207 = load i32, ptr %29, align 4, !tbaa !11
  %208 = load i32, ptr %30, align 4, !tbaa !11
  %209 = load i32, ptr %6, align 4, !tbaa !11
  %210 = load ptr, ptr %206, align 8, !tbaa !26
  %211 = getelementptr inbounds ptr, ptr %210, i64 9
  %212 = load ptr, ptr %211, align 8
  %213 = call noundef i32 %212(ptr noundef nonnull align 8 dereferenceable(60) %206, ptr noundef @_ZL33textured_detailed_sphere_vertices, i32 noundef %207, ptr noundef @_ZL32textured_detailed_sphere_indices, i32 noundef %208, i32 noundef 1, i32 noundef %209)
  store i32 %213, ptr %22, align 4, !tbaa !11
  store i32 11, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #3
  br label %214

214:                                              ; preds = %200, %185, %171, %157
  %215 = load i32, ptr %22, align 4, !tbaa !11
  store i32 1, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret i32 %215

216:                                              ; preds = %55
  %217 = load ptr, ptr %13, align 8
  %218 = load i32, ptr %14, align 4
  %219 = insertvalue { ptr, i32 } poison, ptr %217, 0
  %220 = insertvalue { ptr, i32 } %219, i32 %218, 1
  resume { ptr, i32 } %220
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIhSaIhEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIhSaIhEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIhSaIhEED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { 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 = !{!"_ZTS23EnumSphereLevelOfDetail", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 80}
!14 = !{!"_ZTS14TinyOpenGL3App", !15, i64 0, !6, i64 80, !6, i64 88, !6, i64 96}
!15 = !{!"_ZTS21TinyCommonGraphicsApp", !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !16, i64 40, !16, i64 41, !16, i64 42, !17, i64 44, !17, i64 48, !17, i64 52, !17, i64 56, !16, i64 60, !7, i64 64}
!16 = !{!"bool", !7, i64 0}
!17 = !{!"float", !7, i64 0}
!18 = !{!19, !12, i64 48}
!19 = !{!"_ZTS26TinyOpenGL3AppInternalData", !12, i64 0, !12, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !12, i64 40, !12, i64 44, !12, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !12, i64 88, !12, i64 92, !12, i64 96, !12, i64 100}
!20 = !{!7, !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}
!24 = distinct !{!24, !22}
!25 = !{!14, !6, i64 96}
!26 = !{!27, !27, i64 0}
!27 = !{!"vtable pointer", !8, i64 0}


; 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.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@_ZL21point_sphere_vertices = external hidden constant [9 x float], align 16
@_ZL20point_sphere_indices = external hidden constant [1 x i32], align 4
@_ZL19low_sphere_vertices = external hidden constant [2160 x float], align 16
@_ZL18low_sphere_indices = external hidden constant [240 x i32], align 16
@_ZL33textured_detailed_sphere_vertices = external hidden constant [48384 x float], align 16
@_ZL32textured_detailed_sphere_indices = external hidden constant [5376 x i32], align 16

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN14TinyOpenGL3App35register_graphics_unit_sphere_shapeE23EnumSphereLevelOfDetaili(ptr nocapture noundef nonnull readonly align 8 dereferenceable(104) %0, i32 noundef %1, i32 noundef %2) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.std::vector.0", align 8
  %5 = icmp slt i32 %2, 0
  br i1 %5, label %6, label %42

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 80
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %8, i64 48
  %10 = load i32, ptr %9, align 8, !tbaa !13
  %11 = icmp slt i32 %10, 0
  br i1 %11, label %12, label %42

12:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #3
  call void @_ZNSt6vectorIhSaIhEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #3
  invoke void @_ZNSt6vectorIhSaIhEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef 3145728)
          to label %.preheader60 unwind label %13

13:                                               ; preds = %17, %12
  %14 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt6vectorIhSaIhEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #3
  resume { ptr, i32 } %14

.preheader60:                                     ; preds = %12, %.preheader60
  %indvars.iv = phi i64 [ %indvars.iv.next, %.preheader60 ], [ 0, %12 ]
  %15 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %indvars.iv) #3
  store i8 -1, ptr %15, align 1, !tbaa !16
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 3145728
  br i1 %exitcond.not, label %.preheader, label %.preheader60, !llvm.loop !17

.preheader:                                       ; preds = %.preheader60, %25
  %indvars.iv69 = phi i64 [ %indvars.iv.next70, %25 ], [ 0, %.preheader60 ]
  %16 = icmp ult i64 %indvars.iv69, 512
  br label %26

17:                                               ; preds = %25
  %18 = getelementptr inbounds i8, ptr %0, i64 96
  %19 = load ptr, ptr %18, align 8, !tbaa !19
  %20 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef 0) #3
  %21 = load ptr, ptr %19, align 8, !tbaa !20
  %22 = getelementptr inbounds i8, ptr %21, i64 88
  %23 = load ptr, ptr %22, align 8
  %24 = invoke noundef i32 %23(ptr noundef nonnull align 8 dereferenceable(60) %19, ptr noundef nonnull %20, i32 noundef 1024, i32 noundef 1024, i1 noundef zeroext true)
          to label %39 unwind label %13

25:                                               ; preds = %38
  %indvars.iv.next70 = add nuw nsw i64 %indvars.iv69, 1
  %exitcond72.not = icmp eq i64 %indvars.iv.next70, 1024
  br i1 %exitcond72.not, label %17, label %.preheader, !llvm.loop !22

26:                                               ; preds = %.preheader, %38
  %indvars.iv65 = phi i64 [ 0, %.preheader ], [ %indvars.iv.next66, %38 ]
  %27 = icmp ugt i64 %indvars.iv65, 511
  %28 = xor i1 %16, %27
  br i1 %28, label %29, label %38

29:                                               ; preds = %26
  %30 = shl nuw nsw i64 %indvars.iv65, 10
  %31 = add nuw nsw i64 %30, %indvars.iv69
  %32 = mul nuw nsw i64 %31, 3
  %33 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %32) #3
  store i8 0, ptr %33, align 1, !tbaa !16
  %34 = add nuw nsw i64 %32, 1
  %35 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %34) #3
  store i8 -1, ptr %35, align 1, !tbaa !16
  %36 = add nuw nsw i64 %32, 2
  %37 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %36) #3
  store i8 0, ptr %37, align 1, !tbaa !16
  br label %38

38:                                               ; preds = %29, %26
  %indvars.iv.next66 = add nuw nsw i64 %indvars.iv65, 1
  %exitcond68.not = icmp eq i64 %indvars.iv.next66, 1024
  br i1 %exitcond68.not, label %25, label %26, !llvm.loop !23

39:                                               ; preds = %17
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %40, i64 48
  store i32 %24, ptr %41, align 8, !tbaa !13
  call void @_ZNSt6vectorIhSaIhEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #3
  %.pre = load ptr, ptr %7, align 8, !tbaa !5
  %.phi.trans.insert = getelementptr inbounds i8, ptr %.pre, i64 48
  %.pre73 = load i32, ptr %.phi.trans.insert, align 8, !tbaa !13
  br label %42

42:                                               ; preds = %6, %39, %3
  %.0 = phi i32 [ %2, %3 ], [ %.pre73, %39 ], [ %10, %6 ]
  %43 = getelementptr inbounds i8, ptr %0, i64 96
  %44 = load ptr, ptr %43, align 8, !tbaa !19
  %45 = load ptr, ptr %44, align 8, !tbaa !20
  %46 = getelementptr inbounds i8, ptr %45, i64 72
  %47 = load ptr, ptr %46, align 8
  switch i32 %1, label %54 [
    i32 0, label %48
    i32 1, label %50
    i32 2, label %52
  ]

48:                                               ; preds = %42
  %49 = call noundef i32 %47(ptr noundef nonnull align 8 dereferenceable(60) %44, ptr noundef nonnull @_ZL21point_sphere_vertices, i32 noundef 1, ptr noundef nonnull @_ZL20point_sphere_indices, i32 noundef 1, i32 noundef 2, i32 noundef %.0)
  br label %56

50:                                               ; preds = %42
  %51 = call noundef i32 %47(ptr noundef nonnull align 8 dereferenceable(60) %44, ptr noundef nonnull @_ZL19low_sphere_vertices, i32 noundef 240, ptr noundef nonnull @_ZL18low_sphere_indices, i32 noundef 240, i32 noundef 1, i32 noundef %.0)
  br label %56

52:                                               ; preds = %42
  %53 = call noundef i32 %47(ptr noundef nonnull align 8 dereferenceable(60) %44, ptr noundef nonnull @_ZL33textured_detailed_sphere_vertices, i32 noundef 5376, ptr noundef nonnull @_ZL32textured_detailed_sphere_indices, i32 noundef 5376, i32 noundef 1, i32 noundef %.0)
  br label %56

54:                                               ; preds = %42
  %55 = call noundef i32 %47(ptr noundef nonnull align 8 dereferenceable(60) %44, ptr noundef nonnull @_ZL33textured_detailed_sphere_vertices, i32 noundef 5376, ptr noundef nonnull @_ZL32textured_detailed_sphere_indices, i32 noundef 5376, i32 noundef 1, i32 noundef %.0)
  br label %56

56:                                               ; preds = %54, %52, %50, %48
  %.057 = phi i32 [ %55, %54 ], [ %53, %52 ], [ %51, %50 ], [ %49, %48 ]
  ret i32 %.057
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIhSaIhEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIhSaIhEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIhSaIhEED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { 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, !8, i64 80}
!6 = !{!"_ZTS14TinyOpenGL3App", !7, i64 0, !8, i64 80, !8, i64 88, !8, i64 96}
!7 = !{!"_ZTS21TinyCommonGraphicsApp", !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !11, i64 40, !11, i64 41, !11, i64 42, !12, i64 44, !12, i64 48, !12, i64 52, !12, i64 56, !11, i64 60, !9, i64 64}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"bool", !9, i64 0}
!12 = !{!"float", !9, i64 0}
!13 = !{!14, !15, i64 48}
!14 = !{!"_ZTS26TinyOpenGL3AppInternalData", !15, i64 0, !15, i64 4, !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !15, i64 40, !15, i64 44, !15, i64 48, !8, i64 56, !8, i64 64, !8, i64 72, !8, i64 80, !15, i64 88, !15, i64 92, !15, i64 96, !15, i64 100}
!15 = !{!"int", !9, i64 0}
!16 = !{!9, !9, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!6, !8, i64 96}
!20 = !{!21, !21, i64 0}
!21 = !{!"vtable pointer", !10, i64 0}
!22 = distinct !{!22, !18}
!23 = distinct !{!23, !18}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass