; LLVM IR from rdguez-mariano/fast_imas_IPOL :: io_png/libs/png (pngset)

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

@.str.22 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [45 x i8], align 1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

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

declare void @png_warning(ptr noundef, ptr noundef) #2

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

declare void @png_free_data(ptr noundef, ptr noundef, i64 noundef, i32 noundef) #2

declare ptr @png_malloc_warn(ptr noundef, i64 noundef) #2

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local void @png_set_iCCP(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef %4, i64 noundef %5) #4 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store i32 %3, ptr %10, align 4, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !5
  store i64 %5, ptr %12, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = icmp eq ptr %17, null
  br i1 %18, label %28, label %19

19:                                               ; preds = %6
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = icmp eq ptr %20, null
  br i1 %21, label %28, label %22

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

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

28:                                               ; preds = %25, %22, %19, %6
  store i32 1, ptr %16, align 4
  br label %80

29:                                               ; preds = %25
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = call i64 @strlen(ptr noundef %30) #6
  %32 = add i64 %31, 1
  store i64 %32, ptr %15, align 8, !tbaa !11
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = load i64, ptr %15, align 8, !tbaa !11
  %35 = call ptr @png_malloc_warn(ptr noundef %33, i64 noundef %34)
  store ptr %35, ptr %13, align 8, !tbaa !5
  %36 = load ptr, ptr %13, align 8, !tbaa !5
  %37 = icmp eq ptr %36, null
  br i1 %37, label %38, label %40

38:                                               ; preds = %29
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  call void @png_warning(ptr noundef %39, ptr noundef @.str.22)
  store i32 1, ptr %16, align 4
  br label %80

40:                                               ; preds = %29
  %41 = load ptr, ptr %13, align 8, !tbaa !5
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = load i64, ptr %15, align 8, !tbaa !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %41, ptr align 1 %42, i64 %43, i1 false)
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = load i64, ptr %12, align 8, !tbaa !11
  %46 = call ptr @png_malloc_warn(ptr noundef %44, i64 noundef %45)
  store ptr %46, ptr %14, align 8, !tbaa !5
  %47 = load ptr, ptr %14, align 8, !tbaa !5
  %48 = icmp eq ptr %47, null
  br i1 %48, label %49, label %53

49:                                               ; preds = %40
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = load ptr, ptr %13, align 8, !tbaa !5
  call void @png_free(ptr noundef %50, ptr noundef %51)
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  call void @png_warning(ptr noundef %52, ptr noundef @.str.23)
  store i32 1, ptr %16, align 4
  br label %80

53:                                               ; preds = %40
  %54 = load ptr, ptr %14, align 8, !tbaa !5
  %55 = load ptr, ptr %11, align 8, !tbaa !5
  %56 = load i64, ptr %12, align 8, !tbaa !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %54, ptr align 1 %55, i64 %56, i1 false)
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  call void @png_free_data(ptr noundef %57, ptr noundef %58, i64 noundef 16, i32 noundef 0)
  %59 = load i64, ptr %12, align 8, !tbaa !11
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.png_info_struct, ptr %60, i32 0, i32 53
  store i64 %59, ptr %61, align 8, !tbaa !13
  %62 = load ptr, ptr %13, align 8, !tbaa !5
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.png_info_struct, ptr %63, i32 0, i32 51
  store ptr %62, ptr %64, align 8, !tbaa !21
  %65 = load ptr, ptr %14, align 8, !tbaa !5
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.png_info_struct, ptr %66, i32 0, i32 52
  store ptr %65, ptr %67, align 8, !tbaa !22
  %68 = load i32, ptr %10, align 4, !tbaa !9
  %69 = trunc i32 %68 to i8
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.png_info_struct, ptr %70, i32 0, i32 54
  store i8 %69, ptr %71, align 8, !tbaa !23
  %72 = load ptr, ptr %8, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.png_info_struct, ptr %72, i32 0, i32 48
  %74 = load i64, ptr %73, align 8, !tbaa !24
  %75 = or i64 %74, 16
  store i64 %75, ptr %73, align 8, !tbaa !24
  %76 = load ptr, ptr %8, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.png_info_struct, ptr %76, i32 0, i32 2
  %78 = load i64, ptr %77, align 8, !tbaa !25
  %79 = or i64 %78, 4096
  store i64 %79, ptr %77, align 8, !tbaa !25
  store i32 0, ptr %16, align 4
  br label %80

80:                                               ; preds = %53, %49, %38, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  %81 = load i32, ptr %16, align 4
  switch i32 %81, label %83 [
    i32 0, label %82
    i32 1, label %82
  ]

82:                                               ; preds = %80, %80
  ret void

83:                                               ; preds = %80
  unreachable
}

declare void @png_free(ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 #3 = { nounwind willreturn memory(read) "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 #4 = { 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 #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }

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


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

@.str.22 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [45 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

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

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

declare ptr @png_malloc_warn(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @png_set_iCCP(ptr noundef %0, ptr noundef %1, ptr noundef readonly %2, i32 noundef %3, ptr noundef readonly %4, i64 noundef %5) local_unnamed_addr #3 {
  %7 = insertelement <4 x ptr> poison, ptr %0, i64 0
  %8 = insertelement <4 x ptr> %7, ptr %1, i64 1
  %9 = insertelement <4 x ptr> %8, ptr %2, i64 2
  %10 = insertelement <4 x ptr> %9, ptr %4, i64 3
  %11 = icmp eq <4 x ptr> %10, zeroinitializer
  %12 = bitcast <4 x i1> %11 to i4
  %.not = icmp eq i4 %12, 0
  br i1 %.not, label %13, label %35

13:                                               ; preds = %6
  %14 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %2) #4
  %15 = add i64 %14, 1
  %16 = tail call ptr @png_malloc_warn(ptr noundef nonnull %0, i64 noundef %15) #5
  %17 = icmp eq ptr %16, null
  br i1 %17, label %18, label %19

18:                                               ; preds = %13
  tail call void @png_warning(ptr noundef nonnull %0, ptr noundef nonnull @.str.22) #5
  br label %35

19:                                               ; preds = %13
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %16, ptr nonnull align 1 %2, i64 %15, i1 false)
  %20 = tail call ptr @png_malloc_warn(ptr noundef nonnull %0, i64 noundef %5) #5
  %21 = icmp eq ptr %20, null
  br i1 %21, label %22, label %23

22:                                               ; preds = %19
  tail call void @png_free(ptr noundef nonnull %0, ptr noundef nonnull %16) #5
  tail call void @png_warning(ptr noundef nonnull %0, ptr noundef nonnull @.str.23) #5
  br label %35

23:                                               ; preds = %19
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %20, ptr nonnull align 1 %4, i64 %5, i1 false)
  tail call void @png_free_data(ptr noundef nonnull %0, ptr noundef nonnull %1, i64 noundef 16, i32 noundef 0) #5
  %24 = getelementptr inbounds i8, ptr %1, i64 312
  store i64 %5, ptr %24, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %1, i64 296
  store ptr %16, ptr %25, align 8, !tbaa !18
  %26 = getelementptr inbounds i8, ptr %1, i64 304
  store ptr %20, ptr %26, align 8, !tbaa !19
  %27 = trunc i32 %3 to i8
  %28 = getelementptr inbounds i8, ptr %1, i64 320
  store i8 %27, ptr %28, align 8, !tbaa !20
  %29 = getelementptr inbounds i8, ptr %1, i64 272
  %30 = load i64, ptr %29, align 8, !tbaa !21
  %31 = or i64 %30, 16
  store i64 %31, ptr %29, align 8, !tbaa !21
  %32 = getelementptr inbounds i8, ptr %1, i64 16
  %33 = load i64, ptr %32, align 8, !tbaa !22
  %34 = or i64 %33, 4096
  store i64 %34, ptr %32, align 8, !tbaa !22
  br label %35

35:                                               ; preds = %6, %23, %22, %18
  ret void
}

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

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 #3 = { 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 #4 = { nounwind willreturn memory(read) }
attributes #5 = { 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 312}
!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 = !{!6, !10, i64 304}
!20 = !{!6, !8, i64 320}
!21 = !{!6, !7, i64 272}
!22 = !{!6, !7, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalDCEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass