; LLVM IR from steps3d/graphics-book :: Code/Core (Texture)

; 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.TgaImage = type { ptr, i32, i32 }
%class.Texture = type { i32, i32, i32, i32, i32, i8, i32, %"class.std::__cxx11::basic_string" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

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 nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) #1 align 2

declare void @glGetTexImage(i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK7Texture10saveToFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj(ptr noundef nonnull align 8 dereferenceable(64) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef %2) #3 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i8, align 1
  %15 = alloca %class.TgaImage, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca %class.TgaImage, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  %20 = load ptr, ptr %5, align 8
  %21 = getelementptr inbounds %class.Texture, ptr %20, i32 0, i32 1
  %22 = load i32, ptr %21, align 4, !tbaa !11
  %23 = icmp ne i32 %22, 3552
  br i1 %23, label %24, label %33

24:                                               ; preds = %3
  %25 = getelementptr inbounds %class.Texture, ptr %20, i32 0, i32 1
  %26 = load i32, ptr %25, align 4, !tbaa !11
  %27 = icmp ne i32 %26, 3553
  br i1 %27, label %28, label %33

28:                                               ; preds = %24
  %29 = getelementptr inbounds %class.Texture, ptr %20, i32 0, i32 1
  %30 = load i32, ptr %29, align 4, !tbaa !11
  %31 = icmp ne i32 %30, 34037
  br i1 %31, label %32, label %33

32:                                               ; preds = %28
  store i1 false, ptr %4, align 1
  br label %150

33:                                               ; preds = %28, %24, %3
  %34 = load i32, ptr %7, align 4, !tbaa !9
  %35 = icmp eq i32 %34, 6402
  br i1 %35, label %36, label %123

36:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %37 = getelementptr inbounds %class.Texture, ptr %20, i32 0, i32 2
  %38 = load i32, ptr %37, align 8, !tbaa !17
  %39 = getelementptr inbounds %class.Texture, ptr %20, i32 0, i32 3
  %40 = load i32, ptr %39, align 4, !tbaa !18
  %41 = mul nsw i32 %38, %40
  %42 = sext i32 %41 to i64
  %43 = mul i64 %42, 4
  %44 = call noalias ptr @malloc(i64 noundef %43) #7
  store ptr %44, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %45 = getelementptr inbounds %class.Texture, ptr %20, i32 0, i32 2
  %46 = load i32, ptr %45, align 8, !tbaa !17
  %47 = getelementptr inbounds %class.Texture, ptr %20, i32 0, i32 3
  %48 = load i32, ptr %47, align 4, !tbaa !18
  %49 = mul nsw i32 %46, %48
  %50 = mul nsw i32 %49, 3
  %51 = sext i32 %50 to i64
  %52 = call noalias ptr @malloc(i64 noundef %51) #7
  store ptr %52, ptr %9, align 8, !tbaa !5
  %53 = getelementptr inbounds %class.Texture, ptr %20, i32 0, i32 1
  %54 = load i32, ptr %53, align 4, !tbaa !11
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  call void @glGetTexImage(i32 noundef %54, i32 noundef 0, i32 noundef 6402, i32 noundef 5126, ptr noundef %55)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %56

56:                                               ; preds = %103, %36
  %57 = load i32, ptr %10, align 4, !tbaa !9
  %58 = getelementptr inbounds %class.Texture, ptr %20, i32 0, i32 3
  %59 = load i32, ptr %58, align 4, !tbaa !18
  %60 = icmp slt i32 %57, %59
  br i1 %60, label %62, label %61

61:                                               ; preds = %56
  store i32 2, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %106

62:                                               ; preds = %56
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %63

63:                                               ; preds = %99, %62
  %64 = load i32, ptr %13, align 4, !tbaa !9
  %65 = getelementptr inbounds %class.Texture, ptr %20, i32 0, i32 2
  %66 = load i32, ptr %65, align 8, !tbaa !17
  %67 = icmp slt i32 %64, %66
  br i1 %67, label %69, label %68

68:                                               ; preds = %63
  store i32 5, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %102

69:                                               ; preds = %63
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #6
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = load i32, ptr %11, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds float, ptr %70, i64 %72
  %74 = load float, ptr %73, align 4, !tbaa !19
  %75 = fmul float 2.550000e+02, %74
  %76 = fptoui float %75 to i8
  store i8 %76, ptr %14, align 1, !tbaa !21
  %77 = load i8, ptr %14, align 1, !tbaa !21
  %78 = load ptr, ptr %9, align 8, !tbaa !5
  %79 = load i32, ptr %11, align 4, !tbaa !9
  %80 = mul nsw i32 3, %79
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds i8, ptr %78, i64 %81
  store i8 %77, ptr %82, align 1, !tbaa !21
  %83 = load i8, ptr %14, align 1, !tbaa !21
  %84 = load ptr, ptr %9, align 8, !tbaa !5
  %85 = load i32, ptr %11, align 4, !tbaa !9
  %86 = mul nsw i32 3, %85
  %87 = add nsw i32 %86, 1
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds i8, ptr %84, i64 %88
  store i8 %83, ptr %89, align 1, !tbaa !21
  %90 = load i8, ptr %14, align 1, !tbaa !21
  %91 = load ptr, ptr %9, align 8, !tbaa !5
  %92 = load i32, ptr %11, align 4, !tbaa !9
  %93 = mul nsw i32 3, %92
  %94 = add nsw i32 %93, 2
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds i8, ptr %91, i64 %95
  store i8 %90, ptr %96, align 1, !tbaa !21
  %97 = load i32, ptr %11, align 4, !tbaa !9
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #6
  br label %99

99:                                               ; preds = %69
  %100 = load i32, ptr %13, align 4, !tbaa !9
  %101 = add nsw i32 %100, 1
  store i32 %101, ptr %13, align 4, !tbaa !9
  br label %63, !llvm.loop !22

102:                                              ; preds = %68
  br label %103

103:                                              ; preds = %102
  %104 = load i32, ptr %10, align 4, !tbaa !9
  %105 = add nsw i32 %104, 1
  store i32 %105, ptr %10, align 4, !tbaa !9
  br label %56, !llvm.loop !24

106:                                              ; preds = %61
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #6
  %107 = getelementptr inbounds %class.Texture, ptr %20, i32 0, i32 2
  %108 = load i32, ptr %107, align 8, !tbaa !17
  %109 = getelementptr inbounds %class.Texture, ptr %20, i32 0, i32 3
  %110 = load i32, ptr %109, align 4, !tbaa !18
  call void @_ZN8TgaImageC1Eii(ptr noundef nonnull align 8 dereferenceable(16) %15, i32 noundef %108, i32 noundef %110)
  %111 = load ptr, ptr %9, align 8, !tbaa !5
  invoke void @_ZN8TgaImage10setRgbDataEPKh(ptr noundef nonnull align 8 dereferenceable(16) %15, ptr noundef %111)
          to label %112 unwind label %119

112:                                              ; preds = %106
  %113 = load ptr, ptr %6, align 8, !tbaa !5
  %114 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %113) #6
  %115 = invoke noundef zeroext i1 @_ZN8TgaImage11writeToFileEPKc(ptr noundef nonnull align 8 dereferenceable(16) %15, ptr noundef %114)
          to label %116 unwind label %119

116:                                              ; preds = %112
  %117 = load ptr, ptr %8, align 8, !tbaa !5
  call void @free(ptr noundef %117) #6
  %118 = load ptr, ptr %9, align 8, !tbaa !5
  call void @free(ptr noundef %118) #6
  store i1 true, ptr %4, align 1
  store i32 1, ptr %12, align 4
  call void @_ZN8TgaImageD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %15) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %150

119:                                              ; preds = %112, %106
  %120 = landingpad { ptr, i32 }
          cleanup
  %121 = extractvalue { ptr, i32 } %120, 0
  store ptr %121, ptr %16, align 8
  %122 = extractvalue { ptr, i32 } %120, 1
  store i32 %122, ptr %17, align 4
  call void @_ZN8TgaImageD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %15) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %152

123:                                              ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  %124 = getelementptr inbounds %class.Texture, ptr %20, i32 0, i32 2
  %125 = load i32, ptr %124, align 8, !tbaa !17
  %126 = getelementptr inbounds %class.Texture, ptr %20, i32 0, i32 3
  %127 = load i32, ptr %126, align 4, !tbaa !18
  %128 = mul nsw i32 %125, %127
  %129 = mul nsw i32 %128, 3
  %130 = sext i32 %129 to i64
  %131 = call noalias ptr @malloc(i64 noundef %130) #7
  store ptr %131, ptr %18, align 8, !tbaa !5
  %132 = getelementptr inbounds %class.Texture, ptr %20, i32 0, i32 1
  %133 = load i32, ptr %132, align 4, !tbaa !11
  %134 = load ptr, ptr %18, align 8, !tbaa !5
  call void @glGetTexImage(i32 noundef %133, i32 noundef 0, i32 noundef 6407, i32 noundef 5121, ptr noundef %134)
  call void @llvm.lifetime.start.p0(i64 16, ptr %19) #6
  %135 = getelementptr inbounds %class.Texture, ptr %20, i32 0, i32 2
  %136 = load i32, ptr %135, align 8, !tbaa !17
  %137 = getelementptr inbounds %class.Texture, ptr %20, i32 0, i32 3
  %138 = load i32, ptr %137, align 4, !tbaa !18
  call void @_ZN8TgaImageC1Eii(ptr noundef nonnull align 8 dereferenceable(16) %19, i32 noundef %136, i32 noundef %138)
  %139 = load ptr, ptr %18, align 8, !tbaa !5
  invoke void @_ZN8TgaImage10setRgbDataEPKh(ptr noundef nonnull align 8 dereferenceable(16) %19, ptr noundef %139)
          to label %140 unwind label %146

140:                                              ; preds = %123
  %141 = load ptr, ptr %6, align 8, !tbaa !5
  %142 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %141) #6
  %143 = invoke noundef zeroext i1 @_ZN8TgaImage11writeToFileEPKc(ptr noundef nonnull align 8 dereferenceable(16) %19, ptr noundef %142)
          to label %144 unwind label %146

144:                                              ; preds = %140
  %145 = load ptr, ptr %18, align 8, !tbaa !5
  call void @free(ptr noundef %145) #6
  store i1 true, ptr %4, align 1
  store i32 1, ptr %12, align 4
  call void @_ZN8TgaImageD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %19) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  br label %150

146:                                              ; preds = %140, %123
  %147 = landingpad { ptr, i32 }
          cleanup
  %148 = extractvalue { ptr, i32 } %147, 0
  store ptr %148, ptr %16, align 8
  %149 = extractvalue { ptr, i32 } %147, 1
  store i32 %149, ptr %17, align 4
  call void @_ZN8TgaImageD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %19) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  br label %152

150:                                              ; preds = %144, %116, %32
  %151 = load i1, ptr %4, align 1
  ret i1 %151

152:                                              ; preds = %146, %119
  %153 = load ptr, ptr %16, align 8
  %154 = load i32, ptr %17, align 4
  %155 = insertvalue { ptr, i32 } poison, ptr %153, 0
  %156 = insertvalue { ptr, i32 } %155, i32 %154, 1
  resume { ptr, i32 } %156
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #4

declare void @_ZN8TgaImageC1Eii(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, i32 noundef) unnamed_addr #2

declare void @_ZN8TgaImage10setRgbDataEPKh(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) #2

declare noundef zeroext i1 @_ZN8TgaImage11writeToFileEPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) #2

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = { nounwind 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 #5 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind }
attributes #7 = { nounwind 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 4}
!12 = !{!"_ZTS7Texture", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !13, i64 20, !10, i64 24, !14, i64 32}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !15, i64 0, !16, i64 8, !7, i64 16}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!12, !10, i64 8}
!18 = !{!12, !10, i64 12}
!19 = !{!20, !20, i64 0}
!20 = !{!"float", !7, i64 0}
!21 = !{!7, !7, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = distinct !{!24, !23}


; 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.TgaImage = type { ptr, i32, i32 }

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 nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1 align 2

declare void @glGetTexImage(i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK7Texture10saveToFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj(ptr nocapture noundef nonnull readonly align 8 dereferenceable(64) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef %2) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %class.TgaImage, align 8
  %5 = alloca %class.TgaImage, align 8
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  %7 = load i32, ptr %6, align 4, !tbaa !5
  switch i32 %7, label %72 [
    i32 3552, label %8
    i32 3553, label %8
    i32 34037, label %8
  ]

8:                                                ; preds = %3, %3, %3
  %9 = icmp eq i32 %2, 6402
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load i32, ptr %10, align 8, !tbaa !15
  %12 = getelementptr inbounds i8, ptr %0, i64 12
  %13 = load i32, ptr %12, align 4, !tbaa !16
  br i1 %9, label %14, label %59

14:                                               ; preds = %8
  %15 = mul nsw i32 %13, %11
  %16 = sext i32 %15 to i64
  %17 = shl nsw i64 %16, 2
  %18 = tail call noalias ptr @malloc(i64 noundef %17) #7
  %19 = mul nsw i32 %15, 3
  %20 = sext i32 %19 to i64
  %21 = tail call noalias ptr @malloc(i64 noundef %20) #7
  tail call void @glGetTexImage(i32 noundef %7, i32 noundef 0, i32 noundef 6402, i32 noundef 5126, ptr noundef %18)
  %22 = load i32, ptr %12, align 4, !tbaa !16
  %23 = icmp sgt i32 %22, 0
  %.pre = load i32, ptr %10, align 8, !tbaa !15
  %24 = icmp sgt i32 %.pre, 0
  %or.cond = select i1 %23, i1 %24, i1 false
  br i1 %or.cond, label %.preheader.us.preheader, label %._crit_edge42

.preheader.us.preheader:                          ; preds = %14
  %xtraiter = and i32 %.pre, 1
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  %25 = icmp eq i32 %.pre, 1
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us
  %.03141.us = phi i32 [ %52, %._crit_edge.us ], [ 0, %.preheader.us.preheader ]
  %.03340.us = phi i32 [ %27, %._crit_edge.us ], [ 0, %.preheader.us.preheader ]
  %26 = sext i32 %.03340.us to i64
  %27 = add i32 %.pre, %.03340.us
  br i1 %lcmp.mod.not, label %.prol.loopexit, label %.prol.loopexit.unr-lcssa

.prol.loopexit.unr-lcssa:                         ; preds = %.preheader.us
  %28 = getelementptr inbounds float, ptr %18, i64 %26
  %29 = load float, ptr %28, align 4, !tbaa !17
  %30 = fmul float %29, 2.550000e+02
  %31 = fptoui float %30 to i8
  %32 = mul nsw i64 %26, 3
  %33 = getelementptr inbounds i8, ptr %21, i64 %32
  store i8 %31, ptr %33, align 1, !tbaa !19
  %34 = getelementptr i8, ptr %33, i64 1
  store i8 %31, ptr %34, align 1, !tbaa !19
  %35 = getelementptr i8, ptr %33, i64 2
  store i8 %31, ptr %35, align 1, !tbaa !19
  %indvars.iv.next.prol = add nsw i64 %26, 1
  br label %.prol.loopexit

.prol.loopexit:                                   ; preds = %.prol.loopexit.unr-lcssa, %.preheader.us
  %indvars.iv.unr = phi i64 [ %26, %.preheader.us ], [ %indvars.iv.next.prol, %.prol.loopexit.unr-lcssa ]
  br i1 %25, label %._crit_edge.us, label %.preheader.us.new

.preheader.us.new:                                ; preds = %.prol.loopexit, %.preheader.us.new
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %.preheader.us.new ], [ %indvars.iv.unr, %.prol.loopexit ]
  %36 = getelementptr inbounds float, ptr %18, i64 %indvars.iv
  %37 = load float, ptr %36, align 4, !tbaa !17
  %38 = fmul float %37, 2.550000e+02
  %39 = fptoui float %38 to i8
  %40 = mul nsw i64 %indvars.iv, 3
  %41 = getelementptr inbounds i8, ptr %21, i64 %40
  store i8 %39, ptr %41, align 1, !tbaa !19
  %42 = getelementptr i8, ptr %41, i64 1
  store i8 %39, ptr %42, align 1, !tbaa !19
  %43 = getelementptr i8, ptr %41, i64 2
  store i8 %39, ptr %43, align 1, !tbaa !19
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %44 = getelementptr inbounds float, ptr %18, i64 %indvars.iv.next
  %45 = load float, ptr %44, align 4, !tbaa !17
  %46 = fmul float %45, 2.550000e+02
  %47 = fptoui float %46 to i8
  %48 = mul nsw i64 %indvars.iv.next, 3
  %49 = getelementptr inbounds i8, ptr %21, i64 %48
  store i8 %47, ptr %49, align 1, !tbaa !19
  %50 = getelementptr i8, ptr %49, i64 1
  store i8 %47, ptr %50, align 1, !tbaa !19
  %51 = getelementptr i8, ptr %49, i64 2
  store i8 %47, ptr %51, align 1, !tbaa !19
  %indvars.iv.next.1 = add nsw i64 %indvars.iv, 2
  %lftr.wideiv.1 = trunc i64 %indvars.iv.next.1 to i32
  %exitcond.not.1 = icmp eq i32 %27, %lftr.wideiv.1
  br i1 %exitcond.not.1, label %._crit_edge.us, label %.preheader.us.new, !llvm.loop !20

._crit_edge.us:                                   ; preds = %.preheader.us.new, %.prol.loopexit
  %52 = add nuw nsw i32 %.03141.us, 1
  %exitcond46.not = icmp eq i32 %52, %22
  br i1 %exitcond46.not, label %._crit_edge42, label %.preheader.us, !llvm.loop !22

._crit_edge42:                                    ; preds = %._crit_edge.us, %14
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #8
  call void @_ZN8TgaImageC1Eii(ptr noundef nonnull align 8 dereferenceable(16) %4, i32 noundef %.pre, i32 noundef %22)
  invoke void @_ZN8TgaImage10setRgbDataEPKh(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef %21)
          to label %53 unwind label %57

53:                                               ; preds = %._crit_edge42
  %54 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %1) #8
  %55 = invoke noundef zeroext i1 @_ZN8TgaImage11writeToFileEPKc(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef %54)
          to label %56 unwind label %57

56:                                               ; preds = %53
  call void @free(ptr noundef %18) #8
  call void @free(ptr noundef %21) #8
  call void @_ZN8TgaImageD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %4) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #8
  br label %72

57:                                               ; preds = %53, %._crit_edge42
  %58 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN8TgaImageD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %4) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #8
  br label %73

59:                                               ; preds = %8
  %60 = mul i32 %11, 3
  %61 = mul i32 %60, %13
  %62 = sext i32 %61 to i64
  %63 = tail call noalias ptr @malloc(i64 noundef %62) #7
  tail call void @glGetTexImage(i32 noundef %7, i32 noundef 0, i32 noundef 6407, i32 noundef 5121, ptr noundef %63)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #8
  %64 = load i32, ptr %10, align 8, !tbaa !15
  %65 = load i32, ptr %12, align 4, !tbaa !16
  call void @_ZN8TgaImageC1Eii(ptr noundef nonnull align 8 dereferenceable(16) %5, i32 noundef %64, i32 noundef %65)
  invoke void @_ZN8TgaImage10setRgbDataEPKh(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef %63)
          to label %66 unwind label %70

66:                                               ; preds = %59
  %67 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %1) #8
  %68 = invoke noundef zeroext i1 @_ZN8TgaImage11writeToFileEPKc(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef %67)
          to label %69 unwind label %70

69:                                               ; preds = %66
  call void @free(ptr noundef %63) #8
  call void @_ZN8TgaImageD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #8
  br label %72

70:                                               ; preds = %66, %59
  %71 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN8TgaImageD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #8
  br label %73

72:                                               ; preds = %3, %69, %56
  %.0 = phi i1 [ true, %56 ], [ true, %69 ], [ false, %3 ]
  ret i1 %.0

73:                                               ; preds = %70, %57
  %.pn = phi { ptr, i32 } [ %58, %57 ], [ %71, %70 ]
  resume { ptr, i32 } %.pn
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #4

declare void @_ZN8TgaImageC1Eii(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, i32 noundef) unnamed_addr #2

declare void @_ZN8TgaImage10setRgbDataEPKh(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) local_unnamed_addr #2

declare noundef zeroext i1 @_ZN8TgaImage11writeToFileEPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #5

; Function Attrs: nounwind
declare void @_ZN8TgaImageD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #6

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 #7 = { nounwind allocsize(0) }
attributes #8 = { 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, !7, i64 4}
!6 = !{!"_ZTS7Texture", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !10, i64 20, !7, i64 24, !11, i64 32}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !12, i64 0, !14, i64 8, !8, i64 16}
!12 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !13, i64 0}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!"long", !8, i64 0}
!15 = !{!6, !7, i64 8}
!16 = !{!6, !7, i64 12}
!17 = !{!18, !18, i64 0}
!18 = !{!"float", !8, i64 0}
!19 = !{!8, !8, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}


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