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

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

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

@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [51 x i8], align 1

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

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

declare i32 @fclose(ptr noundef) #1

; 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: 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) #4

; 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)) #5

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z7TgaLoadPKcR8TgaImage(ptr noundef %0, ptr noundef nonnull align 8 dereferenceable(16) %1) #7 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i8, align 1
  %9 = alloca i64, align 8
  %10 = alloca i8, align 1
  %11 = alloca i8, align 1
  %12 = alloca i16, align 2
  %13 = alloca i16, align 2
  %14 = alloca i8, align 1
  %15 = alloca i16, align 2
  %16 = alloca i16, align 2
  %17 = alloca i16, align 2
  %18 = alloca i16, align 2
  %19 = alloca i8, align 1
  %20 = alloca i8, align 1
  %21 = alloca i8, align 1
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca %union.texel.0, align 4
  %25 = alloca i32, align 4
  %26 = alloca ptr, align 8
  %27 = alloca ptr, align 8
  %28 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = icmp ne ptr %29, null
  br i1 %30, label %32, label %31

31:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  br label %184

32:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #8
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = call noalias ptr @fopen(ptr noundef %33, ptr noundef @.str.1)
  store ptr %34, ptr %6, align 8, !tbaa !5
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = icmp eq ptr %35, null
  br i1 %36, label %37, label %40

37:                                               ; preds = %32
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, ptr noundef %38)
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %183

40:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #8
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = call i64 @fread(ptr noundef %8, i64 noundef 1, i64 noundef 1, ptr noundef %41)
  store i64 %42, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #8
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = call i64 @fread(ptr noundef %10, i64 noundef 1, i64 noundef 1, ptr noundef %43)
  store i64 %44, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #8
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = call i64 @fread(ptr noundef %11, i64 noundef 1, i64 noundef 1, ptr noundef %45)
  store i64 %46, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 2, ptr %12) #8
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = call i64 @fread(ptr noundef %12, i64 noundef 2, i64 noundef 1, ptr noundef %47)
  store i64 %48, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 2, ptr %13) #8
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = call i64 @fread(ptr noundef %13, i64 noundef 2, i64 noundef 1, ptr noundef %49)
  store i64 %50, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #8
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = call i64 @fread(ptr noundef %14, i64 noundef 1, i64 noundef 1, ptr noundef %51)
  store i64 %52, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 2, ptr %15) #8
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = call i64 @fread(ptr noundef %15, i64 noundef 2, i64 noundef 1, ptr noundef %53)
  store i64 %54, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 2, ptr %16) #8
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = call i64 @fread(ptr noundef %16, i64 noundef 2, i64 noundef 1, ptr noundef %55)
  store i64 %56, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 2, ptr %17) #8
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = call i64 @fread(ptr noundef %17, i64 noundef 2, i64 noundef 1, ptr noundef %57)
  store i64 %58, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 2, ptr %18) #8
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = call i64 @fread(ptr noundef %18, i64 noundef 2, i64 noundef 1, ptr noundef %59)
  store i64 %60, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %19) #8
  store i8 32, ptr %19, align 1, !tbaa !11
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = call i64 @fread(ptr noundef %19, i64 noundef 1, i64 noundef 1, ptr noundef %61)
  store i64 %62, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %20) #8
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = call i64 @fread(ptr noundef %20, i64 noundef 1, i64 noundef 1, ptr noundef %63)
  store i64 %64, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %21) #8
  %65 = load i8, ptr %19, align 1, !tbaa !11
  %66 = sext i8 %65 to i32
  %67 = sdiv i32 %66, 8
  %68 = trunc i32 %67 to i8
  store i8 %68, ptr %21, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #8
  %69 = load i16, ptr %17, align 2, !tbaa !12
  %70 = sext i16 %69 to i32
  %71 = load i16, ptr %18, align 2, !tbaa !12
  %72 = sext i16 %71 to i32
  %73 = mul nsw i32 %70, %72
  store i32 %73, ptr %22, align 4, !tbaa !14
  %74 = load i16, ptr %17, align 2, !tbaa !12
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.TgaImage, ptr %75, i32 0, i32 0
  store i16 %74, ptr %76, align 8, !tbaa !16
  %77 = load i16, ptr %18, align 2, !tbaa !12
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.TgaImage, ptr %78, i32 0, i32 1
  store i16 %77, ptr %79, align 2, !tbaa !18
  %80 = load i32, ptr %22, align 4, !tbaa !14
  %81 = zext i32 %80 to i64
  %82 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %81, i64 4)
  %83 = extractvalue { i64, i1 } %82, 1
  %84 = extractvalue { i64, i1 } %82, 0
  %85 = select i1 %83, i64 -1, i64 %84
  %86 = call noalias noundef nonnull ptr @_Znam(i64 noundef %85) #9
  %87 = load ptr, ptr %5, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.TgaImage, ptr %87, i32 0, i32 2
  store ptr %86, ptr %88, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #8
  store i32 0, ptr %23, align 4, !tbaa !14
  br label %89

89:                                               ; preds = %113, %40
  %90 = load i32, ptr %23, align 4, !tbaa !14
  %91 = load i32, ptr %22, align 4, !tbaa !14
  %92 = icmp ult i32 %90, %91
  br i1 %92, label %94, label %93

93:                                               ; preds = %89
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #8
  br label %116

94:                                               ; preds = %89
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #8
  store i32 0, ptr %24, align 4, !tbaa !11
  %95 = load i8, ptr %21, align 1, !tbaa !11
  %96 = zext i8 %95 to i64
  %97 = load ptr, ptr %6, align 8, !tbaa !5
  %98 = call i64 @fread(ptr noundef %24, i64 noundef %96, i64 noundef 1, ptr noundef %97)
  %99 = icmp ne i64 %98, 0
  br i1 %99, label %103, label %100

100:                                              ; preds = %94
  %101 = load ptr, ptr %4, align 8, !tbaa !5
  %102 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, ptr noundef %101)
  br label %103

103:                                              ; preds = %100, %94
  %104 = getelementptr inbounds [4 x i8], ptr %24, i64 0, i64 0
  %105 = getelementptr inbounds [4 x i8], ptr %24, 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) %104, ptr noundef nonnull align 1 dereferenceable(1) %105) #8
  %106 = load i32, ptr %24, align 4, !tbaa !11
  %107 = load ptr, ptr %5, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.TgaImage, ptr %107, i32 0, i32 2
  %109 = load ptr, ptr %108, align 8, !tbaa !19
  %110 = load i32, ptr %23, align 4, !tbaa !14
  %111 = zext i32 %110 to i64
  %112 = getelementptr inbounds i32, ptr %109, i64 %111
  store i32 %106, ptr %112, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #8
  br label %113

113:                                              ; preds = %103
  %114 = load i32, ptr %23, align 4, !tbaa !14
  %115 = add i32 %114, 1
  store i32 %115, ptr %23, align 4, !tbaa !14
  br label %89, !llvm.loop !20

116:                                              ; preds = %93
  %117 = load i8, ptr %20, align 1, !tbaa !11
  %118 = sext i8 %117 to i32
  %119 = and i32 %118, 32
  %120 = icmp ne i32 %119, 0
  br i1 %120, label %121, label %180

121:                                              ; preds = %116
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #8
  %122 = load ptr, ptr %5, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.TgaImage, ptr %122, i32 0, i32 0
  %124 = load i16, ptr %123, align 8, !tbaa !16
  %125 = zext i16 %124 to i32
  %126 = mul nsw i32 %125, 4
  store i32 %126, ptr %25, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #8
  %127 = load ptr, ptr %5, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.TgaImage, ptr %127, i32 0, i32 0
  %129 = load i16, ptr %128, align 8, !tbaa !16
  %130 = zext i16 %129 to i32
  %131 = mul nsw i32 %130, 4
  %132 = sext i32 %131 to i64
  %133 = call noalias noundef nonnull ptr @_Znam(i64 noundef %132) #9
  store ptr %133, ptr %26, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %27) #8
  %134 = load ptr, ptr %5, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct.TgaImage, ptr %134, i32 0, i32 2
  %136 = load ptr, ptr %135, align 8, !tbaa !19
  store ptr %136, ptr %27, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #8
  %137 = load ptr, ptr %5, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.TgaImage, ptr %137, i32 0, i32 2
  %139 = load ptr, ptr %138, align 8, !tbaa !19
  %140 = load i32, ptr %25, align 4, !tbaa !14
  %141 = load ptr, ptr %5, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.TgaImage, ptr %141, i32 0, i32 1
  %143 = load i16, ptr %142, align 2, !tbaa !18
  %144 = zext i16 %143 to i32
  %145 = sub nsw i32 %144, 1
  %146 = mul nsw i32 %140, %145
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds i8, ptr %139, i64 %147
  store ptr %148, ptr %28, align 8, !tbaa !5
  br label %149

149:                                              ; preds = %153, %121
  %150 = load ptr, ptr %27, align 8, !tbaa !5
  %151 = load ptr, ptr %28, align 8, !tbaa !5
  %152 = icmp ult ptr %150, %151
  br i1 %152, label %153, label %175

153:                                              ; preds = %149
  %154 = load ptr, ptr %26, align 8, !tbaa !5
  %155 = load ptr, ptr %28, align 8, !tbaa !5
  %156 = load i32, ptr %25, align 4, !tbaa !14
  %157 = sext i32 %156 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %154, ptr align 1 %155, i64 %157, i1 false)
  %158 = load ptr, ptr %28, align 8, !tbaa !5
  %159 = load ptr, ptr %27, align 8, !tbaa !5
  %160 = load i32, ptr %25, align 4, !tbaa !14
  %161 = sext i32 %160 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %158, ptr align 1 %159, i64 %161, i1 false)
  %162 = load ptr, ptr %27, align 8, !tbaa !5
  %163 = load ptr, ptr %26, align 8, !tbaa !5
  %164 = load i32, ptr %25, align 4, !tbaa !14
  %165 = sext i32 %164 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %162, ptr align 1 %163, i64 %165, i1 false)
  %166 = load i32, ptr %25, align 4, !tbaa !14
  %167 = load ptr, ptr %27, align 8, !tbaa !5
  %168 = sext i32 %166 to i64
  %169 = getelementptr inbounds i8, ptr %167, i64 %168
  store ptr %169, ptr %27, align 8, !tbaa !5
  %170 = load i32, ptr %25, align 4, !tbaa !14
  %171 = load ptr, ptr %28, align 8, !tbaa !5
  %172 = sext i32 %170 to i64
  %173 = sub i64 0, %172
  %174 = getelementptr inbounds i8, ptr %171, i64 %173
  store ptr %174, ptr %28, align 8, !tbaa !5
  br label %149, !llvm.loop !22

175:                                              ; preds = %149
  %176 = load ptr, ptr %26, align 8, !tbaa !5
  %177 = icmp eq ptr %176, null
  br i1 %177, label %179, label %178

178:                                              ; preds = %175
  call void @_ZdaPv(ptr noundef %176) #10
  br label %179

179:                                              ; preds = %178, %175
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #8
  br label %180

180:                                              ; preds = %179, %116
  %181 = load ptr, ptr %6, align 8, !tbaa !5
  %182 = call i32 @fclose(ptr noundef %181)
  store i1 true, ptr %3, align 1
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #8
  call void @llvm.lifetime.end.p0(i64 1, ptr %21) #8
  call void @llvm.lifetime.end.p0(i64 1, ptr %20) #8
  call void @llvm.lifetime.end.p0(i64 1, ptr %19) #8
  call void @llvm.lifetime.end.p0(i64 2, ptr %18) #8
  call void @llvm.lifetime.end.p0(i64 2, ptr %17) #8
  call void @llvm.lifetime.end.p0(i64 2, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 2, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #8
  call void @llvm.lifetime.end.p0(i64 2, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 2, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #8
  br label %183

183:                                              ; preds = %180, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #8
  br label %184

184:                                              ; preds = %183, %31
  %185 = load i1, ptr %3, align 1
  ret i1 %185
}

declare i32 @printf(ptr noundef, ...) #1

declare i64 @fread(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #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 = { 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 allocsize(0) }
attributes #10 = { 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 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!17, !13, i64 0}
!17 = !{!"_ZTS8TgaImage", !13, i64 0, !13, i64 2, !6, i64 8}
!18 = !{!17, !13, i64 2}
!19 = !{!17, !6, i64 8}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}


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

%union.texel.0 = type { i32 }

@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [51 x i8], align 1

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

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z7TgaLoadPKcR8TgaImage(ptr noundef %0, ptr nocapture noundef nonnull align 8 dereferenceable(16) %1) local_unnamed_addr #6 {
  %3 = alloca i8, align 1
  %4 = alloca i8, align 1
  %5 = alloca i8, align 1
  %6 = alloca i16, align 2
  %7 = alloca i16, align 2
  %8 = alloca i8, align 1
  %9 = alloca i16, align 2
  %10 = alloca i16, align 2
  %11 = alloca i16, align 2
  %12 = alloca i16, align 2
  %13 = alloca i8, align 1
  %14 = alloca i8, align 1
  %15 = alloca %union.texel.0, align 4
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %78, label %16

16:                                               ; preds = %2
  %17 = tail call noalias ptr @fopen(ptr noundef nonnull %0, ptr noundef nonnull @.str.1)
  %.not58 = icmp eq ptr %17, null
  br i1 %.not58, label %18, label %20

18:                                               ; preds = %16
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef nonnull %0)
  br label %78

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

.lr.ph:                                           ; preds = %20
  %44 = sdiv i8 %33, 8
  %45 = zext i8 %44 to i64
  %46 = getelementptr inbounds i8, ptr %15, i64 2
  br label %50

._crit_edge:                                      ; preds = %54, %20
  %47 = phi ptr [ %42, %20 ], [ %56, %54 ]
  %48 = load i8, ptr %14, align 1, !tbaa !5
  %49 = and i8 %48, 32
  %.not56 = icmp eq i8 %49, 0
  br i1 %.not56, label %76, label %58

50:                                               ; preds = %.lr.ph, %54
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %54 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %15) #7
  store i32 0, ptr %15, align 4, !tbaa !5
  %51 = call i64 @fread(ptr noundef nonnull %15, i64 noundef %45, i64 noundef 1, ptr noundef nonnull %17)
  %.not57 = icmp eq i64 %51, 0
  br i1 %.not57, label %52, label %54

52:                                               ; preds = %50
  %53 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, ptr noundef nonnull %0)
  br label %54

54:                                               ; preds = %52, %50
  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) %15, ptr noundef nonnull align 1 dereferenceable(1) %46) #7
  %55 = load i32, ptr %15, align 4, !tbaa !5
  %56 = load ptr, ptr %43, align 8, !tbaa !14
  %57 = getelementptr inbounds i32, ptr %56, i64 %indvars.iv
  store i32 %55, ptr %57, align 4, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %15) #7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %40
  br i1 %exitcond.not, label %._crit_edge, label %50, !llvm.loop !17

58:                                               ; preds = %._crit_edge
  %59 = load i16, ptr %1, align 8, !tbaa !10
  %60 = zext i16 %59 to i32
  %61 = shl nuw nsw i32 %60, 2
  %62 = zext nneg i32 %61 to i64
  %63 = call noalias noundef nonnull ptr @_Znam(i64 noundef %62) #8
  %64 = load i16, ptr %39, align 2, !tbaa !13
  %65 = zext i16 %64 to i32
  %66 = add nsw i32 %65, -1
  %67 = mul nsw i32 %66, %61
  %68 = icmp sgt i32 %67, 0
  br i1 %68, label %.lr.ph63, label %._crit_edge64

.lr.ph63:                                         ; preds = %58
  %69 = zext nneg i32 %67 to i64
  %70 = getelementptr inbounds i8, ptr %47, i64 %69
  %71 = sub nsw i64 0, %62
  br label %72

72:                                               ; preds = %.lr.ph63, %72
  %.061 = phi ptr [ %70, %.lr.ph63 ], [ %74, %72 ]
  %.05160 = phi ptr [ %47, %.lr.ph63 ], [ %73, %72 ]
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %63, ptr nonnull align 1 %.061, i64 %62, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %.061, ptr align 1 %.05160, i64 %62, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %.05160, ptr nonnull align 1 %63, i64 %62, i1 false)
  %73 = getelementptr inbounds i8, ptr %.05160, i64 %62
  %74 = getelementptr inbounds i8, ptr %.061, i64 %71
  %75 = icmp ult ptr %73, %74
  br i1 %75, label %72, label %._crit_edge64, !llvm.loop !19

._crit_edge64:                                    ; preds = %72, %58
  call void @_ZdaPv(ptr noundef nonnull %63) #9
  br label %76

76:                                               ; preds = %._crit_edge64, %._crit_edge
  %77 = call i32 @fclose(ptr noundef nonnull %17)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %14) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %13) #7
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %12) #7
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %11) #7
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %10) #7
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %9) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %8) #7
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %7) #7
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #7
  br label %78

78:                                               ; preds = %18, %76, %2
  %.1 = phi i1 [ false, %2 ], [ true, %76 ], [ false, %18 ]
  ret i1 %.1
}

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { nobuiltin nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #7 = { nounwind }
attributes #8 = { builtin 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, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"short", !6, i64 0}
!10 = !{!11, !9, i64 0}
!11 = !{!"_ZTS8TgaImage", !9, i64 0, !9, i64 2, !12, i64 8}
!12 = !{!"any pointer", !6, i64 0}
!13 = !{!11, !9, i64 2}
!14 = !{!11, !12, i64 8}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !6, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


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