; LLVM IR from mncoppola/rpef :: utilities_src/squashfs2.1/lzma/C/7zip/Compress/LZMA_Alone (LzmaRamDecode)

; 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._CLzmaDecoderState = type { %struct._CLzmaProperties, ptr }
%struct._CLzmaProperties = type { i32, i32, i32 }

; 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: nounwind uwtable
define dso_local i32 @LzmaRamDecompress(ptr noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #1 {
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca %struct._CLzmaDecoderState, align 8
  %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
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store i64 %1, ptr %10, align 8, !tbaa !9
  store ptr %2, ptr %11, align 8, !tbaa !5
  store i64 %3, ptr %12, align 8, !tbaa !9
  store ptr %4, ptr %13, align 8, !tbaa !5
  store ptr %5, ptr %14, align 8, !tbaa !5
  store ptr %6, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  %24 = load i64, ptr %10, align 8, !tbaa !9
  %25 = icmp ult i64 %24, 14
  br i1 %25, label %26, label %27

26:                                               ; preds = %7
  store i32 1, ptr %8, align 4
  store i32 1, ptr %21, align 4
  br label %89

27:                                               ; preds = %7
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %28, i64 0
  %30 = load i8, ptr %29, align 1, !tbaa !11
  %31 = zext i8 %30 to i32
  store i32 %31, ptr %20, align 4, !tbaa !12
  %32 = load ptr, ptr %13, align 8, !tbaa !5
  store i64 0, ptr %32, align 8, !tbaa !9
  %33 = load i32, ptr %20, align 4, !tbaa !12
  %34 = icmp sgt i32 %33, 1
  br i1 %34, label %35, label %36

35:                                               ; preds = %27
  store i32 1, ptr %8, align 4
  store i32 1, ptr %21, align 4
  br label %89

36:                                               ; preds = %27
  %37 = getelementptr inbounds %struct._CLzmaDecoderState, ptr %16, i32 0, i32 0
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %38, i64 1
  %40 = call i32 @LzmaDecodeProperties(ptr noundef %37, ptr noundef %39, i32 noundef 5)
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %42, label %43

42:                                               ; preds = %36
  store i32 1, ptr %8, align 4
  store i32 1, ptr %21, align 4
  br label %89

43:                                               ; preds = %36
  %44 = load ptr, ptr %14, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._CLzmaDecoderState, ptr %16, i32 0, i32 0
  %46 = getelementptr inbounds %struct._CLzmaProperties, ptr %45, i32 0, i32 0
  %47 = load i32, ptr %46, align 8, !tbaa !14
  %48 = getelementptr inbounds %struct._CLzmaDecoderState, ptr %16, i32 0, i32 0
  %49 = getelementptr inbounds %struct._CLzmaProperties, ptr %48, i32 0, i32 1
  %50 = load i32, ptr %49, align 4, !tbaa !17
  %51 = add nsw i32 %47, %50
  %52 = shl i32 768, %51
  %53 = add nsw i32 1846, %52
  %54 = sext i32 %53 to i64
  %55 = mul i64 %54, 2
  %56 = call ptr %44(i64 noundef %55)
  %57 = getelementptr inbounds %struct._CLzmaDecoderState, ptr %16, i32 0, i32 1
  store ptr %56, ptr %57, align 8, !tbaa !18
  %58 = getelementptr inbounds %struct._CLzmaDecoderState, ptr %16, i32 0, i32 1
  %59 = load ptr, ptr %58, align 8, !tbaa !18
  %60 = icmp eq ptr %59, null
  br i1 %60, label %61, label %62

61:                                               ; preds = %43
  store i32 2, ptr %8, align 4
  store i32 1, ptr %21, align 4
  br label %89

62:                                               ; preds = %43
  %63 = load ptr, ptr %9, align 8, !tbaa !5
  %64 = getelementptr inbounds i8, ptr %63, i64 14
  %65 = load i64, ptr %10, align 8, !tbaa !9
  %66 = trunc i64 %65 to i32
  %67 = sub i32 %66, 14
  %68 = load ptr, ptr %11, align 8, !tbaa !5
  %69 = load i64, ptr %12, align 8, !tbaa !9
  %70 = trunc i64 %69 to i32
  %71 = call i32 @LzmaDecode(ptr noundef %16, ptr noundef %64, i32 noundef %67, ptr noundef %19, ptr noundef %68, i32 noundef %70, ptr noundef %18)
  store i32 %71, ptr %17, align 4, !tbaa !12
  %72 = load ptr, ptr %15, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct._CLzmaDecoderState, ptr %16, i32 0, i32 1
  %74 = load ptr, ptr %73, align 8, !tbaa !18
  call void %72(ptr noundef %74)
  %75 = load i32, ptr %17, align 4, !tbaa !12
  %76 = icmp ne i32 %75, 0
  br i1 %76, label %77, label %78

77:                                               ; preds = %62
  store i32 1, ptr %8, align 4
  store i32 1, ptr %21, align 4
  br label %89

78:                                               ; preds = %62
  %79 = load i32, ptr %18, align 4, !tbaa !12
  %80 = zext i32 %79 to i64
  %81 = load ptr, ptr %13, align 8, !tbaa !5
  store i64 %80, ptr %81, align 8, !tbaa !9
  %82 = load i32, ptr %20, align 4, !tbaa !12
  %83 = icmp eq i32 %82, 1
  br i1 %83, label %84, label %88

84:                                               ; preds = %78
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #3
  store i32 0, ptr %22, align 4, !tbaa !12
  store i32 -5, ptr %23, align 4, !tbaa !12
  %85 = load ptr, ptr %11, align 8, !tbaa !5
  %86 = load i32, ptr %18, align 4, !tbaa !12
  %87 = call i32 @x86_Convert(ptr noundef %85, i32 noundef %86, i32 noundef 0, ptr noundef %22, ptr noundef %23, i32 noundef 0)
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  br label %88

88:                                               ; preds = %84, %78
  store i32 0, ptr %8, align 4
  store i32 1, ptr %21, align 4
  br label %89

89:                                               ; preds = %88, %77, %61, %42, %35, %26
  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 24, ptr %16) #3
  %90 = load i32, ptr %8, align 4
  ret i32 %90
}

declare i32 @LzmaDecodeProperties(ptr noundef, ptr noundef, i32 noundef) #2

declare i32 @LzmaDecode(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

declare i32 @x86_Convert(ptr noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !13, i64 0}
!15 = !{!"_CLzmaDecoderState", !16, i64 0, !6, i64 16}
!16 = !{!"_CLzmaProperties", !13, i64 0, !13, i64 4, !13, i64 8}
!17 = !{!15, !13, i64 4}
!18 = !{!15, !6, 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"

%struct._CLzmaDecoderState = type { %struct._CLzmaProperties, ptr }
%struct._CLzmaProperties = type { i32, i32, i32 }

; 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: nounwind uwtable
define dso_local range(i32 0, 3) i32 @LzmaRamDecompress(ptr noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3, ptr nocapture noundef writeonly %4, ptr nocapture noundef readonly %5, ptr nocapture noundef readonly %6) local_unnamed_addr #1 {
  %8 = alloca %struct._CLzmaDecoderState, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #3
  %13 = icmp ult i64 %1, 14
  br i1 %13, label %45, label %14

14:                                               ; preds = %7
  %15 = load i8, ptr %0, align 1, !tbaa !5
  store i64 0, ptr %4, align 8, !tbaa !8
  %16 = icmp ugt i8 %15, 1
  br i1 %16, label %45, label %17

17:                                               ; preds = %14
  %18 = getelementptr inbounds i8, ptr %0, i64 1
  %19 = call i32 @LzmaDecodeProperties(ptr noundef nonnull %8, ptr noundef nonnull %18, i32 noundef 5) #3
  %.not = icmp eq i32 %19, 0
  br i1 %.not, label %20, label %45

20:                                               ; preds = %17
  %21 = load i32, ptr %8, align 8, !tbaa !10
  %22 = getelementptr inbounds i8, ptr %8, i64 4
  %23 = load i32, ptr %22, align 4, !tbaa !15
  %24 = add nsw i32 %23, %21
  %25 = shl i32 768, %24
  %26 = add nuw nsw i32 %25, 1846
  %27 = sext i32 %26 to i64
  %28 = shl nsw i64 %27, 1
  %29 = call ptr %5(i64 noundef %28) #3
  %30 = getelementptr inbounds i8, ptr %8, i64 16
  store ptr %29, ptr %30, align 8, !tbaa !16
  %31 = icmp eq ptr %29, null
  br i1 %31, label %45, label %32

32:                                               ; preds = %20
  %33 = getelementptr inbounds i8, ptr %0, i64 14
  %34 = trunc i64 %1 to i32
  %35 = add i32 %34, -14
  %36 = trunc i64 %3 to i32
  %37 = call i32 @LzmaDecode(ptr noundef nonnull %8, ptr noundef nonnull %33, i32 noundef %35, ptr noundef nonnull %10, ptr noundef %2, i32 noundef %36, ptr noundef nonnull %9) #3
  %38 = load ptr, ptr %30, align 8, !tbaa !16
  call void %6(ptr noundef %38) #3
  %.not17 = icmp eq i32 %37, 0
  br i1 %.not17, label %39, label %45

39:                                               ; preds = %32
  %40 = load i32, ptr %9, align 4, !tbaa !17
  %41 = zext i32 %40 to i64
  store i64 %41, ptr %4, align 8, !tbaa !8
  %42 = icmp eq i8 %15, 1
  br i1 %42, label %43, label %45

43:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %12) #3
  store i32 0, ptr %11, align 4, !tbaa !17
  store i32 -5, ptr %12, align 4, !tbaa !17
  %44 = call i32 @x86_Convert(ptr noundef %2, i32 noundef %40, i32 noundef 0, ptr noundef nonnull %11, ptr noundef nonnull %12, i32 noundef 0) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #3
  br label %45

45:                                               ; preds = %39, %43, %32, %20, %17, %14, %7
  %.0 = phi i32 [ 1, %7 ], [ 1, %14 ], [ 1, %17 ], [ 2, %20 ], [ 1, %32 ], [ 0, %43 ], [ 0, %39 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #3
  ret i32 %.0
}

declare i32 @LzmaDecodeProperties(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare i32 @LzmaDecode(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

declare i32 @x86_Convert(ptr noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long", !6, i64 0}
!10 = !{!11, !13, i64 0}
!11 = !{!"_CLzmaDecoderState", !12, i64 0, !14, i64 16}
!12 = !{!"_CLzmaProperties", !13, i64 0, !13, i64 4, !13, i64 8}
!13 = !{!"int", !6, i64 0}
!14 = !{!"any pointer", !6, i64 0}
!15 = !{!11, !13, i64 4}
!16 = !{!11, !14, i64 16}
!17 = !{!13, !13, i64 0}


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