; LLVM IR from fhanau/Efficient-Compression-Tool :: src/optipng (image)

; 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.opng_image = type { i32, i32, ptr, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, %struct.png_color_16_struct, %struct.png_color_16_struct, ptr, ptr, %struct.png_color_8_struct, ptr }
%struct.png_color_16_struct = type { i8, i16, i16, i16, i16 }
%struct.png_color_8_struct = type { i8, i8, i8, i8, i8 }

; Function Attrs: nounwind uwtable
define dso_local void @opng_store_image(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %7 = load ptr, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr %6, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.opng_image, ptr %9, i32 0, i32 0
  %11 = load i32, ptr %10, align 8, !tbaa !9
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.opng_image, ptr %12, i32 0, i32 1
  %14 = load i32, ptr %13, align 4, !tbaa !15
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.opng_image, ptr %15, i32 0, i32 3
  %17 = load i32, ptr %16, align 8, !tbaa !16
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.opng_image, ptr %18, i32 0, i32 4
  %20 = load i32, ptr %19, align 4, !tbaa !17
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.opng_image, ptr %21, i32 0, i32 5
  %23 = load i32, ptr %22, align 8, !tbaa !18
  call void @png_set_IHDR(ptr noundef %7, ptr noundef %8, i32 noundef %11, i32 noundef %14, i32 noundef %17, i32 noundef %20, i32 noundef %23, i32 noundef 0, i32 noundef 0)
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.opng_image, ptr %26, i32 0, i32 9
  %28 = load ptr, ptr %27, align 8, !tbaa !19
  call void @png_set_rows(ptr noundef %24, ptr noundef %25, ptr noundef %28)
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.opng_image, ptr %29, i32 0, i32 18
  %31 = load ptr, ptr %30, align 8, !tbaa !20
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %42

33:                                               ; preds = %3
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.opng_image, ptr %36, i32 0, i32 18
  %38 = load ptr, ptr %37, align 8, !tbaa !20
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.opng_image, ptr %39, i32 0, i32 6
  %41 = load i32, ptr %40, align 4, !tbaa !21
  call void @png_set_PLTE(ptr noundef %34, ptr noundef %35, ptr noundef %38, i32 noundef %41)
  br label %42

42:                                               ; preds = %33, %3
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.opng_image, ptr %43, i32 0, i32 10
  %45 = load ptr, ptr %44, align 8, !tbaa !22
  %46 = icmp ne ptr %45, null
  br i1 %46, label %52, label %47

47:                                               ; preds = %42
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.opng_image, ptr %48, i32 0, i32 11
  %50 = load ptr, ptr %49, align 8, !tbaa !23
  %51 = icmp ne ptr %50, null
  br i1 %51, label %52, label %64

52:                                               ; preds = %47, %42
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.opng_image, ptr %55, i32 0, i32 10
  %57 = load ptr, ptr %56, align 8, !tbaa !22
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.opng_image, ptr %58, i32 0, i32 7
  %60 = load i32, ptr %59, align 8, !tbaa !24
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.opng_image, ptr %61, i32 0, i32 11
  %63 = load ptr, ptr %62, align 8, !tbaa !23
  call void @png_set_tRNS(ptr noundef %53, ptr noundef %54, ptr noundef %57, i32 noundef %60, ptr noundef %63)
  br label %64

64:                                               ; preds = %52, %47
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.opng_image, ptr %65, i32 0, i32 12
  %67 = load ptr, ptr %66, align 8, !tbaa !25
  %68 = icmp ne ptr %67, null
  br i1 %68, label %69, label %75

69:                                               ; preds = %64
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.opng_image, ptr %72, i32 0, i32 12
  %74 = load ptr, ptr %73, align 8, !tbaa !25
  call void @png_set_bKGD(ptr noundef %70, ptr noundef %71, ptr noundef %74)
  br label %75

75:                                               ; preds = %69, %64
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.opng_image, ptr %76, i32 0, i32 2
  %78 = load ptr, ptr %77, align 8, !tbaa !26
  %79 = icmp ne ptr %78, null
  br i1 %79, label %80, label %86

80:                                               ; preds = %75
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.opng_image, ptr %83, i32 0, i32 2
  %85 = load ptr, ptr %84, align 8, !tbaa !26
  call void @png_set_hIST(ptr noundef %81, ptr noundef %82, ptr noundef %85)
  br label %86

86:                                               ; preds = %80, %75
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.opng_image, ptr %87, i32 0, i32 16
  %89 = load ptr, ptr %88, align 8, !tbaa !27
  %90 = icmp ne ptr %89, null
  br i1 %90, label %91, label %97

91:                                               ; preds = %86
  %92 = load ptr, ptr %5, align 8, !tbaa !5
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.opng_image, ptr %94, i32 0, i32 16
  %96 = load ptr, ptr %95, align 8, !tbaa !27
  call void @png_set_sBIT(ptr noundef %92, ptr noundef %93, ptr noundef %96)
  br label %97

97:                                               ; preds = %91, %86
  %98 = load ptr, ptr %4, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.opng_image, ptr %98, i32 0, i32 8
  %100 = load i32, ptr %99, align 4, !tbaa !28
  %101 = icmp ne i32 %100, 0
  br i1 %101, label %102, label %111

102:                                              ; preds = %97
  %103 = load ptr, ptr %5, align 8, !tbaa !5
  %104 = load ptr, ptr %6, align 8, !tbaa !5
  %105 = load ptr, ptr %4, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.opng_image, ptr %105, i32 0, i32 15
  %107 = load ptr, ptr %106, align 8, !tbaa !29
  %108 = load ptr, ptr %4, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.opng_image, ptr %108, i32 0, i32 8
  %110 = load i32, ptr %109, align 4, !tbaa !28
  call void @png_set_unknown_chunks(ptr noundef %103, ptr noundef %104, ptr noundef %107, i32 noundef %110)
  br label %111

111:                                              ; preds = %102, %97
  ret void
}

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_set_rows(ptr noundef, ptr noundef, ptr noundef) #1

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

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

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

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

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

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

attributes #0 = { 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 #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" }

!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, !11, i64 0}
!10 = !{!"opng_image", !11, i64 0, !11, i64 4, !6, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !12, i64 72, !12, i64 82, !6, i64 96, !6, i64 104, !14, i64 112, !6, i64 120}
!11 = !{!"int", !7, i64 0}
!12 = !{!"png_color_16_struct", !7, i64 0, !13, i64 2, !13, i64 4, !13, i64 6, !13, i64 8}
!13 = !{!"short", !7, i64 0}
!14 = !{!"png_color_8_struct", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4}
!15 = !{!10, !11, i64 4}
!16 = !{!10, !11, i64 16}
!17 = !{!10, !11, i64 20}
!18 = !{!10, !11, i64 24}
!19 = !{!10, !6, i64 40}
!20 = !{!10, !6, i64 120}
!21 = !{!10, !11, i64 28}
!22 = !{!10, !6, i64 48}
!23 = !{!10, !6, i64 56}
!24 = !{!10, !11, i64 32}
!25 = !{!10, !6, i64 64}
!26 = !{!10, !6, i64 8}
!27 = !{!10, !6, i64 104}
!28 = !{!10, !11, i64 36}
!29 = !{!10, !6, i64 96}


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

; Function Attrs: nounwind uwtable
define dso_local void @opng_store_image(ptr nocapture noundef readonly %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = load i32, ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  %6 = load i32, ptr %5, align 4, !tbaa !14
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load i32, ptr %7, align 8, !tbaa !15
  %9 = getelementptr inbounds i8, ptr %0, i64 20
  %10 = load i32, ptr %9, align 4, !tbaa !16
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = load i32, ptr %11, align 8, !tbaa !17
  tail call void @png_set_IHDR(ptr noundef %1, ptr noundef %2, i32 noundef %4, i32 noundef %6, i32 noundef %8, i32 noundef %10, i32 noundef %12, i32 noundef 0, i32 noundef 0) #2
  %13 = getelementptr inbounds i8, ptr %0, i64 40
  %14 = load ptr, ptr %13, align 8, !tbaa !18
  tail call void @png_set_rows(ptr noundef %1, ptr noundef %2, ptr noundef %14) #2
  %15 = getelementptr inbounds i8, ptr %0, i64 120
  %16 = load ptr, ptr %15, align 8, !tbaa !19
  %.not = icmp eq ptr %16, null
  br i1 %.not, label %20, label %17

17:                                               ; preds = %3
  %18 = getelementptr inbounds i8, ptr %0, i64 28
  %19 = load i32, ptr %18, align 4, !tbaa !20
  tail call void @png_set_PLTE(ptr noundef %1, ptr noundef %2, ptr noundef nonnull %16, i32 noundef %19) #2
  br label %20

20:                                               ; preds = %17, %3
  %21 = getelementptr inbounds i8, ptr %0, i64 48
  %22 = load ptr, ptr %21, align 8, !tbaa !21
  %.not43 = icmp eq ptr %22, null
  %23 = getelementptr inbounds i8, ptr %0, i64 56
  %24 = load ptr, ptr %23, align 8, !tbaa !22
  %.not44 = icmp eq ptr %24, null
  %or.cond = select i1 %.not43, i1 %.not44, i1 false
  br i1 %or.cond, label %27, label %._crit_edge

._crit_edge:                                      ; preds = %20
  %25 = getelementptr inbounds i8, ptr %0, i64 32
  %26 = load i32, ptr %25, align 8, !tbaa !23
  tail call void @png_set_tRNS(ptr noundef %1, ptr noundef %2, ptr noundef %22, i32 noundef %26, ptr noundef %24) #2
  br label %27

27:                                               ; preds = %20, %._crit_edge
  %28 = getelementptr inbounds i8, ptr %0, i64 64
  %29 = load ptr, ptr %28, align 8, !tbaa !24
  %.not45 = icmp eq ptr %29, null
  br i1 %.not45, label %31, label %30

30:                                               ; preds = %27
  tail call void @png_set_bKGD(ptr noundef %1, ptr noundef %2, ptr noundef nonnull %29) #2
  br label %31

31:                                               ; preds = %30, %27
  %32 = getelementptr inbounds i8, ptr %0, i64 8
  %33 = load ptr, ptr %32, align 8, !tbaa !25
  %.not46 = icmp eq ptr %33, null
  br i1 %.not46, label %35, label %34

34:                                               ; preds = %31
  tail call void @png_set_hIST(ptr noundef %1, ptr noundef %2, ptr noundef nonnull %33) #2
  br label %35

35:                                               ; preds = %34, %31
  %36 = getelementptr inbounds i8, ptr %0, i64 104
  %37 = load ptr, ptr %36, align 8, !tbaa !26
  %.not47 = icmp eq ptr %37, null
  br i1 %.not47, label %39, label %38

38:                                               ; preds = %35
  tail call void @png_set_sBIT(ptr noundef %1, ptr noundef %2, ptr noundef nonnull %37) #2
  br label %39

39:                                               ; preds = %38, %35
  %40 = getelementptr inbounds i8, ptr %0, i64 36
  %41 = load i32, ptr %40, align 4, !tbaa !27
  %.not48 = icmp eq i32 %41, 0
  br i1 %.not48, label %45, label %42

42:                                               ; preds = %39
  %43 = getelementptr inbounds i8, ptr %0, i64 96
  %44 = load ptr, ptr %43, align 8, !tbaa !28
  tail call void @png_set_unknown_chunks(ptr noundef %1, ptr noundef %2, ptr noundef %44, i32 noundef %41) #2
  br label %45

45:                                               ; preds = %42, %39
  ret void
}

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 #1

declare void @png_set_rows(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @png_set_PLTE(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

declare void @png_set_tRNS(ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

declare void @png_set_bKGD(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @png_set_hIST(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @png_set_sBIT(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @png_set_unknown_chunks(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { 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 #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 }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"opng_image", !7, i64 0, !7, i64 4, !10, i64 8, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !11, i64 72, !11, i64 82, !10, i64 96, !10, i64 104, !13, i64 112, !10, i64 120}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"png_color_16_struct", !8, i64 0, !12, i64 2, !12, i64 4, !12, i64 6, !12, i64 8}
!12 = !{!"short", !8, i64 0}
!13 = !{!"png_color_8_struct", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3, !8, i64 4}
!14 = !{!6, !7, i64 4}
!15 = !{!6, !7, i64 16}
!16 = !{!6, !7, i64 20}
!17 = !{!6, !7, i64 24}
!18 = !{!6, !10, i64 40}
!19 = !{!6, !10, i64 120}
!20 = !{!6, !7, i64 28}
!21 = !{!6, !10, i64 48}
!22 = !{!6, !10, i64 56}
!23 = !{!6, !7, i64 32}
!24 = !{!6, !10, i64 64}
!25 = !{!6, !10, i64 8}
!26 = !{!6, !10, i64 104}
!27 = !{!6, !7, i64 36}
!28 = !{!6, !10, i64 96}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass