; LLVM IR from zchrissirhcz/pixel :: legacy/zcnn (zcnn_png)

; 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.__jmp_buf_tag = type { [8 x i64], i32, %struct.__sigset_t }
%struct.__sigset_t = type { [16 x i64] }

@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [36 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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #3

declare i32 @fclose(ptr noundef) #1

declare noalias ptr @png_create_info_struct(ptr noundef) #1

; Function Attrs: nounwind returns_twice
declare i32 @_setjmp(ptr noundef) #4

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

; Function Attrs: noreturn nounwind
declare void @longjmp(ptr noundef, i32 noundef) #3

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

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

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

declare void @png_set_bgr(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @nc_image_save_png(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) #6 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !9
  store i32 %5, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %21 = call noalias ptr @png_create_write_struct(ptr noundef @.str.5, ptr noundef null, ptr noundef null, ptr noundef null)
  store ptr %21, ptr %13, align 8, !tbaa !5
  %22 = load ptr, ptr %13, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %27, label %24

24:                                               ; preds = %6
  %25 = load ptr, ptr @stderr, align 8, !tbaa !5
  %26 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef @.str.1, ptr noundef @.str.10, i32 noundef 124, ptr noundef @.str.3) #7
  call void @exit(i32 noundef 1) #8
  unreachable

27:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %28 = load ptr, ptr %13, align 8, !tbaa !5
  %29 = call noalias ptr @png_create_info_struct(ptr noundef %28)
  store ptr %29, ptr %14, align 8, !tbaa !5
  %30 = load ptr, ptr %14, align 8, !tbaa !5
  %31 = icmp ne ptr %30, null
  br i1 %31, label %33, label %32

32:                                               ; preds = %27
  call void @png_destroy_write_struct(ptr noundef %13, ptr noundef null)
  br label %33

33:                                               ; preds = %32, %27
  %34 = load ptr, ptr %13, align 8, !tbaa !5
  %35 = call ptr @png_set_longjmp_fn(ptr noundef %34, ptr noundef @longjmp, i64 noundef 200)
  %36 = getelementptr inbounds [1 x %struct.__jmp_buf_tag], ptr %35, i64 0, i64 0
  %37 = call i32 @_setjmp(ptr noundef %36) #9
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %42

39:                                               ; preds = %33
  call void @png_destroy_write_struct(ptr noundef %13, ptr noundef %14)
  %40 = load ptr, ptr @stderr, align 8, !tbaa !5
  %41 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %40, ptr noundef @.str.1, ptr noundef @.str.11, i32 noundef 134, ptr noundef @.str.3) #7
  call void @exit(i32 noundef 1) #8
  unreachable

42:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = call noalias ptr @fopen(ptr noundef %43, ptr noundef @.str.12)
  store ptr %44, ptr %15, align 8, !tbaa !5
  %45 = load ptr, ptr %15, align 8, !tbaa !5
  %46 = icmp ne ptr %45, null
  br i1 %46, label %50, label %47

47:                                               ; preds = %42
  %48 = load ptr, ptr @stderr, align 8, !tbaa !5
  %49 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %48, ptr noundef @.str.1, ptr noundef @.str.13, i32 noundef 139, ptr noundef @.str.3) #7
  call void @exit(i32 noundef 1) #8
  unreachable

50:                                               ; preds = %42
  %51 = load ptr, ptr %13, align 8, !tbaa !5
  %52 = load ptr, ptr %15, align 8, !tbaa !5
  call void @png_init_io(ptr noundef %51, ptr noundef %52)
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  store i32 3, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #7
  store i32 1, ptr %17, align 4, !tbaa !9
  %53 = load ptr, ptr %13, align 8, !tbaa !5
  call void @png_set_filter(ptr noundef %53, i32 noundef 0, i32 noundef 16)
  %54 = load ptr, ptr %13, align 8, !tbaa !5
  call void @png_set_compression_level(ptr noundef %54, i32 noundef 1)
  %55 = load ptr, ptr %13, align 8, !tbaa !5
  %56 = load i32, ptr %16, align 4, !tbaa !9
  call void @png_set_compression_strategy(ptr noundef %55, i32 noundef %56)
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #7
  %57 = load i32, ptr %11, align 4, !tbaa !9
  %58 = icmp eq i32 %57, 1
  br i1 %58, label %59, label %60

59:                                               ; preds = %50
  store i32 0, ptr %18, align 4, !tbaa !9
  br label %66

60:                                               ; preds = %50
  %61 = load i32, ptr %11, align 4, !tbaa !9
  %62 = icmp eq i32 %61, 3
  br i1 %62, label %63, label %64

63:                                               ; preds = %60
  store i32 2, ptr %18, align 4, !tbaa !9
  br label %65

64:                                               ; preds = %60
  store i32 6, ptr %18, align 4, !tbaa !9
  br label %65

65:                                               ; preds = %64, %63
  br label %66

66:                                               ; preds = %65, %59
  %67 = load ptr, ptr %13, align 8, !tbaa !5
  %68 = load ptr, ptr %14, align 8, !tbaa !5
  %69 = load i32, ptr %10, align 4, !tbaa !9
  %70 = load i32, ptr %9, align 4, !tbaa !9
  %71 = load i32, ptr %18, align 4, !tbaa !9
  call void @png_set_IHDR(ptr noundef %67, ptr noundef %68, i32 noundef %69, i32 noundef %70, i32 noundef 8, i32 noundef %71, i32 noundef 0, i32 noundef 0, i32 noundef 0)
  %72 = load ptr, ptr %13, align 8, !tbaa !5
  %73 = load ptr, ptr %14, align 8, !tbaa !5
  call void @png_write_info(ptr noundef %72, ptr noundef %73)
  %74 = load ptr, ptr %13, align 8, !tbaa !5
  call void @png_set_bgr(ptr noundef %74)
  %75 = call zeroext i1 @is_big_endian()
  br i1 %75, label %78, label %76

76:                                               ; preds = %66
  %77 = load ptr, ptr %13, align 8, !tbaa !5
  call void @png_set_swap(ptr noundef %77)
  br label %78

78:                                               ; preds = %76, %66
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  %79 = load i32, ptr %9, align 4, !tbaa !9
  %80 = zext i32 %79 to i64
  %81 = mul i64 %80, 8
  %82 = call noalias ptr @malloc(i64 noundef %81) #10
  store ptr %82, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #7
  store i32 0, ptr %20, align 4, !tbaa !9
  br label %83

83:                                               ; preds = %99, %78
  %84 = load i32, ptr %20, align 4, !tbaa !9
  %85 = load i32, ptr %9, align 4, !tbaa !9
  %86 = icmp ult i32 %84, %85
  br i1 %86, label %88, label %87

87:                                               ; preds = %83
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #7
  br label %102

88:                                               ; preds = %83
  %89 = load ptr, ptr %8, align 8, !tbaa !5
  %90 = load i32, ptr %20, align 4, !tbaa !9
  %91 = load i32, ptr %12, align 4, !tbaa !9
  %92 = mul i32 %90, %91
  %93 = zext i32 %92 to i64
  %94 = getelementptr inbounds i8, ptr %89, i64 %93
  %95 = load ptr, ptr %19, align 8, !tbaa !5
  %96 = load i32, ptr %20, align 4, !tbaa !9
  %97 = zext i32 %96 to i64
  %98 = getelementptr inbounds ptr, ptr %95, i64 %97
  store ptr %94, ptr %98, align 8, !tbaa !5
  br label %99

99:                                               ; preds = %88
  %100 = load i32, ptr %20, align 4, !tbaa !9
  %101 = add i32 %100, 1
  store i32 %101, ptr %20, align 4, !tbaa !9
  br label %83, !llvm.loop !11

102:                                              ; preds = %87
  %103 = load ptr, ptr %13, align 8, !tbaa !5
  %104 = load ptr, ptr %19, align 8, !tbaa !5
  call void @png_write_image(ptr noundef %103, ptr noundef %104)
  %105 = load ptr, ptr %13, align 8, !tbaa !5
  %106 = load ptr, ptr %14, align 8, !tbaa !5
  call void @png_write_end(ptr noundef %105, ptr noundef %106)
  %107 = load ptr, ptr %15, align 8, !tbaa !5
  %108 = call i32 @fclose(ptr noundef %107)
  %109 = load ptr, ptr %19, align 8, !tbaa !5
  call void @free(ptr noundef %109) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  ret void
}

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

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

declare void @png_set_filter(ptr noundef, i32 noundef, i32 noundef) #1

declare void @png_set_compression_level(ptr noundef, i32 noundef) #1

declare void @png_set_compression_strategy(ptr noundef, i32 noundef) #1

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

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

declare void @png_set_swap(ptr noundef) #1

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

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @is_big_endian() #6

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 = { 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 = { noreturn 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 #4 = { nounwind returns_twice "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 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 #6 = { 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 = { nounwind }
attributes #8 = { noreturn nounwind }
attributes #9 = { nounwind returns_twice }
attributes #10 = { nounwind allocsize(0) }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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.1 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [36 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 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #2

; 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

; Function Attrs: nounwind returns_twice
declare i32 @_setjmp(ptr noundef) local_unnamed_addr #4

declare ptr @png_set_longjmp_fn(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: noreturn nounwind
declare void @longjmp(ptr noundef, i32 noundef) #2

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

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

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

declare void @png_set_bgr(ptr noundef) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
define dso_local void @nc_image_save_png(ptr nocapture noundef readonly %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #7 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #8
  %9 = call noalias ptr @png_create_write_struct(ptr noundef nonnull @.str.5, ptr noundef null, ptr noundef null, ptr noundef null) #8
  store ptr %9, ptr %7, align 8, !tbaa !5
  %.not = icmp eq ptr %9, null
  br i1 %.not, label %10, label %13

10:                                               ; preds = %6
  %11 = load ptr, ptr @stderr, align 8, !tbaa !5
  %12 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.10, i32 noundef 124, ptr noundef nonnull @.str.3) #9
  call void @exit(i32 noundef 1) #10
  unreachable

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

15:                                               ; preds = %13
  call void @png_destroy_write_struct(ptr noundef nonnull %7, ptr noundef null) #8
  %.pre = load ptr, ptr %7, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %15, %13
  %17 = phi ptr [ %.pre, %15 ], [ %9, %13 ]
  %18 = call ptr @png_set_longjmp_fn(ptr noundef %17, ptr noundef nonnull @longjmp, i64 noundef 200) #8
  %19 = call i32 @_setjmp(ptr noundef %18) #11
  %.not24 = icmp eq i32 %19, 0
  br i1 %.not24, label %23, label %20

20:                                               ; preds = %16
  call void @png_destroy_write_struct(ptr noundef nonnull %7, ptr noundef nonnull %8) #8
  %21 = load ptr, ptr @stderr, align 8, !tbaa !5
  %22 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.11, i32 noundef 134, ptr noundef nonnull @.str.3) #9
  call void @exit(i32 noundef 1) #10
  unreachable

23:                                               ; preds = %16
  %24 = call noalias ptr @fopen(ptr noundef %0, ptr noundef nonnull @.str.12)
  %.not25 = icmp eq ptr %24, null
  br i1 %.not25, label %25, label %28

25:                                               ; preds = %23
  %26 = load ptr, ptr @stderr, align 8, !tbaa !5
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.13, i32 noundef 139, ptr noundef nonnull @.str.3) #9
  call void @exit(i32 noundef 1) #10
  unreachable

28:                                               ; preds = %23
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  call void @png_init_io(ptr noundef %29, ptr noundef nonnull %24) #8
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  call void @png_set_filter(ptr noundef %30, i32 noundef 0, i32 noundef 16) #8
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  call void @png_set_compression_level(ptr noundef %31, i32 noundef 1) #8
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  call void @png_set_compression_strategy(ptr noundef %32, i32 noundef 3) #8
  %switch.selectcmp = icmp eq i32 %4, 3
  %switch.select = select i1 %switch.selectcmp, i32 2, i32 6
  %switch.selectcmp26 = icmp eq i32 %4, 1
  %switch.select27 = select i1 %switch.selectcmp26, i32 0, i32 %switch.select
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  call void @png_set_IHDR(ptr noundef %33, ptr noundef %14, i32 noundef %3, i32 noundef %2, i32 noundef 8, i32 noundef %switch.select27, i32 noundef 0, i32 noundef 0, i32 noundef 0) #8
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  call void @png_write_info(ptr noundef %34, ptr noundef %14) #8
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  call void @png_set_bgr(ptr noundef %35) #8
  %36 = call zeroext i1 @is_big_endian()
  br i1 %36, label %39, label %37

37:                                               ; preds = %28
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  call void @png_set_swap(ptr noundef %38) #8
  br label %39

39:                                               ; preds = %37, %28
  %40 = zext i32 %2 to i64
  %41 = shl nuw nsw i64 %40, 3
  %42 = call noalias ptr @malloc(i64 noundef %41) #12
  %.not29 = icmp eq i32 %2, 0
  br i1 %.not29, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %39
  %xtraiter = and i64 %40, 3
  %43 = icmp ult i32 %2, 4
  br i1 %43, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %40, 4294967292
  br label %.lr.ph

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.3, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %44 = trunc nuw i64 %indvars.iv.epil to i32
  %45 = mul i32 %44, %5
  %46 = zext i32 %45 to i64
  %47 = getelementptr inbounds i8, ptr %1, i64 %46
  %48 = getelementptr inbounds ptr, ptr %42, i64 %indvars.iv.epil
  store ptr %47, ptr %48, align 8, !tbaa !5
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph.epil, !llvm.loop !9

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil, %39
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  call void @png_write_image(ptr noundef %49, ptr noundef %42) #8
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  call void @png_write_end(ptr noundef %50, ptr noundef %14) #8
  %51 = call i32 @fclose(ptr noundef nonnull %24)
  call void @free(ptr noundef %42) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #8
  ret void

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.3, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %52 = trunc nuw i64 %indvars.iv to i32
  %53 = mul i32 %52, %5
  %54 = zext i32 %53 to i64
  %55 = getelementptr inbounds i8, ptr %1, i64 %54
  %56 = getelementptr inbounds ptr, ptr %42, i64 %indvars.iv
  store ptr %55, ptr %56, align 8, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %57 = trunc nuw i64 %indvars.iv.next to i32
  %58 = mul i32 %57, %5
  %59 = zext i32 %58 to i64
  %60 = getelementptr inbounds i8, ptr %1, i64 %59
  %61 = getelementptr inbounds ptr, ptr %42, i64 %indvars.iv.next
  store ptr %60, ptr %61, align 8, !tbaa !5
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %62 = trunc nuw i64 %indvars.iv.next.1 to i32
  %63 = mul i32 %62, %5
  %64 = zext i32 %63 to i64
  %65 = getelementptr inbounds i8, ptr %1, i64 %64
  %66 = getelementptr inbounds ptr, ptr %42, i64 %indvars.iv.next.1
  store ptr %65, ptr %66, align 8, !tbaa !5
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %67 = trunc nuw i64 %indvars.iv.next.2 to i32
  %68 = mul i32 %67, %5
  %69 = zext i32 %68 to i64
  %70 = getelementptr inbounds i8, ptr %1, i64 %69
  %71 = getelementptr inbounds ptr, ptr %42, i64 %indvars.iv.next.2
  store ptr %70, ptr %71, align 8, !tbaa !5
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !11
}

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_filter(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #3

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

declare void @png_set_compression_strategy(ptr noundef, i32 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_set_swap(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

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @is_big_endian() local_unnamed_addr #7

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 = { noreturn 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 = { "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 returns_twice "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #7 = { 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 #8 = { nounwind }
attributes #9 = { cold nounwind }
attributes #10 = { noreturn nounwind }
attributes #11 = { nounwind returns_twice }
attributes #12 = { nounwind allocsize(0) }

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

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


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