; LLVM IR from alibaba/GCanvas :: core/test/linux/util (lodepng)

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

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

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

; 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 @_ZL12lodepng_freePv(ptr 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 i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca i32, align 4
  %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
  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 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  store ptr null, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  store i64 0, ptr %14, align 8, !tbaa !9
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = load i64, ptr %9, align 8, !tbaa !9
  %23 = load ptr, ptr %10, align 8, !tbaa !5
  %24 = call noundef i32 @_ZL7deflatePPhPmPKhmPK23LodePNGCompressSettings(ptr noundef %13, ptr noundef %14, ptr noundef %21, i64 noundef %22, ptr noundef %23)
  store i32 %24, ptr %12, align 4, !tbaa !11
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr null, ptr %25, align 8, !tbaa !5
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 0, ptr %26, align 8, !tbaa !9
  %27 = load i32, ptr %12, align 4, !tbaa !11
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %41, label %29

29:                                               ; preds = %5
  %30 = load i64, ptr %14, align 8, !tbaa !9
  %31 = add i64 %30, 6
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %31, ptr %32, align 8, !tbaa !9
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = load i64, ptr %33, align 8, !tbaa !9
  %35 = call noundef ptr @_ZL14lodepng_mallocm(i64 noundef %34)
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %35, ptr %36, align 8, !tbaa !5
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = icmp ne ptr %37, null
  br i1 %38, label %40, label %39

39:                                               ; preds = %29
  store i32 83, ptr %12, align 4, !tbaa !11
  br label %40

40:                                               ; preds = %39, %29
  br label %41

41:                                               ; preds = %40, %5
  %42 = load i32, ptr %12, align 4, !tbaa !11
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %100, label %44

44:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = load i64, ptr %9, align 8, !tbaa !9
  %47 = trunc i64 %46 to i32
  %48 = call noundef i32 @_ZL7adler32PKhj(ptr noundef %45, i32 noundef %47)
  store i32 %48, ptr %15, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  store i32 120, ptr %16, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  store i32 0, ptr %17, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  store i32 0, ptr %18, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  %49 = load i32, ptr %16, align 4, !tbaa !11
  %50 = mul i32 256, %49
  %51 = load i32, ptr %18, align 4, !tbaa !11
  %52 = mul i32 %51, 32
  %53 = add i32 %50, %52
  %54 = load i32, ptr %17, align 4, !tbaa !11
  %55 = mul i32 %54, 64
  %56 = add i32 %53, %55
  store i32 %56, ptr %19, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  %57 = load i32, ptr %19, align 4, !tbaa !11
  %58 = urem i32 %57, 31
  %59 = sub i32 31, %58
  store i32 %59, ptr %20, align 4, !tbaa !11
  %60 = load i32, ptr %20, align 4, !tbaa !11
  %61 = load i32, ptr %19, align 4, !tbaa !11
  %62 = add i32 %61, %60
  store i32 %62, ptr %19, align 4, !tbaa !11
  %63 = load i32, ptr %19, align 4, !tbaa !11
  %64 = lshr i32 %63, 8
  %65 = trunc i32 %64 to i8
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = load ptr, ptr %66, align 8, !tbaa !5
  %68 = getelementptr inbounds i8, ptr %67, i64 0
  store i8 %65, ptr %68, align 1, !tbaa !13
  %69 = load i32, ptr %19, align 4, !tbaa !11
  %70 = and i32 %69, 255
  %71 = trunc i32 %70 to i8
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = load ptr, ptr %72, align 8, !tbaa !5
  %74 = getelementptr inbounds i8, ptr %73, i64 1
  store i8 %71, ptr %74, align 1, !tbaa !13
  store i64 0, ptr %11, align 8, !tbaa !9
  br label %75

75:                                               ; preds = %89, %44
  %76 = load i64, ptr %11, align 8, !tbaa !9
  %77 = load i64, ptr %14, align 8, !tbaa !9
  %78 = icmp ne i64 %76, %77
  br i1 %78, label %79, label %92

79:                                               ; preds = %75
  %80 = load ptr, ptr %13, align 8, !tbaa !5
  %81 = load i64, ptr %11, align 8, !tbaa !9
  %82 = getelementptr inbounds i8, ptr %80, i64 %81
  %83 = load i8, ptr %82, align 1, !tbaa !13
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = load ptr, ptr %84, align 8, !tbaa !5
  %86 = load i64, ptr %11, align 8, !tbaa !9
  %87 = add i64 %86, 2
  %88 = getelementptr inbounds i8, ptr %85, i64 %87
  store i8 %83, ptr %88, align 1, !tbaa !13
  br label %89

89:                                               ; preds = %79
  %90 = load i64, ptr %11, align 8, !tbaa !9
  %91 = add i64 %90, 1
  store i64 %91, ptr %11, align 8, !tbaa !9
  br label %75, !llvm.loop !14

92:                                               ; preds = %75
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  %94 = load ptr, ptr %93, align 8, !tbaa !5
  %95 = load ptr, ptr %7, align 8, !tbaa !5
  %96 = load i64, ptr %95, align 8, !tbaa !9
  %97 = sub i64 %96, 4
  %98 = getelementptr inbounds i8, ptr %94, i64 %97
  %99 = load i32, ptr %15, align 4, !tbaa !11
  call void @_ZL19lodepng_set32bitIntPhj(ptr noundef %98, i32 noundef %99)
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  br label %100

100:                                              ; preds = %92, %41
  %101 = load ptr, ptr %13, align 8, !tbaa !5
  call void @_ZL12lodepng_freePv(ptr noundef %101)
  %102 = load i32, ptr %12, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  ret i32 %102
}

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

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

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 }

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


; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; 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 @_ZL12lodepng_freePv(ptr 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 ptr, align 8
  %7 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  store ptr null, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #3
  store i64 0, ptr %7, align 8, !tbaa !9
  %8 = call noundef i32 @_ZL7deflatePPhPmPKhmPK23LodePNGCompressSettings(ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef %2, i64 noundef %3, ptr noundef %4)
  store ptr null, ptr %0, align 8, !tbaa !5
  store i64 0, ptr %1, align 8, !tbaa !9
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %9, label %31

9:                                                ; preds = %5
  %10 = load i64, ptr %7, align 8, !tbaa !9
  %11 = add i64 %10, 6
  store i64 %11, ptr %1, align 8, !tbaa !9
  %12 = call noundef ptr @_ZL14lodepng_mallocm(i64 noundef %11)
  store ptr %12, ptr %0, align 8, !tbaa !5
  %13 = trunc i64 %3 to i32
  %14 = call noundef i32 @_ZL7adler32PKhj(ptr noundef %2, i32 noundef %13)
  %15 = load ptr, ptr %0, align 8, !tbaa !5
  store i8 120, ptr %15, align 1, !tbaa !11
  %16 = load ptr, ptr %0, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %16, i64 1
  store i8 1, ptr %17, align 1, !tbaa !11
  %18 = load i64, ptr %7, align 8, !tbaa !9
  %.not3439 = icmp eq i64 %18, 0
  br i1 %.not3439, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %9, %.lr.ph
  %.040 = phi i64 [ %25, %.lr.ph ], [ 0, %9 ]
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %19, i64 %.040
  %21 = load i8, ptr %20, align 1, !tbaa !11
  %22 = load ptr, ptr %0, align 8, !tbaa !5
  %23 = getelementptr i8, ptr %22, i64 %.040
  %24 = getelementptr i8, ptr %23, i64 2
  store i8 %21, ptr %24, align 1, !tbaa !11
  %25 = add i64 %.040, 1
  %26 = load i64, ptr %7, align 8, !tbaa !9
  %.not34 = icmp eq i64 %25, %26
  br i1 %.not34, label %._crit_edge, label %.lr.ph, !llvm.loop !12

._crit_edge:                                      ; preds = %.lr.ph, %9
  %27 = load ptr, ptr %0, align 8, !tbaa !5
  %28 = load i64, ptr %1, align 8, !tbaa !9
  %29 = getelementptr i8, ptr %27, i64 %28
  %30 = getelementptr i8, ptr %29, i64 -4
  call void @_ZL19lodepng_set32bitIntPhj(ptr noundef %30, i32 noundef %14)
  br label %31

31:                                               ; preds = %5, %._crit_edge
  %.03137 = phi i32 [ 0, %._crit_edge ], [ %8, %5 ]
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZL12lodepng_freePv(ptr noundef %32)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  ret i32 %.03137
}

; 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 uwtable
declare hidden void @_ZL19lodepng_set32bitIntPhj(ptr noundef, i32 noundef) local_unnamed_addr #1

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


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