; LLVM IR from Try/Tempest :: Engine/thirdparty/libpng (pngget)

; 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.png_info_def = type { i32, i32, i32, i64, ptr, i16, i16, i8, i8, i8, i8, i8, i8, i8, i8, [8 x i8], %struct.png_colorspace, ptr, ptr, i32, i32, i32, ptr, %struct.png_time_struct, %struct.png_color_8_struct, ptr, %struct.png_color_16_struct, %struct.png_color_16_struct, i32, i32, i8, i32, i32, i8, i32, ptr, ptr, ptr, ptr, i32, i32, ptr, ptr, i8, i8, i32, ptr, i32, ptr, i32, i8, ptr, ptr, ptr }
%struct.png_colorspace = type { i32, %struct.png_xy, %struct.png_XYZ, i16, i16 }
%struct.png_xy = type { i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.png_XYZ = type { i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.png_time_struct = type { i16, i8, i8, i8, i8, i8 }
%struct.png_color_8_struct = type { i8, i8, i8, i8, i8 }
%struct.png_color_16_struct = type { i8, i16, i16, i16, i16 }

; Function Attrs: nounwind uwtable
define dso_local i32 @png_get_IHDR(ptr noalias noundef %0, ptr noalias noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8) #0 {
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  store ptr %0, ptr %11, align 8, !tbaa !5
  store ptr %1, ptr %12, align 8, !tbaa !5
  store ptr %2, ptr %13, align 8, !tbaa !5
  store ptr %3, ptr %14, align 8, !tbaa !5
  store ptr %4, ptr %15, align 8, !tbaa !5
  store ptr %5, ptr %16, align 8, !tbaa !5
  store ptr %6, ptr %17, align 8, !tbaa !5
  store ptr %7, ptr %18, align 8, !tbaa !5
  store ptr %8, ptr %19, align 8, !tbaa !5
  %20 = load ptr, ptr %11, align 8, !tbaa !5
  %21 = icmp eq ptr %20, null
  br i1 %21, label %25, label %22

22:                                               ; preds = %9
  %23 = load ptr, ptr %12, align 8, !tbaa !5
  %24 = icmp eq ptr %23, null
  br i1 %24, label %25, label %26

25:                                               ; preds = %22, %9
  store i32 0, ptr %10, align 4
  br label %115

26:                                               ; preds = %22
  %27 = load ptr, ptr %13, align 8, !tbaa !5
  %28 = icmp ne ptr %27, null
  br i1 %28, label %29, label %34

29:                                               ; preds = %26
  %30 = load ptr, ptr %12, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.png_info_def, ptr %30, i32 0, i32 0
  %32 = load i32, ptr %31, align 8, !tbaa !9
  %33 = load ptr, ptr %13, align 8, !tbaa !5
  store i32 %32, ptr %33, align 4, !tbaa !20
  br label %34

34:                                               ; preds = %29, %26
  %35 = load ptr, ptr %14, align 8, !tbaa !5
  %36 = icmp ne ptr %35, null
  br i1 %36, label %37, label %42

37:                                               ; preds = %34
  %38 = load ptr, ptr %12, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.png_info_def, ptr %38, i32 0, i32 1
  %40 = load i32, ptr %39, align 4, !tbaa !21
  %41 = load ptr, ptr %14, align 8, !tbaa !5
  store i32 %40, ptr %41, align 4, !tbaa !20
  br label %42

42:                                               ; preds = %37, %34
  %43 = load ptr, ptr %15, align 8, !tbaa !5
  %44 = icmp ne ptr %43, null
  br i1 %44, label %45, label %51

45:                                               ; preds = %42
  %46 = load ptr, ptr %12, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.png_info_def, ptr %46, i32 0, i32 7
  %48 = load i8, ptr %47, align 4, !tbaa !22
  %49 = zext i8 %48 to i32
  %50 = load ptr, ptr %15, align 8, !tbaa !5
  store i32 %49, ptr %50, align 4, !tbaa !20
  br label %51

51:                                               ; preds = %45, %42
  %52 = load ptr, ptr %16, align 8, !tbaa !5
  %53 = icmp ne ptr %52, null
  br i1 %53, label %54, label %60

54:                                               ; preds = %51
  %55 = load ptr, ptr %12, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.png_info_def, ptr %55, i32 0, i32 8
  %57 = load i8, ptr %56, align 1, !tbaa !23
  %58 = zext i8 %57 to i32
  %59 = load ptr, ptr %16, align 8, !tbaa !5
  store i32 %58, ptr %59, align 4, !tbaa !20
  br label %60

60:                                               ; preds = %54, %51
  %61 = load ptr, ptr %18, align 8, !tbaa !5
  %62 = icmp ne ptr %61, null
  br i1 %62, label %63, label %69

63:                                               ; preds = %60
  %64 = load ptr, ptr %12, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.png_info_def, ptr %64, i32 0, i32 9
  %66 = load i8, ptr %65, align 2, !tbaa !24
  %67 = zext i8 %66 to i32
  %68 = load ptr, ptr %18, align 8, !tbaa !5
  store i32 %67, ptr %68, align 4, !tbaa !20
  br label %69

69:                                               ; preds = %63, %60
  %70 = load ptr, ptr %19, align 8, !tbaa !5
  %71 = icmp ne ptr %70, null
  br i1 %71, label %72, label %78

72:                                               ; preds = %69
  %73 = load ptr, ptr %12, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.png_info_def, ptr %73, i32 0, i32 10
  %75 = load i8, ptr %74, align 1, !tbaa !25
  %76 = zext i8 %75 to i32
  %77 = load ptr, ptr %19, align 8, !tbaa !5
  store i32 %76, ptr %77, align 4, !tbaa !20
  br label %78

78:                                               ; preds = %72, %69
  %79 = load ptr, ptr %17, align 8, !tbaa !5
  %80 = icmp ne ptr %79, null
  br i1 %80, label %81, label %87

81:                                               ; preds = %78
  %82 = load ptr, ptr %12, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.png_info_def, ptr %82, i32 0, i32 11
  %84 = load i8, ptr %83, align 8, !tbaa !26
  %85 = zext i8 %84 to i32
  %86 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 %85, ptr %86, align 4, !tbaa !20
  br label %87

87:                                               ; preds = %81, %78
  %88 = load ptr, ptr %11, align 8, !tbaa !5
  %89 = load ptr, ptr %12, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.png_info_def, ptr %89, i32 0, i32 0
  %91 = load i32, ptr %90, align 8, !tbaa !9
  %92 = load ptr, ptr %12, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.png_info_def, ptr %92, i32 0, i32 1
  %94 = load i32, ptr %93, align 4, !tbaa !21
  %95 = load ptr, ptr %12, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.png_info_def, ptr %95, i32 0, i32 7
  %97 = load i8, ptr %96, align 4, !tbaa !22
  %98 = zext i8 %97 to i32
  %99 = load ptr, ptr %12, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.png_info_def, ptr %99, i32 0, i32 8
  %101 = load i8, ptr %100, align 1, !tbaa !23
  %102 = zext i8 %101 to i32
  %103 = load ptr, ptr %12, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.png_info_def, ptr %103, i32 0, i32 11
  %105 = load i8, ptr %104, align 8, !tbaa !26
  %106 = zext i8 %105 to i32
  %107 = load ptr, ptr %12, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.png_info_def, ptr %107, i32 0, i32 9
  %109 = load i8, ptr %108, align 2, !tbaa !24
  %110 = zext i8 %109 to i32
  %111 = load ptr, ptr %12, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.png_info_def, ptr %111, i32 0, i32 10
  %113 = load i8, ptr %112, align 1, !tbaa !25
  %114 = zext i8 %113 to i32
  call void @png_check_IHDR(ptr noundef %88, i32 noundef %91, i32 noundef %94, i32 noundef %98, i32 noundef %102, i32 noundef %106, i32 noundef %110, i32 noundef %114)
  store i32 1, ptr %10, align 4
  br label %115

115:                                              ; preds = %87, %25
  %116 = load i32, ptr %10, align 4
  ret i32 %116
}

declare void @png_check_IHDR(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 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 = !{!"png_info_def", !11, i64 0, !11, i64 4, !11, i64 8, !12, i64 16, !6, i64 24, !13, i64 32, !13, i64 34, !7, i64 36, !7, i64 37, !7, i64 38, !7, i64 39, !7, i64 40, !7, i64 41, !7, i64 42, !7, i64 43, !7, i64 44, !14, i64 52, !6, i64 128, !6, i64 136, !11, i64 144, !11, i64 148, !11, i64 152, !6, i64 160, !17, i64 168, !18, i64 176, !6, i64 184, !19, i64 192, !19, i64 202, !11, i64 212, !11, i64 216, !7, i64 220, !11, i64 224, !11, i64 228, !7, i64 232, !11, i64 236, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !11, i64 272, !11, i64 276, !6, i64 280, !6, i64 288, !7, i64 296, !7, i64 297, !11, i64 300, !6, i64 304, !11, i64 312, !6, i64 320, !11, i64 328, !7, i64 332, !6, i64 336, !6, i64 344, !6, i64 352}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!"png_colorspace", !11, i64 0, !15, i64 4, !16, i64 36, !13, i64 72, !13, i64 74}
!15 = !{!"png_xy", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28}
!16 = !{!"png_XYZ", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32}
!17 = !{!"png_time_struct", !13, i64 0, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6}
!18 = !{!"png_color_8_struct", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4}
!19 = !{!"png_color_16_struct", !7, i64 0, !13, i64 2, !13, i64 4, !13, i64 6, !13, i64 8}
!20 = !{!11, !11, i64 0}
!21 = !{!10, !11, i64 4}
!22 = !{!10, !7, i64 36}
!23 = !{!10, !7, i64 37}
!24 = !{!10, !7, i64 38}
!25 = !{!10, !7, i64 39}
!26 = !{!10, !7, i64 40}


; 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 range(i32 0, 2) i32 @png_get_IHDR(ptr noalias noundef %0, ptr noalias noundef readonly %1, ptr noundef writeonly %2, ptr noundef writeonly %3, ptr noundef writeonly %4, ptr noundef writeonly %5, ptr noundef writeonly %6, ptr noundef writeonly %7, ptr noundef writeonly %8) local_unnamed_addr #0 {
  %10 = icmp eq ptr %0, null
  %11 = icmp eq ptr %1, null
  %or.cond = or i1 %10, %11
  br i1 %or.cond, label %56, label %12

12:                                               ; preds = %9
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %15, label %13

13:                                               ; preds = %12
  %14 = load i32, ptr %1, align 8, !tbaa !5
  store i32 %14, ptr %2, align 4, !tbaa !19
  br label %15

15:                                               ; preds = %13, %12
  %.not41 = icmp eq ptr %3, null
  br i1 %.not41, label %19, label %16

16:                                               ; preds = %15
  %17 = getelementptr inbounds i8, ptr %1, i64 4
  %18 = load i32, ptr %17, align 4, !tbaa !20
  store i32 %18, ptr %3, align 4, !tbaa !19
  br label %19

19:                                               ; preds = %16, %15
  %.not42 = icmp eq ptr %4, null
  br i1 %.not42, label %24, label %20

20:                                               ; preds = %19
  %21 = getelementptr inbounds i8, ptr %1, i64 36
  %22 = load i8, ptr %21, align 4, !tbaa !21
  %23 = zext i8 %22 to i32
  store i32 %23, ptr %4, align 4, !tbaa !19
  br label %24

24:                                               ; preds = %20, %19
  %.not43 = icmp eq ptr %5, null
  br i1 %.not43, label %29, label %25

25:                                               ; preds = %24
  %26 = getelementptr inbounds i8, ptr %1, i64 37
  %27 = load i8, ptr %26, align 1, !tbaa !22
  %28 = zext i8 %27 to i32
  store i32 %28, ptr %5, align 4, !tbaa !19
  br label %29

29:                                               ; preds = %25, %24
  %.not44 = icmp eq ptr %7, null
  br i1 %.not44, label %34, label %30

30:                                               ; preds = %29
  %31 = getelementptr inbounds i8, ptr %1, i64 38
  %32 = load i8, ptr %31, align 2, !tbaa !23
  %33 = zext i8 %32 to i32
  store i32 %33, ptr %7, align 4, !tbaa !19
  br label %34

34:                                               ; preds = %30, %29
  %.not45 = icmp eq ptr %8, null
  br i1 %.not45, label %39, label %35

35:                                               ; preds = %34
  %36 = getelementptr inbounds i8, ptr %1, i64 39
  %37 = load i8, ptr %36, align 1, !tbaa !24
  %38 = zext i8 %37 to i32
  store i32 %38, ptr %8, align 4, !tbaa !19
  br label %39

39:                                               ; preds = %35, %34
  %.not46 = icmp eq ptr %6, null
  %.phi.trans.insert = getelementptr inbounds i8, ptr %1, i64 40
  %.pre = load i8, ptr %.phi.trans.insert, align 8, !tbaa !25
  %.pre47 = zext i8 %.pre to i32
  br i1 %.not46, label %._crit_edge, label %40

40:                                               ; preds = %39
  store i32 %.pre47, ptr %6, align 4, !tbaa !19
  br label %._crit_edge

._crit_edge:                                      ; preds = %39, %40
  %41 = load i32, ptr %1, align 8, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %1, i64 4
  %43 = load i32, ptr %42, align 4, !tbaa !20
  %44 = getelementptr inbounds i8, ptr %1, i64 36
  %45 = load i8, ptr %44, align 4, !tbaa !21
  %46 = zext i8 %45 to i32
  %47 = getelementptr inbounds i8, ptr %1, i64 37
  %48 = load i8, ptr %47, align 1, !tbaa !22
  %49 = zext i8 %48 to i32
  %50 = getelementptr inbounds i8, ptr %1, i64 38
  %51 = load i8, ptr %50, align 2, !tbaa !23
  %52 = zext i8 %51 to i32
  %53 = getelementptr inbounds i8, ptr %1, i64 39
  %54 = load i8, ptr %53, align 1, !tbaa !24
  %55 = zext i8 %54 to i32
  tail call void @png_check_IHDR(ptr noundef nonnull %0, i32 noundef %41, i32 noundef %43, i32 noundef %46, i32 noundef %49, i32 noundef %.pre47, i32 noundef %52, i32 noundef %55) #2
  br label %56

56:                                               ; preds = %9, %._crit_edge
  %.0 = phi i32 [ 1, %._crit_edge ], [ 0, %9 ]
  ret i32 %.0
}

declare void @png_check_IHDR(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 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 = !{!"png_info_def", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !11, i64 24, !12, i64 32, !12, i64 34, !8, i64 36, !8, i64 37, !8, i64 38, !8, i64 39, !8, i64 40, !8, i64 41, !8, i64 42, !8, i64 43, !8, i64 44, !13, i64 52, !11, i64 128, !11, i64 136, !7, i64 144, !7, i64 148, !7, i64 152, !11, i64 160, !16, i64 168, !17, i64 176, !11, i64 184, !18, i64 192, !18, i64 202, !7, i64 212, !7, i64 216, !8, i64 220, !7, i64 224, !7, i64 228, !8, i64 232, !7, i64 236, !11, i64 240, !11, i64 248, !11, i64 256, !11, i64 264, !7, i64 272, !7, i64 276, !11, i64 280, !11, i64 288, !8, i64 296, !8, i64 297, !7, i64 300, !11, i64 304, !7, i64 312, !11, i64 320, !7, i64 328, !8, i64 332, !11, i64 336, !11, i64 344, !11, i64 352}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"short", !8, i64 0}
!13 = !{!"png_colorspace", !7, i64 0, !14, i64 4, !15, i64 36, !12, i64 72, !12, i64 74}
!14 = !{!"png_xy", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28}
!15 = !{!"png_XYZ", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32}
!16 = !{!"png_time_struct", !12, i64 0, !8, i64 2, !8, i64 3, !8, i64 4, !8, i64 5, !8, i64 6}
!17 = !{!"png_color_8_struct", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3, !8, i64 4}
!18 = !{!"png_color_16_struct", !8, i64 0, !12, i64 2, !12, i64 4, !12, i64 6, !12, i64 8}
!19 = !{!7, !7, i64 0}
!20 = !{!6, !7, i64 4}
!21 = !{!6, !8, i64 36}
!22 = !{!6, !8, i64 37}
!23 = !{!6, !8, i64 38}
!24 = !{!6, !8, i64 39}
!25 = !{!6, !8, i64 40}


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