; LLVM IR from niessner/Matterport :: code/gaps/pkgs/png (pngerror)

; 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_struct_def = type { [1 x %struct.__jmp_buf_tag], ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i8, i8, i32, i32, i32, %struct.z_stream_s, ptr, i64, i32, i32, i32, i32, i32, i32, i32, i32, i32, i64, i64, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, %struct.png_row_info_struct, i32, i32, ptr, i16, i16, [5 x i8], i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i16, i8, float, %struct.png_color_16_struct, %struct.png_color_16_struct, ptr, i32, i32, i32, float, float, ptr, ptr, ptr, ptr, ptr, ptr, %struct.png_color_8_struct, %struct.png_color_8_struct, ptr, %struct.png_color_16_struct, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i64, i64, i64, i64, i32, i32, i64, i64, ptr, ptr, ptr, ptr, ptr, i8, i8, ptr, ptr, ptr, ptr, ptr, ptr, i32, ptr, ptr, i32, ptr, i8, i16, i16, i16, i32, i32, i8, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i8, i32, i32, i32, %struct.png_unknown_chunk_t, i32, i32, ptr, i32 }
%struct.__jmp_buf_tag = type { [8 x i64], i32, %struct.__sigset_t }
%struct.__sigset_t = type { [16 x i64] }
%struct.z_stream_s = type { ptr, i32, i64, ptr, i32, i64, ptr, ptr, ptr, ptr, ptr, i32, i64, i64 }
%struct.png_row_info_struct = type { i32, i64, 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 }
%struct.png_unknown_chunk_t = type { [5 x i8], ptr, i64, i8 }

; Function Attrs: nounwind uwtable
define dso_local void @png_warning(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 0, ptr %5, align 4, !tbaa !9
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = icmp ne ptr %6, null
  br i1 %7, label %8, label %32

8:                                                ; preds = %2
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = load i8, ptr %9, align 1, !tbaa !11
  %11 = sext i8 %10 to i32
  %12 = icmp eq i32 %11, 35
  br i1 %12, label %13, label %31

13:                                               ; preds = %8
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %27, %13
  %15 = load i32, ptr %5, align 4, !tbaa !9
  %16 = icmp slt i32 %15, 15
  br i1 %16, label %17, label %30

17:                                               ; preds = %14
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds i8, ptr %18, i64 %20
  %22 = load i8, ptr %21, align 1, !tbaa !11
  %23 = sext i8 %22 to i32
  %24 = icmp eq i32 %23, 32
  br i1 %24, label %25, label %26

25:                                               ; preds = %17
  br label %30

26:                                               ; preds = %17
  br label %27

27:                                               ; preds = %26
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %5, align 4, !tbaa !9
  br label %14, !llvm.loop !12

30:                                               ; preds = %25, %14
  br label %31

31:                                               ; preds = %30, %8
  br label %32

32:                                               ; preds = %31, %2
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %49

35:                                               ; preds = %32
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.png_struct_def, ptr %36, i32 0, i32 3
  %38 = load ptr, ptr %37, align 8, !tbaa !14
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %49

40:                                               ; preds = %35
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.png_struct_def, ptr %41, i32 0, i32 3
  %43 = load ptr, ptr %42, align 8, !tbaa !14
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = load i32, ptr %5, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds i8, ptr %45, i64 %47
  call void %43(ptr noundef %44, ptr noundef %48)
  br label %55

49:                                               ; preds = %35, %32
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = load i32, ptr %5, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds i8, ptr %51, i64 %53
  call void @png_default_warning(ptr noundef %50, ptr noundef %54)
  br label %55

55:                                               ; preds = %49, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret void
}

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

; Function Attrs: nounwind uwtable
declare hidden void @png_default_warning(ptr noundef, ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !6, i64 216}
!15 = !{!"png_struct_def", !7, i64 0, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !7, i64 280, !7, i64 281, !10, i64 284, !10, i64 288, !10, i64 292, !16, i64 296, !6, i64 408, !17, i64 416, !10, i64 424, !10, i64 428, !10, i64 432, !10, i64 436, !10, i64 440, !10, i64 444, !10, i64 448, !10, i64 452, !10, i64 456, !17, i64 464, !17, i64 472, !10, i64 480, !10, i64 484, !6, i64 488, !6, i64 496, !6, i64 504, !6, i64 512, !6, i64 520, !6, i64 528, !18, i64 536, !10, i64 560, !10, i64 564, !6, i64 568, !19, i64 576, !19, i64 578, !7, i64 580, !7, i64 585, !7, i64 586, !7, i64 587, !7, i64 588, !7, i64 589, !7, i64 590, !7, i64 591, !7, i64 592, !7, i64 593, !7, i64 594, !7, i64 595, !7, i64 596, !19, i64 598, !7, i64 600, !20, i64 604, !21, i64 608, !21, i64 618, !6, i64 632, !10, i64 640, !10, i64 644, !10, i64 648, !20, i64 652, !20, i64 656, !6, i64 664, !6, i64 672, !6, i64 680, !6, i64 688, !6, i64 696, !6, i64 704, !22, i64 712, !22, i64 717, !6, i64 728, !21, i64 736, !6, i64 752, !6, i64 760, !6, i64 768, !6, i64 776, !6, i64 784, !6, i64 792, !6, i64 800, !6, i64 808, !6, i64 816, !10, i64 824, !10, i64 828, !17, i64 832, !17, i64 840, !17, i64 848, !17, i64 856, !10, i64 864, !10, i64 868, !17, i64 872, !17, i64 880, !6, i64 888, !6, i64 896, !6, i64 904, !6, i64 912, !6, i64 920, !7, i64 928, !7, i64 929, !6, i64 936, !6, i64 944, !6, i64 952, !6, i64 960, !6, i64 968, !6, i64 976, !10, i64 984, !6, i64 992, !6, i64 1000, !10, i64 1008, !6, i64 1016, !7, i64 1024, !19, i64 1026, !19, i64 1028, !19, i64 1030, !10, i64 1032, !10, i64 1036, !7, i64 1040, !6, i64 1048, !6, i64 1056, !6, i64 1064, !6, i64 1072, !6, i64 1080, !6, i64 1088, !6, i64 1096, !7, i64 1104, !10, i64 1108, !10, i64 1112, !10, i64 1116, !23, i64 1120, !10, i64 1152, !10, i64 1156, !6, i64 1160, !10, i64 1168}
!16 = !{!"z_stream_s", !6, i64 0, !10, i64 8, !17, i64 16, !6, i64 24, !10, i64 32, !17, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !10, i64 88, !17, i64 96, !17, i64 104}
!17 = !{!"long", !7, i64 0}
!18 = !{!"png_row_info_struct", !10, i64 0, !17, i64 8, !7, i64 16, !7, i64 17, !7, i64 18, !7, i64 19}
!19 = !{!"short", !7, i64 0}
!20 = !{!"float", !7, i64 0}
!21 = !{!"png_color_16_struct", !7, i64 0, !19, i64 2, !19, i64 4, !19, i64 6, !19, i64 8}
!22 = !{!"png_color_8_struct", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4}
!23 = !{!"png_unknown_chunk_t", !7, i64 0, !6, i64 8, !17, i64 16, !7, i64 24}


; 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 @png_warning(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %.thread, label %3

3:                                                ; preds = %2
  %4 = load i8, ptr %1, align 1, !tbaa !5
  %5 = icmp eq i8 %4, 35
  br i1 %5, label %.preheader.preheader, label %.thread19

.preheader.preheader:                             ; preds = %3
  %6 = getelementptr inbounds i8, ptr %1, i64 1
  %7 = load i8, ptr %6, align 1, !tbaa !5
  %8 = icmp eq i8 %7, 32
  br i1 %8, label %.thread19, label %.preheader.1

.preheader.1:                                     ; preds = %.preheader.preheader
  %9 = getelementptr inbounds i8, ptr %1, i64 2
  %10 = load i8, ptr %9, align 1, !tbaa !5
  %11 = icmp eq i8 %10, 32
  br i1 %11, label %.thread19, label %.preheader.2

.preheader.2:                                     ; preds = %.preheader.1
  %12 = getelementptr inbounds i8, ptr %1, i64 3
  %13 = load i8, ptr %12, align 1, !tbaa !5
  %14 = icmp eq i8 %13, 32
  br i1 %14, label %.thread19, label %.preheader.3

.preheader.3:                                     ; preds = %.preheader.2
  %15 = getelementptr inbounds i8, ptr %1, i64 4
  %16 = load i8, ptr %15, align 1, !tbaa !5
  %17 = icmp eq i8 %16, 32
  br i1 %17, label %.thread19, label %.preheader.4

.preheader.4:                                     ; preds = %.preheader.3
  %18 = getelementptr inbounds i8, ptr %1, i64 5
  %19 = load i8, ptr %18, align 1, !tbaa !5
  %20 = icmp eq i8 %19, 32
  br i1 %20, label %.thread19, label %.preheader.5

.preheader.5:                                     ; preds = %.preheader.4
  %21 = getelementptr inbounds i8, ptr %1, i64 6
  %22 = load i8, ptr %21, align 1, !tbaa !5
  %23 = icmp eq i8 %22, 32
  br i1 %23, label %.thread19, label %.preheader.6

.preheader.6:                                     ; preds = %.preheader.5
  %24 = getelementptr inbounds i8, ptr %1, i64 7
  %25 = load i8, ptr %24, align 1, !tbaa !5
  %26 = icmp eq i8 %25, 32
  br i1 %26, label %.thread19, label %.preheader.7

.preheader.7:                                     ; preds = %.preheader.6
  %27 = getelementptr inbounds i8, ptr %1, i64 8
  %28 = load i8, ptr %27, align 1, !tbaa !5
  %29 = icmp eq i8 %28, 32
  br i1 %29, label %.thread19, label %.preheader.8

.preheader.8:                                     ; preds = %.preheader.7
  %30 = getelementptr inbounds i8, ptr %1, i64 9
  %31 = load i8, ptr %30, align 1, !tbaa !5
  %32 = icmp eq i8 %31, 32
  br i1 %32, label %.thread19, label %.preheader.9

.preheader.9:                                     ; preds = %.preheader.8
  %33 = getelementptr inbounds i8, ptr %1, i64 10
  %34 = load i8, ptr %33, align 1, !tbaa !5
  %35 = icmp eq i8 %34, 32
  br i1 %35, label %.thread19, label %.preheader.10

.preheader.10:                                    ; preds = %.preheader.9
  %36 = getelementptr inbounds i8, ptr %1, i64 11
  %37 = load i8, ptr %36, align 1, !tbaa !5
  %38 = icmp eq i8 %37, 32
  br i1 %38, label %.thread19, label %.preheader.11

.preheader.11:                                    ; preds = %.preheader.10
  %39 = getelementptr inbounds i8, ptr %1, i64 12
  %40 = load i8, ptr %39, align 1, !tbaa !5
  %41 = icmp eq i8 %40, 32
  br i1 %41, label %.thread19, label %.preheader.12

.preheader.12:                                    ; preds = %.preheader.11
  %42 = getelementptr inbounds i8, ptr %1, i64 13
  %43 = load i8, ptr %42, align 1, !tbaa !5
  %44 = icmp eq i8 %43, 32
  br i1 %44, label %.thread19, label %.preheader.13

.preheader.13:                                    ; preds = %.preheader.12
  %45 = getelementptr inbounds i8, ptr %1, i64 14
  %46 = load i8, ptr %45, align 1, !tbaa !5
  %47 = icmp eq i8 %46, 32
  %spec.select = select i1 %47, i32 14, i32 15
  br label %.thread19

.thread19:                                        ; preds = %.preheader.13, %.preheader.preheader, %.preheader.1, %.preheader.2, %.preheader.3, %.preheader.4, %.preheader.5, %.preheader.6, %.preheader.7, %.preheader.8, %.preheader.9, %.preheader.10, %.preheader.11, %.preheader.12, %3
  %.121 = phi i32 [ 0, %3 ], [ 1, %.preheader.preheader ], [ 2, %.preheader.1 ], [ 3, %.preheader.2 ], [ 4, %.preheader.3 ], [ 5, %.preheader.4 ], [ 6, %.preheader.5 ], [ 7, %.preheader.6 ], [ 8, %.preheader.7 ], [ 9, %.preheader.8 ], [ 10, %.preheader.9 ], [ 11, %.preheader.10 ], [ 12, %.preheader.11 ], [ 13, %.preheader.12 ], [ %spec.select, %.preheader.13 ]
  %48 = getelementptr inbounds i8, ptr %0, i64 216
  %49 = load ptr, ptr %48, align 8, !tbaa !8
  %.not16 = icmp eq ptr %49, null
  br i1 %.not16, label %.thread, label %50

50:                                               ; preds = %.thread19
  %51 = zext nneg i32 %.121 to i64
  %52 = getelementptr inbounds i8, ptr %1, i64 %51
  tail call void %49(ptr noundef nonnull %0, ptr noundef nonnull %52) #1
  br label %55

.thread:                                          ; preds = %2, %.thread19
  %.118 = phi i32 [ %.121, %.thread19 ], [ 0, %2 ]
  %53 = zext nneg i32 %.118 to i64
  %54 = getelementptr inbounds i8, ptr %1, i64 %53
  tail call void @png_default_warning(ptr noundef %0, ptr noundef %54)
  br label %55

55:                                               ; preds = %.thread, %50
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @png_default_warning(ptr noundef, ptr noundef) local_unnamed_addr #0

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 = { 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, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !10, i64 216}
!9 = !{!"png_struct_def", !6, i64 0, !10, i64 200, !10, i64 208, !10, i64 216, !10, i64 224, !10, i64 232, !10, i64 240, !10, i64 248, !10, i64 256, !10, i64 264, !10, i64 272, !6, i64 280, !6, i64 281, !11, i64 284, !11, i64 288, !11, i64 292, !12, i64 296, !10, i64 408, !13, i64 416, !11, i64 424, !11, i64 428, !11, i64 432, !11, i64 436, !11, i64 440, !11, i64 444, !11, i64 448, !11, i64 452, !11, i64 456, !13, i64 464, !13, i64 472, !11, i64 480, !11, i64 484, !10, i64 488, !10, i64 496, !10, i64 504, !10, i64 512, !10, i64 520, !10, i64 528, !14, i64 536, !11, i64 560, !11, i64 564, !10, i64 568, !15, i64 576, !15, i64 578, !6, i64 580, !6, i64 585, !6, i64 586, !6, i64 587, !6, i64 588, !6, i64 589, !6, i64 590, !6, i64 591, !6, i64 592, !6, i64 593, !6, i64 594, !6, i64 595, !6, i64 596, !15, i64 598, !6, i64 600, !16, i64 604, !17, i64 608, !17, i64 618, !10, i64 632, !11, i64 640, !11, i64 644, !11, i64 648, !16, i64 652, !16, i64 656, !10, i64 664, !10, i64 672, !10, i64 680, !10, i64 688, !10, i64 696, !10, i64 704, !18, i64 712, !18, i64 717, !10, i64 728, !17, i64 736, !10, i64 752, !10, i64 760, !10, i64 768, !10, i64 776, !10, i64 784, !10, i64 792, !10, i64 800, !10, i64 808, !10, i64 816, !11, i64 824, !11, i64 828, !13, i64 832, !13, i64 840, !13, i64 848, !13, i64 856, !11, i64 864, !11, i64 868, !13, i64 872, !13, i64 880, !10, i64 888, !10, i64 896, !10, i64 904, !10, i64 912, !10, i64 920, !6, i64 928, !6, i64 929, !10, i64 936, !10, i64 944, !10, i64 952, !10, i64 960, !10, i64 968, !10, i64 976, !11, i64 984, !10, i64 992, !10, i64 1000, !11, i64 1008, !10, i64 1016, !6, i64 1024, !15, i64 1026, !15, i64 1028, !15, i64 1030, !11, i64 1032, !11, i64 1036, !6, i64 1040, !10, i64 1048, !10, i64 1056, !10, i64 1064, !10, i64 1072, !10, i64 1080, !10, i64 1088, !10, i64 1096, !6, i64 1104, !11, i64 1108, !11, i64 1112, !11, i64 1116, !19, i64 1120, !11, i64 1152, !11, i64 1156, !10, i64 1160, !11, i64 1168}
!10 = !{!"any pointer", !6, i64 0}
!11 = !{!"int", !6, i64 0}
!12 = !{!"z_stream_s", !10, i64 0, !11, i64 8, !13, i64 16, !10, i64 24, !11, i64 32, !13, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !11, i64 88, !13, i64 96, !13, i64 104}
!13 = !{!"long", !6, i64 0}
!14 = !{!"png_row_info_struct", !11, i64 0, !13, i64 8, !6, i64 16, !6, i64 17, !6, i64 18, !6, i64 19}
!15 = !{!"short", !6, i64 0}
!16 = !{!"float", !6, i64 0}
!17 = !{!"png_color_16_struct", !6, i64 0, !15, i64 2, !15, i64 4, !15, i64 6, !15, i64 8}
!18 = !{!"png_color_8_struct", !6, i64 0, !6, i64 1, !6, i64 2, !6, i64 3, !6, i64 4}
!19 = !{!"png_unknown_chunk_t", !6, i64 0, !10, i64 8, !13, i64 16, !6, i64 24}


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass,TailCallElimPass