; LLVM IR from rdguez-mariano/fast_imas_IPOL :: io_png/libs/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 { i64, i64, i64, 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, i64, i64, i8, i64, i64, i8, ptr, float, float, float, float, float, float, float, float, ptr, i64, i64, ptr, ptr, i8, i8, i64, ptr, i64, ptr, ptr, i64, i8, ptr, i64, i8, double, double, ptr, ptr, ptr, i64, i64, i64, i64, i64, i64, i64, i64, i64 }
%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 i64 @png_get_iCCP(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #0 {
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  %14 = load ptr, ptr %8, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %54

16:                                               ; preds = %6
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %54

19:                                               ; preds = %16
  %20 = load ptr, ptr %9, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.png_info_struct, ptr %20, i32 0, i32 2
  %22 = load i64, ptr %21, align 8, !tbaa !9
  %23 = and i64 %22, 4096
  %24 = icmp ne i64 %23, 0
  br i1 %24, label %25, label %54

25:                                               ; preds = %19
  %26 = load ptr, ptr %10, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %54

28:                                               ; preds = %25
  %29 = load ptr, ptr %12, align 8, !tbaa !5
  %30 = icmp ne ptr %29, null
  br i1 %30, label %31, label %54

31:                                               ; preds = %28
  %32 = load ptr, ptr %13, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %54

34:                                               ; preds = %31
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.png_info_struct, ptr %35, i32 0, i32 51
  %37 = load ptr, ptr %36, align 8, !tbaa !19
  %38 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %37, ptr %38, align 8, !tbaa !5
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.png_info_struct, ptr %39, i32 0, i32 52
  %41 = load ptr, ptr %40, align 8, !tbaa !20
  %42 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %41, ptr %42, align 8, !tbaa !5
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.png_info_struct, ptr %43, i32 0, i32 53
  %45 = load i64, ptr %44, align 8, !tbaa !21
  %46 = trunc i64 %45 to i32
  %47 = sext i32 %46 to i64
  %48 = load ptr, ptr %13, align 8, !tbaa !5
  store i64 %47, ptr %48, align 8, !tbaa !22
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.png_info_struct, ptr %49, i32 0, i32 54
  %51 = load i8, ptr %50, align 8, !tbaa !23
  %52 = zext i8 %51 to i32
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  store i32 %52, ptr %53, align 4, !tbaa !24
  store i64 4096, ptr %7, align 8
  br label %55

54:                                               ; preds = %31, %28, %25, %19, %16, %6
  store i64 0, ptr %7, align 8
  br label %55

55:                                               ; preds = %54, %34
  %56 = load i64, ptr %7, align 8
  ret i64 %56
}

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

!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 16}
!10 = !{!"png_info_struct", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !6, i64 32, !12, i64 40, !12, i64 42, !7, i64 44, !7, i64 45, !7, i64 46, !7, i64 47, !7, i64 48, !7, i64 49, !7, i64 50, !7, i64 51, !7, i64 52, !13, i64 60, !7, i64 64, !14, i64 68, !14, i64 72, !6, i64 80, !15, i64 88, !16, i64 96, !6, i64 104, !17, i64 112, !17, i64 122, !11, i64 136, !11, i64 144, !7, i64 152, !11, i64 160, !11, i64 168, !7, i64 176, !6, i64 184, !13, i64 192, !13, i64 196, !13, i64 200, !13, i64 204, !13, i64 208, !13, i64 212, !13, i64 216, !13, i64 220, !6, i64 224, !11, i64 232, !11, i64 240, !6, i64 248, !6, i64 256, !7, i64 264, !7, i64 265, !11, i64 272, !6, i64 280, !11, i64 288, !6, i64 296, !6, i64 304, !11, i64 312, !7, i64 320, !6, i64 328, !11, i64 336, !7, i64 344, !18, i64 352, !18, i64 360, !6, i64 368, !6, i64 376, !6, i64 384, !11, i64 392, !11, i64 400, !11, i64 408, !11, i64 416, !11, i64 424, !11, i64 432, !11, i64 440, !11, i64 448, !11, i64 456}
!11 = !{!"long", !7, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!"png_time_struct", !12, 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, !12, i64 2, !12, i64 4, !12, i64 6, !12, i64 8}
!18 = !{!"double", !7, i64 0}
!19 = !{!10, !6, i64 296}
!20 = !{!10, !6, i64 304}
!21 = !{!10, !11, i64 312}
!22 = !{!11, !11, i64 0}
!23 = !{!10, !7, i64 320}
!24 = !{!14, !14, i64 0}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local range(i64 0, 4097) i64 @png_get_iCCP(ptr noundef readnone %0, ptr noundef readonly %1, ptr noundef writeonly %2, ptr nocapture noundef writeonly %3, ptr noundef writeonly %4, ptr noundef writeonly %5) local_unnamed_addr #0 {
  %7 = icmp ne ptr %0, null
  %8 = icmp ne ptr %1, null
  %or.cond = and i1 %7, %8
  br i1 %or.cond, label %9, label %28

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %1, i64 16
  %11 = load i64, ptr %10, align 8, !tbaa !5
  %12 = and i64 %11, 4096
  %13 = icmp ne i64 %12, 0
  %14 = icmp ne ptr %2, null
  %or.cond3 = and i1 %14, %13
  %15 = icmp ne ptr %4, null
  %or.cond5 = and i1 %15, %or.cond3
  %16 = icmp ne ptr %5, null
  %or.cond7 = and i1 %16, %or.cond5
  br i1 %or.cond7, label %17, label %28

17:                                               ; preds = %9
  %18 = getelementptr inbounds i8, ptr %1, i64 296
  %19 = load ptr, ptr %18, align 8, !tbaa !18
  store ptr %19, ptr %2, align 8, !tbaa !19
  %20 = getelementptr inbounds i8, ptr %1, i64 304
  %21 = load ptr, ptr %20, align 8, !tbaa !20
  store ptr %21, ptr %4, align 8, !tbaa !19
  %22 = getelementptr inbounds i8, ptr %1, i64 312
  %23 = load i64, ptr %22, align 8, !tbaa !21
  %sext = shl i64 %23, 32
  %24 = ashr exact i64 %sext, 32
  store i64 %24, ptr %5, align 8, !tbaa !22
  %25 = getelementptr inbounds i8, ptr %1, i64 320
  %26 = load i8, ptr %25, align 8, !tbaa !23
  %27 = zext i8 %26 to i32
  store i32 %27, ptr %3, align 4, !tbaa !24
  br label %28

28:                                               ; preds = %6, %9, %17
  %.0 = phi i64 [ 4096, %17 ], [ 0, %9 ], [ 0, %6 ]
  ret i64 %.0
}

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

!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 16}
!6 = !{!"png_info_struct", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !11, i64 40, !11, i64 42, !8, i64 44, !8, i64 45, !8, i64 46, !8, i64 47, !8, i64 48, !8, i64 49, !8, i64 50, !8, i64 51, !8, i64 52, !12, i64 60, !8, i64 64, !13, i64 68, !13, i64 72, !10, i64 80, !14, i64 88, !15, i64 96, !10, i64 104, !16, i64 112, !16, i64 122, !7, i64 136, !7, i64 144, !8, i64 152, !7, i64 160, !7, i64 168, !8, i64 176, !10, i64 184, !12, i64 192, !12, i64 196, !12, i64 200, !12, i64 204, !12, i64 208, !12, i64 212, !12, i64 216, !12, i64 220, !10, i64 224, !7, i64 232, !7, i64 240, !10, i64 248, !10, i64 256, !8, i64 264, !8, i64 265, !7, i64 272, !10, i64 280, !7, i64 288, !10, i64 296, !10, i64 304, !7, i64 312, !8, i64 320, !10, i64 328, !7, i64 336, !8, i64 344, !17, i64 352, !17, i64 360, !10, i64 368, !10, i64 376, !10, i64 384, !7, i64 392, !7, i64 400, !7, i64 408, !7, i64 416, !7, i64 424, !7, i64 432, !7, i64 440, !7, i64 448, !7, i64 456}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"short", !8, i64 0}
!12 = !{!"float", !8, i64 0}
!13 = !{!"int", !8, i64 0}
!14 = !{!"png_time_struct", !11, 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, !11, i64 2, !11, i64 4, !11, i64 6, !11, i64 8}
!17 = !{!"double", !8, i64 0}
!18 = !{!6, !10, i64 296}
!19 = !{!10, !10, i64 0}
!20 = !{!6, !10, i64 304}
!21 = !{!6, !7, i64 312}
!22 = !{!7, !7, i64 0}
!23 = !{!6, !8, i64 320}
!24 = !{!13, !13, i64 0}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass