; LLVM IR from niessner/Matterport :: code/gaps/pkgs/png (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_struct = type { i32, i32, i32, i64, ptr, i16, i16, i8, i8, i8, i8, i8, i8, i8, i8, [8 x i8], float, i8, 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, ptr, float, float, float, float, float, float, float, float, ptr, i32, i32, ptr, ptr, i8, i8, i32, ptr, i64, ptr, ptr, i32, i8, ptr, i32, i8, double, double, ptr, ptr, ptr, 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 noundef %0, ptr 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 %37, label %22

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

25:                                               ; preds = %22
  %26 = load ptr, ptr %13, align 8, !tbaa !5
  %27 = icmp eq ptr %26, null
  br i1 %27, label %37, label %28

28:                                               ; preds = %25
  %29 = load ptr, ptr %14, align 8, !tbaa !5
  %30 = icmp eq ptr %29, null
  br i1 %30, label %37, label %31

31:                                               ; preds = %28
  %32 = load ptr, ptr %15, align 8, !tbaa !5
  %33 = icmp eq ptr %32, null
  br i1 %33, label %37, label %34

34:                                               ; preds = %31
  %35 = load ptr, ptr %16, align 8, !tbaa !5
  %36 = icmp eq ptr %35, null
  br i1 %36, label %37, label %38

37:                                               ; preds = %34, %31, %28, %25, %22, %9
  store i32 0, ptr %10, align 4
  br label %111

38:                                               ; preds = %34
  %39 = load ptr, ptr %12, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.png_info_struct, ptr %39, i32 0, i32 0
  %41 = load i32, ptr %40, align 8, !tbaa !9
  %42 = load ptr, ptr %13, align 8, !tbaa !5
  store i32 %41, ptr %42, align 4, !tbaa !19
  %43 = load ptr, ptr %12, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.png_info_struct, ptr %43, i32 0, i32 1
  %45 = load i32, ptr %44, align 4, !tbaa !20
  %46 = load ptr, ptr %14, align 8, !tbaa !5
  store i32 %45, ptr %46, align 4, !tbaa !19
  %47 = load ptr, ptr %12, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.png_info_struct, ptr %47, i32 0, i32 7
  %49 = load i8, ptr %48, align 4, !tbaa !21
  %50 = zext i8 %49 to i32
  %51 = load ptr, ptr %15, align 8, !tbaa !5
  store i32 %50, ptr %51, align 4, !tbaa !19
  %52 = load ptr, ptr %12, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.png_info_struct, ptr %52, i32 0, i32 8
  %54 = load i8, ptr %53, align 1, !tbaa !22
  %55 = zext i8 %54 to i32
  %56 = load ptr, ptr %16, align 8, !tbaa !5
  store i32 %55, ptr %56, align 4, !tbaa !19
  %57 = load ptr, ptr %18, align 8, !tbaa !5
  %58 = icmp ne ptr %57, null
  br i1 %58, label %59, label %65

59:                                               ; preds = %38
  %60 = load ptr, ptr %12, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.png_info_struct, ptr %60, i32 0, i32 9
  %62 = load i8, ptr %61, align 2, !tbaa !23
  %63 = zext i8 %62 to i32
  %64 = load ptr, ptr %18, align 8, !tbaa !5
  store i32 %63, ptr %64, align 4, !tbaa !19
  br label %65

65:                                               ; preds = %59, %38
  %66 = load ptr, ptr %19, align 8, !tbaa !5
  %67 = icmp ne ptr %66, null
  br i1 %67, label %68, label %74

68:                                               ; preds = %65
  %69 = load ptr, ptr %12, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.png_info_struct, ptr %69, i32 0, i32 10
  %71 = load i8, ptr %70, align 1, !tbaa !24
  %72 = zext i8 %71 to i32
  %73 = load ptr, ptr %19, align 8, !tbaa !5
  store i32 %72, ptr %73, align 4, !tbaa !19
  br label %74

74:                                               ; preds = %68, %65
  %75 = load ptr, ptr %17, align 8, !tbaa !5
  %76 = icmp ne ptr %75, null
  br i1 %76, label %77, label %83

77:                                               ; preds = %74
  %78 = load ptr, ptr %12, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.png_info_struct, ptr %78, i32 0, i32 11
  %80 = load i8, ptr %79, align 8, !tbaa !25
  %81 = zext i8 %80 to i32
  %82 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 %81, ptr %82, align 4, !tbaa !19
  br label %83

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

111:                                              ; preds = %83, %37
  %112 = load i32, ptr %10, align 4
  ret i32 %112
}

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_struct", !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, !7, i64 56, !11, i64 60, !11, i64 64, !6, i64 72, !15, i64 80, !16, i64 88, !6, i64 96, !17, i64 104, !17, i64 114, !11, i64 124, !11, i64 128, !7, i64 132, !11, i64 136, !11, i64 140, !7, i64 144, !6, i64 152, !14, i64 160, !14, i64 164, !14, i64 168, !14, i64 172, !14, i64 176, !14, i64 180, !14, i64 184, !14, i64 188, !6, i64 192, !11, i64 200, !11, i64 204, !6, i64 208, !6, i64 216, !7, i64 224, !7, i64 225, !11, i64 228, !6, i64 232, !12, i64 240, !6, i64 248, !6, i64 256, !11, i64 264, !7, i64 268, !6, i64 272, !11, i64 280, !7, i64 284, !18, i64 288, !18, i64 296, !6, i64 304, !6, i64 312, !6, i64 320, !11, i64 328, !11, i64 332, !11, i64 336, !11, i64 340, !11, i64 344, !11, i64 348, !11, i64 352, !11, i64 356, !11, i64 360}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!"png_time_struct", !13, i64 0, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6}
!16 = !{!"png_color_8_struct", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4}
!17 = !{!"png_color_16_struct", !7, i64 0, !13, i64 2, !13, i64 4, !13, i64 6, !13, i64 8}
!18 = !{!"double", !7, i64 0}
!19 = !{!11, !11, i64 0}
!20 = !{!10, !11, i64 4}
!21 = !{!10, !7, i64 36}
!22 = !{!10, !7, i64 37}
!23 = !{!10, !7, i64 38}
!24 = !{!10, !7, i64 39}
!25 = !{!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 noundef %0, ptr 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 = insertelement <4 x ptr> poison, ptr %0, i64 0
  %11 = insertelement <4 x ptr> %10, ptr %1, i64 1
  %12 = insertelement <4 x ptr> %11, ptr %2, i64 2
  %13 = insertelement <4 x ptr> %12, ptr %3, i64 3
  %14 = icmp eq <4 x ptr> %13, zeroinitializer
  %15 = icmp eq ptr %4, null
  %16 = icmp eq ptr %5, null
  %17 = bitcast <4 x i1> %14 to i4
  %18 = icmp ne i4 %17, 0
  %op.rdx = or i1 %18, %15
  %op.rdx49 = or i1 %op.rdx, %16
  br i1 %op.rdx49, label %48, label %19

19:                                               ; preds = %9
  %20 = load i32, ptr %1, align 8, !tbaa !5
  store i32 %20, ptr %2, align 4, !tbaa !18
  %21 = getelementptr inbounds i8, ptr %1, i64 4
  %22 = load i32, ptr %21, align 4, !tbaa !19
  store i32 %22, ptr %3, align 4, !tbaa !18
  %23 = getelementptr inbounds i8, ptr %1, i64 36
  %24 = load i8, ptr %23, align 4, !tbaa !20
  %25 = zext i8 %24 to i32
  store i32 %25, ptr %4, align 4, !tbaa !18
  %26 = getelementptr inbounds i8, ptr %1, i64 37
  %27 = load i8, ptr %26, align 1, !tbaa !21
  %28 = zext i8 %27 to i32
  store i32 %28, ptr %5, align 4, !tbaa !18
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %33, label %29

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

33:                                               ; preds = %29, %19
  %.not46 = icmp eq ptr %8, null
  br i1 %.not46, label %38, label %34

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

38:                                               ; preds = %34, %33
  %.not47 = 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 !24
  %.pre48 = zext i8 %.pre to i32
  br i1 %.not47, label %._crit_edge, label %39

39:                                               ; preds = %38
  store i32 %.pre48, ptr %6, align 4, !tbaa !18
  br label %._crit_edge

._crit_edge:                                      ; preds = %38, %39
  %40 = load i32, ptr %1, align 8, !tbaa !5
  %41 = load i32, ptr %21, align 4, !tbaa !19
  %42 = getelementptr inbounds i8, ptr %1, i64 38
  %43 = load i8, ptr %42, align 2, !tbaa !22
  %44 = zext i8 %43 to i32
  %45 = getelementptr inbounds i8, ptr %1, i64 39
  %46 = load i8, ptr %45, align 1, !tbaa !23
  %47 = zext i8 %46 to i32
  tail call void @png_check_IHDR(ptr noundef nonnull %0, i32 noundef %40, i32 noundef %41, i32 noundef %25, i32 noundef %28, i32 noundef %.pre48, i32 noundef %44, i32 noundef %47) #2
  br label %48

48:                                               ; 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_struct", !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, !8, i64 56, !7, i64 60, !7, i64 64, !11, i64 72, !14, i64 80, !15, i64 88, !11, i64 96, !16, i64 104, !16, i64 114, !7, i64 124, !7, i64 128, !8, i64 132, !7, i64 136, !7, i64 140, !8, i64 144, !11, i64 152, !13, i64 160, !13, i64 164, !13, i64 168, !13, i64 172, !13, i64 176, !13, i64 180, !13, i64 184, !13, i64 188, !11, i64 192, !7, i64 200, !7, i64 204, !11, i64 208, !11, i64 216, !8, i64 224, !8, i64 225, !7, i64 228, !11, i64 232, !10, i64 240, !11, i64 248, !11, i64 256, !7, i64 264, !8, i64 268, !11, i64 272, !7, i64 280, !8, i64 284, !17, i64 288, !17, i64 296, !11, i64 304, !11, i64 312, !11, i64 320, !7, i64 328, !7, i64 332, !7, i64 336, !7, i64 340, !7, i64 344, !7, i64 348, !7, i64 352, !7, i64 356, !7, i64 360}
!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 = !{!"float", !8, i64 0}
!14 = !{!"png_time_struct", !12, i64 0, !8, i64 2, !8, i64 3, !8, i64 4, !8, i64 5, !8, i64 6}
!15 = !{!"png_color_8_struct", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3, !8, i64 4}
!16 = !{!"png_color_16_struct", !8, i64 0, !12, i64 2, !12, i64 4, !12, i64 6, !12, i64 8}
!17 = !{!"double", !8, i64 0}
!18 = !{!7, !7, i64 0}
!19 = !{!6, !7, i64 4}
!20 = !{!6, !8, i64 36}
!21 = !{!6, !8, i64 37}
!22 = !{!6, !8, i64 38}
!23 = !{!6, !8, i64 39}
!24 = !{!6, !8, i64 40}


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