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

; 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.39 = 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
@.str.77 = external hidden unnamed_addr constant [37 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: 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, ...) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK7R2Image8WritePNGEPKc(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1) #2 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) #4
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = call noalias ptr @fopen(ptr noundef %14, ptr noundef @.str.39)
  store ptr %15, ptr %6, align 8, !tbaa !5
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = icmp eq ptr %16, null
  br i1 %17, label %18, label %22

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) #4
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %121

22:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %23 = call noalias ptr @png_create_write_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 %120

29:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %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_write_struct(ptr noundef %8, ptr noundef null)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %119

37:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #4
  store i8 0, ptr %10, align 1, !tbaa !9
  %38 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 2
  %39 = load i32, ptr %38, align 8, !tbaa !10
  %40 = icmp eq i32 %39, 1
  br i1 %40, label %41, label %42

41:                                               ; preds = %37
  store i8 0, ptr %10, align 1, !tbaa !9
  br label %64

42:                                               ; preds = %37
  %43 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 2
  %44 = load i32, ptr %43, align 8, !tbaa !10
  %45 = icmp eq i32 %44, 2
  br i1 %45, label %46, label %47

46:                                               ; preds = %42
  store i8 4, ptr %10, align 1, !tbaa !9
  br label %63

47:                                               ; preds = %42
  %48 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 2
  %49 = load i32, ptr %48, align 8, !tbaa !10
  %50 = icmp eq i32 %49, 3
  br i1 %50, label %51, label %52

51:                                               ; preds = %47
  store i8 2, ptr %10, align 1, !tbaa !9
  br label %62

52:                                               ; preds = %47
  %53 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 2
  %54 = load i32, ptr %53, align 8, !tbaa !10
  %55 = icmp eq i32 %54, 4
  br i1 %55, label %56, label %57

56:                                               ; preds = %52
  store i8 6, ptr %10, align 1, !tbaa !9
  br label %61

57:                                               ; preds = %52
  %58 = load ptr, ptr @stderr, align 8, !tbaa !5
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %58, ptr noundef @.str.77, ptr noundef %59) #4
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %118

61:                                               ; preds = %56
  br label %62

62:                                               ; preds = %61, %51
  br label %63

63:                                               ; preds = %62, %46
  br label %64

64:                                               ; preds = %63, %41
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  %67 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 0
  %68 = load i32, ptr %67, align 8, !tbaa !13
  %69 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 1
  %70 = load i32, ptr %69, align 4, !tbaa !14
  %71 = load i8, ptr %10, align 1, !tbaa !9
  %72 = zext i8 %71 to i32
  call void @png_set_IHDR(ptr noundef %65, ptr noundef %66, i32 noundef %68, i32 noundef %70, i32 noundef 8, i32 noundef %72, i32 noundef 0, i32 noundef 0, i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 1
  %75 = load i32, ptr %74, align 4, !tbaa !14
  %76 = sext i32 %75 to i64
  %77 = mul i64 %76, 8
  %78 = call noalias ptr @png_malloc(ptr noundef %73, i64 noundef %77)
  store ptr %78, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 0, ptr %12, align 4, !tbaa !15
  br label %79

79:                                               ; preds = %102, %64
  %80 = load i32, ptr %12, align 4, !tbaa !15
  %81 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 1
  %82 = load i32, ptr %81, align 4, !tbaa !14
  %83 = icmp slt i32 %80, %82
  br i1 %83, label %85, label %84

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

85:                                               ; preds = %79
  %86 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 4
  %87 = load ptr, ptr %86, align 8, !tbaa !16
  %88 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 1
  %89 = load i32, ptr %88, align 4, !tbaa !14
  %90 = load i32, ptr %12, align 4, !tbaa !15
  %91 = sub nsw i32 %89, %90
  %92 = sub nsw i32 %91, 1
  %93 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 3
  %94 = load i32, ptr %93, align 4, !tbaa !17
  %95 = mul nsw i32 %92, %94
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds i8, ptr %87, i64 %96
  %98 = load ptr, ptr %11, align 8, !tbaa !5
  %99 = load i32, ptr %12, align 4, !tbaa !15
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds ptr, ptr %98, i64 %100
  store ptr %97, ptr %101, align 8, !tbaa !5
  br label %102

102:                                              ; preds = %85
  %103 = load i32, ptr %12, align 4, !tbaa !15
  %104 = add nsw i32 %103, 1
  store i32 %104, ptr %12, align 4, !tbaa !15
  br label %79, !llvm.loop !18

105:                                              ; preds = %84
  %106 = load ptr, ptr %8, align 8, !tbaa !5
  %107 = load ptr, ptr %6, align 8, !tbaa !5
  call void @png_init_io(ptr noundef %106, ptr noundef %107)
  %108 = load ptr, ptr %8, align 8, !tbaa !5
  %109 = load ptr, ptr %9, align 8, !tbaa !5
  call void @png_write_info(ptr noundef %108, ptr noundef %109)
  %110 = load ptr, ptr %8, align 8, !tbaa !5
  %111 = load ptr, ptr %11, align 8, !tbaa !5
  call void @png_write_image(ptr noundef %110, ptr noundef %111)
  %112 = load ptr, ptr %8, align 8, !tbaa !5
  %113 = load ptr, ptr %9, align 8, !tbaa !5
  call void @png_write_end(ptr noundef %112, ptr noundef %113)
  %114 = load ptr, ptr %8, align 8, !tbaa !5
  %115 = load ptr, ptr %11, align 8, !tbaa !5
  call void @png_free(ptr noundef %114, ptr noundef %115)
  call void @png_destroy_write_struct(ptr noundef %8, ptr noundef %9)
  %116 = load ptr, ptr %6, align 8, !tbaa !5
  %117 = call i32 @fclose(ptr noundef %116)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %118

118:                                              ; preds = %105, %57
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #4
  br label %119

119:                                              ; preds = %118, %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %120

120:                                              ; preds = %119, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %121

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

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

declare i32 @fclose(ptr noundef) #3

declare noalias ptr @png_create_info_struct(ptr noundef) #3

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

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

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

declare noalias ptr @png_create_write_struct(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

declare void @png_destroy_write_struct(ptr noundef, ptr noundef) #3

declare void @png_set_IHDR(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #3

declare void @png_write_info(ptr noundef, ptr noundef) #3

declare void @png_write_image(ptr noundef, ptr noundef) #3

declare void @png_write_end(ptr noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 #3 = { "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 }

!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 8}
!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 0}
!14 = !{!11, !12, i64 4}
!15 = !{!12, !12, i64 0}
!16 = !{!11, !6, i64 16}
!17 = !{!11, !12, i64 12}
!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.39 = 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
@.str.77 = external hidden unnamed_addr constant [37 x i8], align 1
@switch.table._ZNK7R2Image8WritePNGEPKc = private unnamed_addr constant [4 x i32] [i32 0, i32 4, i32 2, i32 6], 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: 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 #1

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZNK7R2Image8WritePNGEPKc(ptr nocapture noundef nonnull readonly align 8 dereferenceable(24) %0, ptr noundef %1) local_unnamed_addr #2 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.39)
  %6 = icmp eq ptr %5, null
  br i1 %6, label %7, label %10

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

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

13:                                               ; preds = %10
  %14 = tail call i32 @fclose(ptr noundef nonnull %5)
  br label %60

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

18:                                               ; preds = %15
  %19 = tail call i32 @fclose(ptr noundef nonnull %5)
  call void @png_destroy_write_struct(ptr noundef nonnull %3, ptr noundef null)
  br label %59

20:                                               ; preds = %15
  %21 = getelementptr inbounds i8, ptr %0, i64 8
  %22 = load i32, ptr %21, align 8, !tbaa !9
  %switch.tableidx = add i32 %22, -1
  %23 = icmp ult i32 %switch.tableidx, 4
  br i1 %23, label %switch.lookup, label %24

24:                                               ; preds = %20
  %25 = load ptr, ptr @stderr, align 8, !tbaa !5
  %26 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef nonnull @.str.77, ptr noundef %1) #4
  br label %59

switch.lookup:                                    ; preds = %20
  %27 = zext nneg i32 %switch.tableidx to i64
  %switch.gep = getelementptr inbounds [4 x i32], ptr @switch.table._ZNK7R2Image8WritePNGEPKc, i64 0, i64 %27
  %switch.load = load i32, ptr %switch.gep, align 4
  %28 = load i32, ptr %0, align 8, !tbaa !12
  %29 = getelementptr inbounds i8, ptr %0, i64 4
  %30 = load i32, ptr %29, align 4, !tbaa !13
  tail call void @png_set_IHDR(ptr noundef nonnull %11, ptr noundef nonnull %16, i32 noundef %28, i32 noundef %30, i32 noundef 8, i32 noundef %switch.load, i32 noundef 0, i32 noundef 0, i32 noundef 0)
  %31 = load i32, ptr %29, align 4, !tbaa !13
  %32 = sext i32 %31 to i64
  %33 = shl nsw i64 %32, 3
  %34 = tail call noalias ptr @png_malloc(ptr noundef nonnull %11, i64 noundef %33)
  %35 = load i32, ptr %29, align 4, !tbaa !13
  %36 = icmp sgt i32 %35, 0
  br i1 %36, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %switch.lookup
  %37 = getelementptr inbounds i8, ptr %0, i64 16
  %38 = load ptr, ptr %37, align 8, !tbaa !14
  %39 = getelementptr inbounds i8, ptr %0, i64 12
  %40 = load i32, ptr %39, align 4, !tbaa !15
  %41 = zext nneg i32 %35 to i64
  %42 = sext i32 %40 to i64
  %wide.trip.count = zext nneg i32 %35 to i64
  %min.iters.check = icmp ult i32 %35, 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 %41, i64 0
  %broadcast.splat = shufflevector <2 x i64> %broadcast.splatinsert, <2 x i64> poison, <2 x i32> zeroinitializer
  %broadcast.splatinsert25 = insertelement <2 x i64> poison, i64 %42, i64 0
  %broadcast.splat26 = shufflevector <2 x i64> %broadcast.splatinsert25, <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 ]
  %43 = xor <2 x i64> %vec.ind, <i64 -1, i64 -1>
  %44 = add nsw <2 x i64> %broadcast.splat, %43
  %reass.sub = sub <2 x i64> %broadcast.splat, %vec.ind
  %45 = add <2 x i64> %reass.sub, <i64 -3, i64 -3>
  %46 = mul nsw <2 x i64> %44, %broadcast.splat26
  %47 = mul nsw <2 x i64> %45, %broadcast.splat26
  %48 = getelementptr inbounds i8, ptr %38, <2 x i64> %46
  %49 = getelementptr inbounds i8, ptr %38, <2 x i64> %47
  %50 = getelementptr inbounds ptr, ptr %34, i64 %index
  %51 = getelementptr inbounds i8, ptr %50, i64 16
  store <2 x ptr> %48, ptr %50, align 8, !tbaa !5
  store <2 x ptr> %49, ptr %51, align 8, !tbaa !5
  %index.next = add nuw i64 %index, 4
  %vec.ind.next = add <2 x i64> %vec.ind, <i64 4, i64 4>
  %52 = icmp eq i64 %index.next, %n.vec
  br i1 %52, 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_init_io(ptr noundef nonnull %11, ptr noundef nonnull %5)
  tail call void @png_write_info(ptr noundef nonnull %11, ptr noundef nonnull %16)
  tail call void @png_write_image(ptr noundef nonnull %11, ptr noundef %34)
  tail call void @png_write_end(ptr noundef nonnull %11, ptr noundef nonnull %16)
  tail call void @png_free(ptr noundef nonnull %11, ptr noundef %34)
  call void @png_destroy_write_struct(ptr noundef nonnull %3, ptr noundef nonnull %4)
  %53 = call i32 @fclose(ptr noundef nonnull %5)
  br label %59

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %54 = xor i64 %indvars.iv, -1
  %55 = add nsw i64 %41, %54
  %56 = mul nsw i64 %55, %42
  %57 = getelementptr inbounds i8, ptr %38, i64 %56
  %58 = getelementptr inbounds ptr, ptr %34, i64 %indvars.iv
  store ptr %57, ptr %58, 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

59:                                               ; preds = %24, %._crit_edge, %18
  %.1 = phi i32 [ 0, %18 ], [ 1, %._crit_edge ], [ 0, %24 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  br label %60

60:                                               ; preds = %59, %13
  %.2 = phi i32 [ 0, %13 ], [ %.1, %59 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  br label %61

61:                                               ; preds = %60, %7
  %.3 = phi i32 [ 0, %7 ], [ %.2, %60 ]
  ret i32 %.3
}

; 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

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

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

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

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

declare noalias ptr @png_create_write_struct(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @png_destroy_write_struct(ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @png_set_IHDR(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #3

declare void @png_write_info(ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @png_write_image(ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @png_write_end(ptr noundef, ptr noundef) local_unnamed_addr #3

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 = { 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 #3 = { "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 = { cold nounwind }
attributes #5 = { 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, !11, i64 8}
!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 0}
!13 = !{!10, !11, i64 4}
!14 = !{!10, !6, i64 16}
!15 = !{!10, !11, i64 12}
!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