; LLVM IR from Xingyu-Lin/softgym :: PyFlex/core/tga.ll (Z7TgaSaveP8_IO_FILERK8TgaImageb)

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

%struct.TgaHeader = type { i8, i8, i8, i16, i16, i8, i16, i16, i16, i16, i8, i8 }
%union.texel = type { i32 }
%struct.TgaImage = type { i16, i16, ptr }

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z7TgaSaveP8_IO_FILERK8TgaImageb(ptr noundef %0, ptr noundef nonnull align 8 dereferenceable(16) %1, i1 noundef zeroext %2) #1 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  %8 = alloca %struct.TgaHeader, align 2
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca %union.texel, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  %15 = zext i1 %2 to i8
  store i8 %15, ptr %7, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 20, ptr %8) #9
  %16 = getelementptr inbounds %struct.TgaHeader, ptr %8, i32 0, i32 0
  store i8 0, ptr %16, align 2, !tbaa !11
  %17 = getelementptr inbounds %struct.TgaHeader, ptr %8, i32 0, i32 1
  store i8 0, ptr %17, align 1, !tbaa !14
  %18 = load i8, ptr %7, align 1, !tbaa !9, !range !15, !noundef !16
  %19 = trunc i8 %18 to i1
  %20 = zext i1 %19 to i64
  %21 = select i1 %19, i32 9, i32 2
  %22 = trunc i32 %21 to i8
  %23 = getelementptr inbounds %struct.TgaHeader, ptr %8, i32 0, i32 2
  store i8 %22, ptr %23, align 2, !tbaa !17
  %24 = getelementptr inbounds %struct.TgaHeader, ptr %8, i32 0, i32 3
  store i16 0, ptr %24, align 2, !tbaa !18
  %25 = getelementptr inbounds %struct.TgaHeader, ptr %8, i32 0, i32 4
  store i16 0, ptr %25, align 2, !tbaa !19
  %26 = getelementptr inbounds %struct.TgaHeader, ptr %8, i32 0, i32 5
  store i8 0, ptr %26, align 2, !tbaa !20
  %27 = getelementptr inbounds %struct.TgaHeader, ptr %8, i32 0, i32 6
  store i16 0, ptr %27, align 2, !tbaa !21
  %28 = getelementptr inbounds %struct.TgaHeader, ptr %8, i32 0, i32 7
  store i16 0, ptr %28, align 2, !tbaa !22
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.TgaImage, ptr %29, i32 0, i32 0
  %31 = load i16, ptr %30, align 8, !tbaa !23
  %32 = getelementptr inbounds %struct.TgaHeader, ptr %8, i32 0, i32 8
  store i16 %31, ptr %32, align 2, !tbaa !25
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.TgaImage, ptr %33, i32 0, i32 1
  %35 = load i16, ptr %34, align 2, !tbaa !26
  %36 = getelementptr inbounds %struct.TgaHeader, ptr %8, i32 0, i32 9
  store i16 %35, ptr %36, align 2, !tbaa !27
  %37 = getelementptr inbounds %struct.TgaHeader, ptr %8, i32 0, i32 10
  store i8 32, ptr %37, align 2, !tbaa !28
  %38 = getelementptr inbounds %struct.TgaHeader, ptr %8, i32 0, i32 11
  store i8 0, ptr %38, align 1, !tbaa !29
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %110

41:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #9
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.TgaImage, ptr %42, i32 0, i32 0
  %44 = load i16, ptr %43, align 8, !tbaa !23
  %45 = zext i16 %44 to i32
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.TgaImage, ptr %46, i32 0, i32 1
  %48 = load i16, ptr %47, align 2, !tbaa !26
  %49 = zext i16 %48 to i32
  %50 = mul nsw i32 %45, %49
  %51 = sext i32 %50 to i64
  %52 = add i64 %51, 20
  %53 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %52, i64 4)
  %54 = extractvalue { i64, i1 } %53, 1
  %55 = extractvalue { i64, i1 } %53, 0
  %56 = select i1 %54, i64 -1, i64 %55
  %57 = call noalias noundef nonnull ptr @_Znam(i64 noundef %56) #10
  store ptr %57, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #9
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %58, ptr %10, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.TgaHeader, ptr %8, i32 0, i32 0
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef %59, i32 noundef 1, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %60 = getelementptr inbounds %struct.TgaHeader, ptr %8, i32 0, i32 1
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef %60, i32 noundef 1, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %61 = getelementptr inbounds %struct.TgaHeader, ptr %8, i32 0, i32 2
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef %61, i32 noundef 1, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %62 = getelementptr inbounds %struct.TgaHeader, ptr %8, i32 0, i32 3
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef %62, i32 noundef 2, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %63 = getelementptr inbounds %struct.TgaHeader, ptr %8, i32 0, i32 4
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef %63, i32 noundef 2, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %64 = getelementptr inbounds %struct.TgaHeader, ptr %8, i32 0, i32 5
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef %64, i32 noundef 1, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %65 = getelementptr inbounds %struct.TgaHeader, ptr %8, i32 0, i32 6
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef %65, i32 noundef 2, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %66 = getelementptr inbounds %struct.TgaHeader, ptr %8, i32 0, i32 7
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef %66, i32 noundef 2, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %67 = getelementptr inbounds %struct.TgaHeader, ptr %8, i32 0, i32 8
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef %67, i32 noundef 2, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %68 = getelementptr inbounds %struct.TgaHeader, ptr %8, i32 0, i32 9
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef %68, i32 noundef 2, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %69 = getelementptr inbounds %struct.TgaHeader, ptr %8, i32 0, i32 10
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef %69, i32 noundef 1, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %70 = getelementptr inbounds %struct.TgaHeader, ptr %8, i32 0, i32 11
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef %70, i32 noundef 1, ptr noundef nonnull align 8 dereferenceable(8) %10)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #9
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.TgaImage, ptr %71, i32 0, i32 2
  %73 = load ptr, ptr %72, align 8, !tbaa !30
  store ptr %73, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #9
  store i32 0, ptr %12, align 4, !tbaa !31
  br label %74

74:                                               ; preds = %94, %41
  %75 = load i32, ptr %12, align 4, !tbaa !31
  %76 = load ptr, ptr %6, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.TgaImage, ptr %76, i32 0, i32 0
  %78 = load i16, ptr %77, align 8, !tbaa !23
  %79 = zext i16 %78 to i32
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.TgaImage, ptr %80, i32 0, i32 1
  %82 = load i16, ptr %81, align 2, !tbaa !26
  %83 = zext i16 %82 to i32
  %84 = mul nsw i32 %79, %83
  %85 = icmp slt i32 %75, %84
  br i1 %85, label %87, label %86

86:                                               ; preds = %74
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #9
  br label %97

87:                                               ; preds = %74
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #9
  %88 = load ptr, ptr %11, align 8, !tbaa !5
  %89 = load i32, ptr %12, align 4, !tbaa !31
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds %union.texel, ptr %88, i64 %90
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 4 %91, i64 4, i1 false), !tbaa.struct !33
  %92 = getelementptr inbounds [4 x i8], ptr %13, i64 0, i64 0
  %93 = getelementptr inbounds [4 x i8], ptr %13, i64 0, i64 2
  call void @_ZSt4swapIhENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 1 dereferenceable(1) %92, ptr noundef nonnull align 1 dereferenceable(1) %93) #9
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef %13, i32 noundef 4, ptr noundef nonnull align 8 dereferenceable(8) %10)
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #9
  br label %94

94:                                               ; preds = %87
  %95 = load i32, ptr %12, align 4, !tbaa !31
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr %12, align 4, !tbaa !31
  br label %74, !llvm.loop !35

97:                                               ; preds = %86
  %98 = load ptr, ptr %9, align 8, !tbaa !5
  %99 = load ptr, ptr %10, align 8, !tbaa !5
  %100 = load ptr, ptr %9, align 8, !tbaa !5
  %101 = ptrtoint ptr %99 to i64
  %102 = ptrtoint ptr %100 to i64
  %103 = sub i64 %101, %102
  %104 = load ptr, ptr %5, align 8, !tbaa !5
  %105 = call i64 @fwrite(ptr noundef %98, i64 noundef %103, i64 noundef 1, ptr noundef %104)
  %106 = load ptr, ptr %9, align 8, !tbaa !5
  %107 = icmp eq ptr %106, null
  br i1 %107, label %109, label %108

108:                                              ; preds = %97
  call void @_ZdaPv(ptr noundef %106) #11
  br label %109

109:                                              ; preds = %108, %97
  store i1 true, ptr %4, align 1
  store i32 1, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #9
  br label %111

110:                                              ; preds = %3
  store i1 false, ptr %4, align 1
  store i32 1, ptr %14, align 4
  br label %111

111:                                              ; preds = %110, %109
  call void @llvm.lifetime.end.p0(i64 20, ptr %8) #9
  %112 = load i1, ptr %4, align 1
  ret i1 %112
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef, i32 noundef, ptr noundef nonnull align 8 dereferenceable(8)) #4

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIhENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef nonnull align 1 dereferenceable(1)) #6

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

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

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #4 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = { 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 #9 = { nounwind }
attributes #10 = { builtin allocsize(0) }
attributes #11 = { builtin nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!12, !7, i64 0}
!12 = !{!"_ZTS9TgaHeader", !7, i64 0, !7, i64 1, !7, i64 2, !13, i64 4, !13, i64 6, !7, i64 8, !13, i64 10, !13, i64 12, !13, i64 14, !13, i64 16, !7, i64 18, !7, i64 19}
!13 = !{!"short", !7, i64 0}
!14 = !{!12, !7, i64 1}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!12, !7, i64 2}
!18 = !{!12, !13, i64 4}
!19 = !{!12, !13, i64 6}
!20 = !{!12, !7, i64 8}
!21 = !{!12, !13, i64 10}
!22 = !{!12, !13, i64 12}
!23 = !{!24, !13, i64 0}
!24 = !{!"_ZTS8TgaImage", !13, i64 0, !13, i64 2, !6, i64 8}
!25 = !{!12, !13, i64 14}
!26 = !{!24, !13, i64 2}
!27 = !{!12, !13, i64 16}
!28 = !{!12, !7, i64 18}
!29 = !{!12, !7, i64 19}
!30 = !{!24, !6, i64 8}
!31 = !{!32, !32, i64 0}
!32 = !{!"int", !7, i64 0}
!33 = !{i64 0, i64 4, !34}
!34 = !{!7, !7, i64 0}
!35 = distinct !{!35, !36}
!36 = !{!"llvm.loop.mustprogress"}


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

%struct.TgaHeader = type { i8, i8, i8, i16, i16, i8, i16, i16, i16, i16, i8, i8 }
%union.texel = type { i32 }

; 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 uwtable
define dso_local noundef zeroext i1 @_Z7TgaSaveP8_IO_FILERK8TgaImageb(ptr noundef %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %1, i1 noundef zeroext %2) local_unnamed_addr #1 {
  %4 = alloca %struct.TgaHeader, align 2
  %5 = alloca ptr, align 8
  %6 = alloca %union.texel, align 4
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %4) #7
  store i8 0, ptr %4, align 2, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %4, i64 1
  store i8 0, ptr %7, align 1, !tbaa !10
  %8 = select i1 %2, i8 9, i8 2
  %9 = getelementptr inbounds i8, ptr %4, i64 2
  store i8 %8, ptr %9, align 2, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %4, i64 4
  store i16 0, ptr %10, align 2, !tbaa !12
  %11 = getelementptr inbounds i8, ptr %4, i64 6
  store i16 0, ptr %11, align 2, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %4, i64 8
  store i8 0, ptr %12, align 2, !tbaa !14
  %13 = getelementptr inbounds i8, ptr %4, i64 10
  store i16 0, ptr %13, align 2, !tbaa !15
  %14 = getelementptr inbounds i8, ptr %4, i64 12
  store i16 0, ptr %14, align 2, !tbaa !16
  %15 = load i16, ptr %1, align 8, !tbaa !17
  %16 = getelementptr inbounds i8, ptr %4, i64 14
  store i16 %15, ptr %16, align 2, !tbaa !20
  %17 = getelementptr inbounds i8, ptr %1, i64 2
  %18 = load i16, ptr %17, align 2, !tbaa !21
  %19 = getelementptr inbounds i8, ptr %4, i64 16
  store i16 %18, ptr %19, align 2, !tbaa !22
  %20 = getelementptr inbounds i8, ptr %4, i64 18
  store i8 32, ptr %20, align 2, !tbaa !23
  %21 = getelementptr inbounds i8, ptr %4, i64 19
  store i8 0, ptr %21, align 1, !tbaa !24
  %.not = icmp ne ptr %0, null
  br i1 %.not, label %22, label %51

22:                                               ; preds = %3
  %23 = zext i16 %15 to i64
  %24 = zext i16 %18 to i64
  %25 = shl nuw nsw i64 %23, 2
  %26 = mul nuw nsw i64 %25, %24
  %27 = add nuw nsw i64 %26, 80
  %28 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %27) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #7
  store ptr %28, ptr %5, align 8, !tbaa !25
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef nonnull %4, i32 noundef 1, ptr noundef nonnull align 8 dereferenceable(8) %5)
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef nonnull %7, i32 noundef 1, ptr noundef nonnull align 8 dereferenceable(8) %5)
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef nonnull %9, i32 noundef 1, ptr noundef nonnull align 8 dereferenceable(8) %5)
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef nonnull %10, i32 noundef 2, ptr noundef nonnull align 8 dereferenceable(8) %5)
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef nonnull %11, i32 noundef 2, ptr noundef nonnull align 8 dereferenceable(8) %5)
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef nonnull %12, i32 noundef 1, ptr noundef nonnull align 8 dereferenceable(8) %5)
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef nonnull %13, i32 noundef 2, ptr noundef nonnull align 8 dereferenceable(8) %5)
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef nonnull %14, i32 noundef 2, ptr noundef nonnull align 8 dereferenceable(8) %5)
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef nonnull %16, i32 noundef 2, ptr noundef nonnull align 8 dereferenceable(8) %5)
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef nonnull %19, i32 noundef 2, ptr noundef nonnull align 8 dereferenceable(8) %5)
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef nonnull %20, i32 noundef 1, ptr noundef nonnull align 8 dereferenceable(8) %5)
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef nonnull %21, i32 noundef 1, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %29 = getelementptr inbounds i8, ptr %1, i64 8
  %30 = load ptr, ptr %29, align 8, !tbaa !26
  %31 = load i16, ptr %1, align 8, !tbaa !17
  %32 = zext i16 %31 to i32
  %33 = load i16, ptr %17, align 2, !tbaa !21
  %34 = zext i16 %33 to i32
  %35 = mul nuw nsw i32 %34, %32
  %.not21 = icmp eq i32 %35, 0
  br i1 %.not21, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %22
  %36 = getelementptr inbounds i8, ptr %6, i64 2
  br label %42

._crit_edge:                                      ; preds = %42, %22
  %37 = load ptr, ptr %5, align 8, !tbaa !25
  %38 = ptrtoint ptr %37 to i64
  %39 = ptrtoint ptr %28 to i64
  %40 = sub i64 %38, %39
  %41 = call i64 @fwrite(ptr noundef nonnull %28, i64 noundef %40, i64 noundef 1, ptr noundef nonnull %0)
  call void @_ZdaPv(ptr noundef nonnull %28) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #7
  br label %51

42:                                               ; preds = %.lr.ph, %42
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %42 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #7
  %43 = getelementptr inbounds %union.texel, ptr %30, i64 %indvars.iv
  %44 = load i32, ptr %43, align 4, !tbaa !27
  store i32 %44, ptr %6, align 4, !tbaa !27
  call void @_ZSt4swapIhENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 1 dereferenceable(1) %6, ptr noundef nonnull align 1 dereferenceable(1) %36) #7
  call void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef nonnull %6, i32 noundef 4, ptr noundef nonnull align 8 dereferenceable(8) %5)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %45 = load i16, ptr %1, align 8, !tbaa !17
  %46 = zext i16 %45 to i64
  %47 = load i16, ptr %17, align 2, !tbaa !21
  %48 = zext i16 %47 to i64
  %49 = mul nuw nsw i64 %48, %46
  %50 = icmp ult i64 %indvars.iv.next, %49
  br i1 %50, label %42, label %._crit_edge, !llvm.loop !28

51:                                               ; preds = %3, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %4) #7
  ret i1 %.not
}

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN12_GLOBAL__N_18memwriteEPvjRPh(ptr noundef, i32 noundef, ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIhENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #4

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

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

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 = { 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 #3 = { 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 #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 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { 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 #7 = { nounwind }
attributes #8 = { builtin allocsize(0) }
attributes #9 = { builtin nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"_ZTS9TgaHeader", !7, i64 0, !7, i64 1, !7, i64 2, !9, i64 4, !9, i64 6, !7, i64 8, !9, i64 10, !9, i64 12, !9, i64 14, !9, i64 16, !7, i64 18, !7, i64 19}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"short", !7, i64 0}
!10 = !{!6, !7, i64 1}
!11 = !{!6, !7, i64 2}
!12 = !{!6, !9, i64 4}
!13 = !{!6, !9, i64 6}
!14 = !{!6, !7, i64 8}
!15 = !{!6, !9, i64 10}
!16 = !{!6, !9, i64 12}
!17 = !{!18, !9, i64 0}
!18 = !{!"_ZTS8TgaImage", !9, i64 0, !9, i64 2, !19, i64 8}
!19 = !{!"any pointer", !7, i64 0}
!20 = !{!6, !9, i64 14}
!21 = !{!18, !9, i64 2}
!22 = !{!6, !9, i64 16}
!23 = !{!6, !7, i64 18}
!24 = !{!6, !7, i64 19}
!25 = !{!19, !19, i64 0}
!26 = !{!18, !19, i64 8}
!27 = !{!7, !7, i64 0}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}


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