; LLVM IR from CubbyFlow/RenderFlow :: Extensions/FlowEditor/sample_utils (file_png)

; 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.ucvector = type { ptr, i64, i64 }

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

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL20ucvector_init_bufferP8ucvectorPhm(ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL7adler32PKhj(ptr noundef, i32 noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z21lodepng_zlib_compressPPhPmPKhmPK23LodePNGCompressSettings(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4) #2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca %struct.ucvector, align 8
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i64 %3, ptr %9, align 8, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  store ptr null, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  store i64 0, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  store i32 120, ptr %17, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  store i32 0, ptr %18, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  store i32 0, ptr %19, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  %22 = load i32, ptr %17, align 4, !tbaa !11
  %23 = mul i32 256, %22
  %24 = load i32, ptr %19, align 4, !tbaa !11
  %25 = mul i32 %24, 32
  %26 = add i32 %23, %25
  %27 = load i32, ptr %18, align 4, !tbaa !11
  %28 = mul i32 %27, 64
  %29 = add i32 %26, %28
  store i32 %29, ptr %20, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  %30 = load i32, ptr %20, align 4, !tbaa !11
  %31 = urem i32 %30, 31
  %32 = sub i32 31, %31
  store i32 %32, ptr %21, align 4, !tbaa !11
  %33 = load i32, ptr %21, align 4, !tbaa !11
  %34 = load i32, ptr %20, align 4, !tbaa !11
  %35 = add i32 %34, %33
  store i32 %35, ptr %20, align 4, !tbaa !11
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = load ptr, ptr %36, align 8, !tbaa !5
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = load i64, ptr %38, align 8, !tbaa !9
  call void @_ZL20ucvector_init_bufferP8ucvectorPhm(ptr noundef %11, ptr noundef %37, i64 noundef %39)
  %40 = load i32, ptr %20, align 4, !tbaa !11
  %41 = udiv i32 %40, 256
  %42 = trunc i32 %41 to i8
  %43 = call noundef i32 @_ZL18ucvector_push_backP8ucvectorh(ptr noundef %11, i8 noundef zeroext %42)
  %44 = load i32, ptr %20, align 4, !tbaa !11
  %45 = urem i32 %44, 256
  %46 = trunc i32 %45 to i8
  %47 = call noundef i32 @_ZL18ucvector_push_backP8ucvectorh(ptr noundef %11, i8 noundef zeroext %46)
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = load i64, ptr %9, align 8, !tbaa !9
  %50 = load ptr, ptr %10, align 8, !tbaa !5
  %51 = call noundef i32 @_ZL7deflatePPhPmPKhmPK23LodePNGCompressSettings(ptr noundef %14, ptr noundef %15, ptr noundef %48, i64 noundef %49, ptr noundef %50)
  store i32 %51, ptr %13, align 4, !tbaa !11
  %52 = load i32, ptr %13, align 4, !tbaa !11
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %75, label %54

54:                                               ; preds = %5
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = load i64, ptr %9, align 8, !tbaa !9
  %57 = trunc i64 %56 to i32
  %58 = call noundef i32 @_ZL7adler32PKhj(ptr noundef %55, i32 noundef %57)
  store i32 %58, ptr %16, align 4, !tbaa !11
  store i64 0, ptr %12, align 8, !tbaa !9
  br label %59

59:                                               ; preds = %69, %54
  %60 = load i64, ptr %12, align 8, !tbaa !9
  %61 = load i64, ptr %15, align 8, !tbaa !9
  %62 = icmp ult i64 %60, %61
  br i1 %62, label %63, label %72

63:                                               ; preds = %59
  %64 = load ptr, ptr %14, align 8, !tbaa !5
  %65 = load i64, ptr %12, align 8, !tbaa !9
  %66 = getelementptr inbounds i8, ptr %64, i64 %65
  %67 = load i8, ptr %66, align 1, !tbaa !13
  %68 = call noundef i32 @_ZL18ucvector_push_backP8ucvectorh(ptr noundef %11, i8 noundef zeroext %67)
  br label %69

69:                                               ; preds = %63
  %70 = load i64, ptr %12, align 8, !tbaa !9
  %71 = add i64 %70, 1
  store i64 %71, ptr %12, align 8, !tbaa !9
  br label %59, !llvm.loop !14

72:                                               ; preds = %59
  %73 = load ptr, ptr %14, align 8, !tbaa !5
  call void @free(ptr noundef %73) #4
  %74 = load i32, ptr %16, align 4, !tbaa !11
  call void @_ZL19lodepng_add32bitIntP8ucvectorj(ptr noundef %11, i32 noundef %74)
  br label %75

75:                                               ; preds = %72, %5
  %76 = getelementptr inbounds %struct.ucvector, ptr %11, i32 0, i32 0
  %77 = load ptr, ptr %76, align 8, !tbaa !16
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %77, ptr %78, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.ucvector, ptr %11, i32 0, i32 1
  %80 = load i64, ptr %79, align 8, !tbaa !18
  %81 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %80, ptr %81, align 8, !tbaa !9
  %82 = load i32, ptr %13, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #4
  ret i32 %82
}

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL18ucvector_push_backP8ucvectorh(ptr noundef, i8 noundef zeroext) #2

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL7deflatePPhPmPKhmPK23LodePNGCompressSettings(ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef) #2

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL19lodepng_add32bitIntP8ucvectorj(ptr noundef, i32 noundef) #2

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

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !6, i64 0}
!17 = !{!"_ZTS8ucvector", !6, i64 0, !10, i64 8, !10, i64 16}
!18 = !{!17, !10, i64 8}


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

%struct.ucvector = type { ptr, i64, i64 }

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

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL20ucvector_init_bufferP8ucvectorPhm(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL7adler32PKhj(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z21lodepng_zlib_compressPPhPmPKhmPK23LodePNGCompressSettings(ptr nocapture noundef %0, ptr nocapture noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4) local_unnamed_addr #2 {
  %6 = alloca %struct.ucvector, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  store ptr null, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #4
  store i64 0, ptr %8, align 8, !tbaa !9
  %9 = load ptr, ptr %0, align 8, !tbaa !5
  %10 = load i64, ptr %1, align 8, !tbaa !9
  call void @_ZL20ucvector_init_bufferP8ucvectorPhm(ptr noundef nonnull %6, ptr noundef %9, i64 noundef %10)
  %11 = call noundef i32 @_ZL18ucvector_push_backP8ucvectorh(ptr noundef nonnull %6, i8 noundef zeroext 120)
  %12 = call noundef i32 @_ZL18ucvector_push_backP8ucvectorh(ptr noundef nonnull %6, i8 noundef zeroext 1)
  %13 = call noundef i32 @_ZL7deflatePPhPmPKhmPK23LodePNGCompressSettings(ptr noundef nonnull %7, ptr noundef nonnull %8, ptr noundef %2, i64 noundef %3, ptr noundef %4)
  %.not = icmp eq i32 %13, 0
  br i1 %.not, label %14, label %26

14:                                               ; preds = %5
  %15 = trunc i64 %3 to i32
  %16 = call noundef i32 @_ZL7adler32PKhj(ptr noundef %2, i32 noundef %15)
  %17 = load i64, ptr %8, align 8, !tbaa !9
  %.not23 = icmp eq i64 %17, 0
  br i1 %.not23, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %14, %.lr.ph
  %.022 = phi i64 [ %22, %.lr.ph ], [ 0, %14 ]
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 %.022
  %20 = load i8, ptr %19, align 1, !tbaa !11
  %21 = call noundef i32 @_ZL18ucvector_push_backP8ucvectorh(ptr noundef nonnull %6, i8 noundef zeroext %20)
  %22 = add nuw i64 %.022, 1
  %23 = load i64, ptr %8, align 8, !tbaa !9
  %24 = icmp ult i64 %22, %23
  br i1 %24, label %.lr.ph, label %._crit_edge, !llvm.loop !12

._crit_edge:                                      ; preds = %.lr.ph, %14
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  call void @free(ptr noundef %25) #4
  call void @_ZL19lodepng_add32bitIntP8ucvectorj(ptr noundef nonnull %6, i32 noundef %16)
  br label %26

26:                                               ; preds = %._crit_edge, %5
  %27 = load ptr, ptr %6, align 8, !tbaa !14
  store ptr %27, ptr %0, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %6, i64 8
  %29 = load i64, ptr %28, align 8, !tbaa !16
  store i64 %29, ptr %1, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #4
  ret i32 %13
}

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL18ucvector_push_backP8ucvectorh(ptr noundef, i8 noundef zeroext) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL7deflatePPhPmPKhmPK23LodePNGCompressSettings(ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL19lodepng_add32bitIntP8ucvectorj(ptr noundef, i32 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 #2 = { mustprogress 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 #3 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !6, i64 0}
!15 = !{!"_ZTS8ucvector", !6, i64 0, !10, i64 8, !10, i64 16}
!16 = !{!15, !10, i64 8}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass