; LLVM IR from mncoppola/rpef :: utilities_src/squashfs4.1/squashfs-tools (xz_wrapper)

; 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.lzma_options_lzma = type { i32, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr }
%struct.lzma_stream = type { ptr, i64, i64, ptr, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, i64, i64, i64, i64, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local i32 @lzma_compress(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, ptr noundef %5) #0 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca %struct.lzma_options_lzma, align 8
  %16 = alloca %struct.lzma_stream, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  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 i32 %3, ptr %11, align 4, !tbaa !9
  store i32 %4, ptr %12, align 4, !tbaa !9
  store ptr %5, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %19 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %19, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 112, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 136, ptr %16) #4
  call void @llvm.memset.p0.i64(ptr align 8 %16, i8 0, i64 136, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %20 = call zeroext i8 @lzma_lzma_preset(ptr noundef %15, i32 noundef 5) #4
  %21 = load i32, ptr %12, align 4, !tbaa !9
  %22 = getelementptr inbounds %struct.lzma_options_lzma, ptr %15, i32 0, i32 0
  store i32 %21, ptr %22, align 8, !tbaa !11
  %23 = call i32 @lzma_alone_encoder(ptr noundef %16, ptr noundef %15) #4
  store i32 %23, ptr %17, align 4, !tbaa !9
  %24 = load i32, ptr %17, align 4, !tbaa !9
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %27

26:                                               ; preds = %6
  call void @lzma_end(ptr noundef %16) #4
  br label %81

27:                                               ; preds = %6
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.lzma_stream, ptr %16, i32 0, i32 3
  store ptr %28, ptr %29, align 8, !tbaa !13
  %30 = load i32, ptr %12, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds %struct.lzma_stream, ptr %16, i32 0, i32 4
  store i64 %31, ptr %32, align 8, !tbaa !16
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.lzma_stream, ptr %16, i32 0, i32 0
  store ptr %33, ptr %34, align 8, !tbaa !17
  %35 = load i32, ptr %11, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds %struct.lzma_stream, ptr %16, i32 0, i32 1
  store i64 %36, ptr %37, align 8, !tbaa !18
  %38 = call i32 @lzma_code(ptr noundef %16, i32 noundef 3) #4
  store i32 %38, ptr %17, align 4, !tbaa !9
  call void @lzma_end(ptr noundef %16) #4
  %39 = load i32, ptr %17, align 4, !tbaa !9
  %40 = icmp eq i32 %39, 1
  br i1 %40, label %41, label %76

41:                                               ; preds = %27
  %42 = load i32, ptr %11, align 4, !tbaa !9
  %43 = and i32 %42, 255
  %44 = trunc i32 %43 to i8
  %45 = load ptr, ptr %14, align 8, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %45, i64 5
  store i8 %44, ptr %46, align 1, !tbaa !19
  %47 = load i32, ptr %11, align 4, !tbaa !9
  %48 = ashr i32 %47, 8
  %49 = and i32 %48, 255
  %50 = trunc i32 %49 to i8
  %51 = load ptr, ptr %14, align 8, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %51, i64 6
  store i8 %50, ptr %52, align 1, !tbaa !19
  %53 = load i32, ptr %11, align 4, !tbaa !9
  %54 = ashr i32 %53, 16
  %55 = and i32 %54, 255
  %56 = trunc i32 %55 to i8
  %57 = load ptr, ptr %14, align 8, !tbaa !5
  %58 = getelementptr inbounds i8, ptr %57, i64 7
  store i8 %56, ptr %58, align 1, !tbaa !19
  %59 = load i32, ptr %11, align 4, !tbaa !9
  %60 = ashr i32 %59, 24
  %61 = and i32 %60, 255
  %62 = trunc i32 %61 to i8
  %63 = load ptr, ptr %14, align 8, !tbaa !5
  %64 = getelementptr inbounds i8, ptr %63, i64 8
  store i8 %62, ptr %64, align 1, !tbaa !19
  %65 = load ptr, ptr %14, align 8, !tbaa !5
  %66 = getelementptr inbounds i8, ptr %65, i64 9
  store i8 0, ptr %66, align 1, !tbaa !19
  %67 = load ptr, ptr %14, align 8, !tbaa !5
  %68 = getelementptr inbounds i8, ptr %67, i64 10
  store i8 0, ptr %68, align 1, !tbaa !19
  %69 = load ptr, ptr %14, align 8, !tbaa !5
  %70 = getelementptr inbounds i8, ptr %69, i64 11
  store i8 0, ptr %70, align 1, !tbaa !19
  %71 = load ptr, ptr %14, align 8, !tbaa !5
  %72 = getelementptr inbounds i8, ptr %71, i64 12
  store i8 0, ptr %72, align 1, !tbaa !19
  %73 = getelementptr inbounds %struct.lzma_stream, ptr %16, i32 0, i32 5
  %74 = load i64, ptr %73, align 8, !tbaa !20
  %75 = trunc i64 %74 to i32
  store i32 %75, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %84

76:                                               ; preds = %27
  %77 = load i32, ptr %17, align 4, !tbaa !9
  %78 = icmp eq i32 %77, 0
  br i1 %78, label %79, label %80

79:                                               ; preds = %76
  store i32 0, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %84

80:                                               ; preds = %76
  br label %81

81:                                               ; preds = %80, %26
  %82 = load i32, ptr %17, align 4, !tbaa !9
  %83 = load ptr, ptr %13, align 8, !tbaa !5
  store i32 %82, ptr %83, align 4, !tbaa !9
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %84

84:                                               ; preds = %81, %79, %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 136, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 112, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  %85 = load i32, ptr %7, align 4
  ret i32 %85
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind
declare zeroext i8 @lzma_lzma_preset(ptr noundef, i32 noundef) #3

; Function Attrs: nounwind
declare i32 @lzma_alone_encoder(ptr noundef, ptr noundef) #3

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

; Function Attrs: nounwind
declare i32 @lzma_code(ptr noundef, i32 noundef) #3

; 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"", !10, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !6, i64 96, !6, i64 104}
!13 = !{!14, !6, i64 24}
!14 = !{!"", !6, i64 0, !15, i64 8, !15, i64 16, !6, i64 24, !15, i64 32, !15, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !15, i64 96, !15, i64 104, !15, i64 112, !15, i64 120, !10, i64 128, !10, i64 132}
!15 = !{!"long", !7, i64 0}
!16 = !{!14, !15, i64 32}
!17 = !{!14, !6, i64 0}
!18 = !{!14, !15, i64 8}
!19 = !{!7, !7, i64 0}
!20 = !{!14, !15, i64 40}


; 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.lzma_options_lzma = type { i32, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr }
%struct.lzma_stream = type { ptr, i64, i64, ptr, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, i64, i64, i64, i64, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local i32 @lzma_compress(ptr nocapture noundef readnone %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, ptr nocapture noundef writeonly %5) local_unnamed_addr #0 {
  %7 = alloca %struct.lzma_options_lzma, align 8
  %8 = alloca %struct.lzma_stream, align 8
  call void @llvm.lifetime.start.p0(i64 112, ptr nonnull %7) #4
  call void @llvm.lifetime.start.p0(i64 136, ptr nonnull %8) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(136) %8, i8 0, i64 136, i1 false)
  %9 = call zeroext i8 @lzma_lzma_preset(ptr noundef nonnull %7, i32 noundef 5) #4
  store i32 %4, ptr %7, align 8, !tbaa !5
  %10 = call i32 @lzma_alone_encoder(ptr noundef nonnull %8, ptr noundef nonnull %7) #4
  %.not = icmp eq i32 %10, 0
  br i1 %.not, label %12, label %11

11:                                               ; preds = %6
  call void @lzma_end(ptr noundef nonnull %8) #4
  br label %35

12:                                               ; preds = %6
  %13 = getelementptr inbounds i8, ptr %8, i64 24
  store ptr %1, ptr %13, align 8, !tbaa !11
  %14 = sext i32 %4 to i64
  %15 = getelementptr inbounds i8, ptr %8, i64 32
  store i64 %14, ptr %15, align 8, !tbaa !14
  store ptr %2, ptr %8, align 8, !tbaa !15
  %16 = sext i32 %3 to i64
  %17 = getelementptr inbounds i8, ptr %8, i64 8
  store i64 %16, ptr %17, align 8, !tbaa !16
  %18 = call i32 @lzma_code(ptr noundef nonnull %8, i32 noundef 3) #4
  call void @lzma_end(ptr noundef nonnull %8) #4
  switch i32 %18, label %35 [
    i32 1, label %19
    i32 0, label %36
  ]

19:                                               ; preds = %12
  %20 = trunc i32 %3 to i8
  %21 = getelementptr inbounds i8, ptr %1, i64 5
  store i8 %20, ptr %21, align 1, !tbaa !17
  %22 = lshr i32 %3, 8
  %23 = trunc i32 %22 to i8
  %24 = getelementptr inbounds i8, ptr %1, i64 6
  store i8 %23, ptr %24, align 1, !tbaa !17
  %25 = lshr i32 %3, 16
  %26 = trunc i32 %25 to i8
  %27 = getelementptr inbounds i8, ptr %1, i64 7
  store i8 %26, ptr %27, align 1, !tbaa !17
  %28 = lshr i32 %3, 24
  %29 = trunc nuw i32 %28 to i8
  %30 = getelementptr inbounds i8, ptr %1, i64 8
  store i8 %29, ptr %30, align 1, !tbaa !17
  %31 = getelementptr inbounds i8, ptr %1, i64 9
  %32 = getelementptr inbounds i8, ptr %8, i64 40
  store i32 0, ptr %31, align 1
  %33 = load i64, ptr %32, align 8, !tbaa !18
  %34 = trunc i64 %33 to i32
  br label %36

35:                                               ; preds = %12, %11
  %.0 = phi i32 [ %10, %11 ], [ %18, %12 ]
  store i32 %.0, ptr %5, align 4, !tbaa !19
  br label %36

36:                                               ; preds = %12, %35, %19
  %.023 = phi i32 [ -1, %35 ], [ %34, %19 ], [ %18, %12 ]
  call void @llvm.lifetime.end.p0(i64 136, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 112, ptr nonnull %7) #4
  ret i32 %.023
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind
declare zeroext i8 @lzma_lzma_preset(ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare i32 @lzma_alone_encoder(ptr noundef, ptr noundef) local_unnamed_addr #3

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

; Function Attrs: nounwind
declare i32 @lzma_code(ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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, !7, i64 0}
!6 = !{!"", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !7, i64 48, !7, i64 52, !7, i64 56, !7, i64 60, !7, i64 64, !7, i64 68, !7, i64 72, !7, i64 76, !7, i64 80, !7, i64 84, !7, i64 88, !7, i64 92, !10, i64 96, !10, i64 104}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!12, !10, i64 24}
!12 = !{!"", !10, i64 0, !13, i64 8, !13, i64 16, !10, i64 24, !13, i64 32, !13, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !13, i64 96, !13, i64 104, !13, i64 112, !13, i64 120, !7, i64 128, !7, i64 132}
!13 = !{!"long", !8, i64 0}
!14 = !{!12, !13, i64 32}
!15 = !{!12, !10, i64 0}
!16 = !{!12, !13, i64 8}
!17 = !{!8, !8, i64 0}
!18 = !{!12, !13, i64 40}
!19 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass