; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R2Shapes/R2Image.ll (ZN7R2Image7ReadPNGEPKc)

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

@stderr = external global ptr, align 8
@.str.25 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.75 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.76 = external hidden unnamed_addr constant [6 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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 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: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7R2Image7ReadPNGEPKc(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1) #3 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %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 i8, align 1
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = call noalias ptr @fopen(ptr noundef %14, ptr noundef @.str.25)
  store ptr %15, ptr %6, align 8, !tbaa !5
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %22, label %18

18:                                               ; preds = %2
  %19 = load ptr, ptr @stderr, align 8, !tbaa !5
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef @.str.75, ptr noundef %20) #5
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %153

22:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %23 = call noalias ptr @png_create_read_struct(ptr noundef @.str.76, ptr noundef null, ptr noundef null, ptr noundef null)
  store ptr %23, ptr %8, align 8, !tbaa !5
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = icmp eq ptr %24, null
  br i1 %25, label %26, label %29

26:                                               ; preds = %22
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = call i32 @fclose(ptr noundef %27)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %152

29:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = call noalias ptr @png_create_info_struct(ptr noundef %30)
  store ptr %31, ptr %9, align 8, !tbaa !5
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = icmp eq ptr %32, null
  br i1 %33, label %34, label %37

34:                                               ; preds = %29
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = call i32 @fclose(ptr noundef %35)
  call void @png_destroy_read_struct(ptr noundef %8, ptr noundef null, ptr noundef null)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %151

37:                                               ; preds = %29
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  call void @png_init_io(ptr noundef %38, ptr noundef %39)
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  call void @png_read_info(ptr noundef %40, ptr noundef %41)
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #5
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = call zeroext i8 @png_get_color_type(ptr noundef %42, ptr noundef %43)
  store i8 %44, ptr %10, align 1, !tbaa !9
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = call i32 @png_get_image_width(ptr noundef %45, ptr noundef %46)
  %48 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 0
  store i32 %47, ptr %48, align 8, !tbaa !10
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  %51 = call i32 @png_get_image_height(ptr noundef %49, ptr noundef %50)
  %52 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 1
  store i32 %51, ptr %52, align 4, !tbaa !13
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = call i64 @png_get_rowbytes(ptr noundef %53, ptr noundef %54)
  %56 = trunc i64 %55 to i32
  %57 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 3
  store i32 %56, ptr %57, align 4, !tbaa !14
  %58 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 3
  %59 = load i32, ptr %58, align 4, !tbaa !14
  %60 = srem i32 %59, 4
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %62, label %69

62:                                               ; preds = %37
  %63 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 3
  %64 = load i32, ptr %63, align 4, !tbaa !14
  %65 = sdiv i32 %64, 4
  %66 = add nsw i32 %65, 1
  %67 = mul nsw i32 %66, 4
  %68 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 3
  store i32 %67, ptr %68, align 4, !tbaa !14
  br label %69

69:                                               ; preds = %62, %37
  %70 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 2
  store i32 0, ptr %70, align 8, !tbaa !15
  %71 = load i8, ptr %10, align 1, !tbaa !9
  %72 = zext i8 %71 to i32
  %73 = icmp eq i32 %72, 0
  br i1 %73, label %74, label %76

74:                                               ; preds = %69
  %75 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 2
  store i32 1, ptr %75, align 8, !tbaa !15
  br label %100

76:                                               ; preds = %69
  %77 = load i8, ptr %10, align 1, !tbaa !9
  %78 = zext i8 %77 to i32
  %79 = icmp eq i32 %78, 4
  br i1 %79, label %80, label %82

80:                                               ; preds = %76
  %81 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 2
  store i32 2, ptr %81, align 8, !tbaa !15
  br label %99

82:                                               ; preds = %76
  %83 = load i8, ptr %10, align 1, !tbaa !9
  %84 = zext i8 %83 to i32
  %85 = icmp eq i32 %84, 2
  br i1 %85, label %86, label %88

86:                                               ; preds = %82
  %87 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 2
  store i32 3, ptr %87, align 8, !tbaa !15
  br label %98

88:                                               ; preds = %82
  %89 = load i8, ptr %10, align 1, !tbaa !9
  %90 = zext i8 %89 to i32
  %91 = icmp eq i32 %90, 6
  br i1 %91, label %92, label %94

92:                                               ; preds = %88
  %93 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 2
  store i32 4, ptr %93, align 8, !tbaa !15
  br label %97

94:                                               ; preds = %88
  %95 = load ptr, ptr %6, align 8, !tbaa !5
  %96 = call i32 @fclose(ptr noundef %95)
  call void @png_destroy_read_struct(ptr noundef %8, ptr noundef null, ptr noundef null)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %150

97:                                               ; preds = %92
  br label %98

98:                                               ; preds = %97, %86
  br label %99

99:                                               ; preds = %98, %80
  br label %100

100:                                              ; preds = %99, %74
  %101 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 1
  %102 = load i32, ptr %101, align 4, !tbaa !13
  %103 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 3
  %104 = load i32, ptr %103, align 4, !tbaa !14
  %105 = mul nsw i32 %102, %104
  %106 = sext i32 %105 to i64
  %107 = call noalias noundef nonnull ptr @_Znam(i64 noundef %106) #6
  %108 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 4
  store ptr %107, ptr %108, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %109 = load ptr, ptr %8, align 8, !tbaa !5
  %110 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 1
  %111 = load i32, ptr %110, align 4, !tbaa !13
  %112 = sext i32 %111 to i64
  %113 = mul i64 %112, 8
  %114 = call noalias ptr @png_malloc(ptr noundef %109, i64 noundef %113)
  store ptr %114, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 0, ptr %12, align 4, !tbaa !17
  br label %115

115:                                              ; preds = %138, %100
  %116 = load i32, ptr %12, align 4, !tbaa !17
  %117 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 1
  %118 = load i32, ptr %117, align 4, !tbaa !13
  %119 = icmp slt i32 %116, %118
  br i1 %119, label %121, label %120

120:                                              ; preds = %115
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %141

121:                                              ; preds = %115
  %122 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 4
  %123 = load ptr, ptr %122, align 8, !tbaa !16
  %124 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 1
  %125 = load i32, ptr %124, align 4, !tbaa !13
  %126 = load i32, ptr %12, align 4, !tbaa !17
  %127 = sub nsw i32 %125, %126
  %128 = sub nsw i32 %127, 1
  %129 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 3
  %130 = load i32, ptr %129, align 4, !tbaa !14
  %131 = mul nsw i32 %128, %130
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds i8, ptr %123, i64 %132
  %134 = load ptr, ptr %11, align 8, !tbaa !5
  %135 = load i32, ptr %12, align 4, !tbaa !17
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds ptr, ptr %134, i64 %136
  store ptr %133, ptr %137, align 8, !tbaa !5
  br label %138

138:                                              ; preds = %121
  %139 = load i32, ptr %12, align 4, !tbaa !17
  %140 = add nsw i32 %139, 1
  store i32 %140, ptr %12, align 4, !tbaa !17
  br label %115, !llvm.loop !18

141:                                              ; preds = %120
  %142 = load ptr, ptr %8, align 8, !tbaa !5
  %143 = load ptr, ptr %11, align 8, !tbaa !5
  call void @png_read_image(ptr noundef %142, ptr noundef %143)
  %144 = load ptr, ptr %8, align 8, !tbaa !5
  %145 = load ptr, ptr %9, align 8, !tbaa !5
  call void @png_read_end(ptr noundef %144, ptr noundef %145)
  %146 = load ptr, ptr %8, align 8, !tbaa !5
  %147 = load ptr, ptr %11, align 8, !tbaa !5
  call void @png_free(ptr noundef %146, ptr noundef %147)
  call void @png_destroy_read_struct(ptr noundef %8, ptr noundef %9, ptr noundef null)
  %148 = load ptr, ptr %6, align 8, !tbaa !5
  %149 = call i32 @fclose(ptr noundef %148)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %150

150:                                              ; preds = %141, %94
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #5
  br label %151

151:                                              ; preds = %150, %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %152

152:                                              ; preds = %151, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %153

153:                                              ; preds = %152, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %154 = load i32, ptr %3, align 4
  ret i32 %154
}

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

declare i32 @fclose(ptr noundef) #4

declare noalias ptr @png_create_read_struct(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #4

declare noalias ptr @png_create_info_struct(ptr noundef) #4

declare void @png_destroy_read_struct(ptr noundef, ptr noundef, ptr noundef) #4

declare void @png_init_io(ptr noundef, ptr noundef) #4

declare void @png_read_info(ptr noundef, ptr noundef) #4

declare zeroext i8 @png_get_color_type(ptr noundef, ptr noundef) #4

declare i32 @png_get_image_width(ptr noundef, ptr noundef) #4

declare i32 @png_get_image_height(ptr noundef, ptr noundef) #4

declare i64 @png_get_rowbytes(ptr noundef, ptr noundef) #4

declare noalias ptr @png_malloc(ptr noundef, i64 noundef) #4

declare void @png_read_image(ptr noundef, ptr noundef) #4

declare void @png_read_end(ptr noundef, ptr noundef) #4

declare void @png_free(ptr noundef, ptr noundef) #4

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !12, i64 0}
!11 = !{!"_ZTS7R2Image", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !6, i64 16}
!12 = !{!"int", !7, i64 0}
!13 = !{!11, !12, i64 4}
!14 = !{!11, !12, i64 12}
!15 = !{!11, !12, i64 8}
!16 = !{!11, !6, i64 16}
!17 = !{!12, !12, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str.25 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.75 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.76 = external hidden unnamed_addr constant [6 x i8], align 1
@switch.table._ZN7R2Image7ReadPNGEPKc = private unnamed_addr constant [7 x i32] [i32 1, i32 1, i32 3, i32 1, i32 2, i32 1, i32 4], align 4

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 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: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZN7R2Image7ReadPNGEPKc(ptr nocapture noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1) local_unnamed_addr #3 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = tail call noalias ptr @fopen(ptr noundef %1, ptr noundef nonnull @.str.25)
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %6, label %9

6:                                                ; preds = %2
  %7 = load ptr, ptr @stderr, align 8, !tbaa !5
  %8 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.75, ptr noundef %1) #5
  br label %70

9:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %10 = tail call noalias ptr @png_create_read_struct(ptr noundef nonnull @.str.76, ptr noundef null, ptr noundef null, ptr noundef null)
  store ptr %10, ptr %3, align 8, !tbaa !5
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %14

12:                                               ; preds = %9
  %13 = tail call i32 @fclose(ptr noundef nonnull %5)
  br label %69

14:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %15 = tail call noalias ptr @png_create_info_struct(ptr noundef nonnull %10)
  store ptr %15, ptr %4, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %19

17:                                               ; preds = %14
  %18 = tail call i32 @fclose(ptr noundef nonnull %5)
  call void @png_destroy_read_struct(ptr noundef nonnull %3, ptr noundef null, ptr noundef null)
  br label %68

19:                                               ; preds = %14
  tail call void @png_init_io(ptr noundef nonnull %10, ptr noundef nonnull %5)
  tail call void @png_read_info(ptr noundef nonnull %10, ptr noundef nonnull %15)
  %20 = tail call zeroext i8 @png_get_color_type(ptr noundef nonnull %10, ptr noundef nonnull %15)
  %21 = tail call i32 @png_get_image_width(ptr noundef nonnull %10, ptr noundef nonnull %15)
  store i32 %21, ptr %0, align 8, !tbaa !9
  %22 = tail call i32 @png_get_image_height(ptr noundef nonnull %10, ptr noundef nonnull %15)
  %23 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %22, ptr %23, align 4, !tbaa !12
  %24 = tail call i64 @png_get_rowbytes(ptr noundef nonnull %10, ptr noundef nonnull %15)
  %25 = trunc i64 %24 to i32
  %26 = getelementptr inbounds i8, ptr %0, i64 12
  %27 = and i32 %25, 3
  %.not24 = icmp eq i32 %27, 0
  br i1 %.not24, label %32, label %28

28:                                               ; preds = %19
  %29 = sdiv i32 %25, 4
  %30 = shl nsw i32 %29, 2
  %31 = add i32 %30, 4
  br label %32

32:                                               ; preds = %28, %19
  %storemerge = phi i32 [ %31, %28 ], [ %25, %19 ]
  store i32 %storemerge, ptr %26, align 4, !tbaa !13
  %33 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 0, ptr %33, align 8, !tbaa !14
  %34 = icmp ult i8 %20, 7
  br i1 %34, label %switch.hole_check, label %35

35:                                               ; preds = %switch.hole_check, %32
  %36 = tail call i32 @fclose(ptr noundef nonnull %5)
  call void @png_destroy_read_struct(ptr noundef nonnull %3, ptr noundef null, ptr noundef null)
  br label %68

switch.hole_check:                                ; preds = %32
  %switch.shifted = lshr i8 85, %20
  %switch.lobit = trunc i8 %switch.shifted to i1
  br i1 %switch.lobit, label %switch.lookup, label %35

switch.lookup:                                    ; preds = %switch.hole_check
  %37 = zext nneg i8 %20 to i64
  %switch.gep = getelementptr inbounds [7 x i32], ptr @switch.table._ZN7R2Image7ReadPNGEPKc, i64 0, i64 %37
  %switch.load = load i32, ptr %switch.gep, align 4
  store i32 %switch.load, ptr %33, align 8, !tbaa !14
  %38 = load i32, ptr %23, align 4, !tbaa !12
  %39 = mul nsw i32 %38, %storemerge
  %40 = sext i32 %39 to i64
  %41 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %40) #7
  %42 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %41, ptr %42, align 8, !tbaa !15
  %43 = sext i32 %38 to i64
  %44 = shl nsw i64 %43, 3
  %45 = tail call noalias ptr @png_malloc(ptr noundef nonnull %10, i64 noundef %44)
  %46 = load i32, ptr %23, align 4, !tbaa !12
  %47 = icmp sgt i32 %46, 0
  br i1 %47, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %switch.lookup
  %48 = load ptr, ptr %42, align 8, !tbaa !15
  %49 = load i32, ptr %26, align 4, !tbaa !13
  %50 = zext nneg i32 %46 to i64
  %51 = sext i32 %49 to i64
  %wide.trip.count = zext nneg i32 %46 to i64
  %min.iters.check = icmp ult i32 %46, 4
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph
  %indvars.iv.ph = phi i64 [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  br label %scalar.ph

vector.ph:                                        ; preds = %.lr.ph
  %n.vec = and i64 %wide.trip.count, 2147483644
  %broadcast.splatinsert = insertelement <2 x i64> poison, i64 %50, i64 0
  %broadcast.splat = shufflevector <2 x i64> %broadcast.splatinsert, <2 x i64> poison, <2 x i32> zeroinitializer
  %broadcast.splatinsert28 = insertelement <2 x i64> poison, i64 %51, i64 0
  %broadcast.splat29 = shufflevector <2 x i64> %broadcast.splatinsert28, <2 x i64> poison, <2 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <2 x i64> [ <i64 0, i64 1>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %52 = xor <2 x i64> %vec.ind, <i64 -1, i64 -1>
  %53 = add nsw <2 x i64> %broadcast.splat, %52
  %reass.sub = sub <2 x i64> %broadcast.splat, %vec.ind
  %54 = add <2 x i64> %reass.sub, <i64 -3, i64 -3>
  %55 = mul nsw <2 x i64> %53, %broadcast.splat29
  %56 = mul nsw <2 x i64> %54, %broadcast.splat29
  %57 = getelementptr inbounds i8, ptr %48, <2 x i64> %55
  %58 = getelementptr inbounds i8, ptr %48, <2 x i64> %56
  %59 = getelementptr inbounds ptr, ptr %45, i64 %index
  %60 = getelementptr inbounds i8, ptr %59, i64 16
  store <2 x ptr> %57, ptr %59, align 8, !tbaa !5
  store <2 x ptr> %58, ptr %60, align 8, !tbaa !5
  %index.next = add nuw i64 %index, 4
  %vec.ind.next = add <2 x i64> %vec.ind, <i64 4, i64 4>
  %61 = icmp eq i64 %index.next, %n.vec
  br i1 %61, label %middle.block, label %vector.body, !llvm.loop !16

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

._crit_edge:                                      ; preds = %scalar.ph, %middle.block, %switch.lookup
  tail call void @png_read_image(ptr noundef nonnull %10, ptr noundef %45)
  tail call void @png_read_end(ptr noundef nonnull %10, ptr noundef nonnull %15)
  tail call void @png_free(ptr noundef nonnull %10, ptr noundef %45)
  call void @png_destroy_read_struct(ptr noundef nonnull %3, ptr noundef nonnull %4, ptr noundef null)
  %62 = call i32 @fclose(ptr noundef nonnull %5)
  br label %68

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %63 = xor i64 %indvars.iv, -1
  %64 = add nsw i64 %50, %63
  %65 = mul nsw i64 %64, %51
  %66 = getelementptr inbounds i8, ptr %48, i64 %65
  %67 = getelementptr inbounds ptr, ptr %45, i64 %indvars.iv
  store ptr %66, ptr %67, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %scalar.ph, !llvm.loop !20

68:                                               ; preds = %35, %._crit_edge, %17
  %.1 = phi i32 [ 0, %17 ], [ 1, %._crit_edge ], [ 0, %35 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  br label %69

69:                                               ; preds = %68, %12
  %.2 = phi i32 [ 0, %12 ], [ %.1, %68 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  br label %70

70:                                               ; preds = %69, %6
  %.3 = phi i32 [ %.2, %69 ], [ 0, %6 ]
  ret i32 %.3
}

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

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

declare noalias ptr @png_create_read_struct(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

declare noalias ptr @png_create_info_struct(ptr noundef) local_unnamed_addr #4

declare void @png_destroy_read_struct(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

declare void @png_init_io(ptr noundef, ptr noundef) local_unnamed_addr #4

declare void @png_read_info(ptr noundef, ptr noundef) local_unnamed_addr #4

declare zeroext i8 @png_get_color_type(ptr noundef, ptr noundef) local_unnamed_addr #4

declare i32 @png_get_image_width(ptr noundef, ptr noundef) local_unnamed_addr #4

declare i32 @png_get_image_height(ptr noundef, ptr noundef) local_unnamed_addr #4

declare i64 @png_get_rowbytes(ptr noundef, ptr noundef) local_unnamed_addr #4

declare noalias ptr @png_malloc(ptr noundef, i64 noundef) local_unnamed_addr #4

declare void @png_read_image(ptr noundef, ptr noundef) local_unnamed_addr #4

declare void @png_read_end(ptr noundef, ptr noundef) local_unnamed_addr #4

declare void @png_free(ptr noundef, ptr noundef) local_unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nobuiltin allocsize(0) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 #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 = { "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 = { cold nounwind }
attributes #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTS7R2Image", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !6, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!10, !11, i64 12}
!14 = !{!10, !11, i64 8}
!15 = !{!10, !6, i64 16}
!16 = distinct !{!16, !17, !18, !19}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!"llvm.loop.isvectorized", i32 1}
!19 = !{!"llvm.loop.unroll.runtime.disable"}
!20 = distinct !{!20, !17, !19, !18}


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