; LLVM IR from SSBMTonberry/pocketlzma :: ref_spec/lzma1900/CPP/7zip/Compress (LzmaEncoder)

; 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._CLzmaEncProps = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i64 }
%struct.tagPROPVARIANT = type { i16, i16, i16, i16, %union.anon }
%union.anon = type { %struct._LARGE_INTEGER }
%struct._LARGE_INTEGER = type { i64 }
%"class.NCompress::NLzma::CEncoder" = type { %struct.ICompressCoder, %struct.ICompressSetCoderProperties, %struct.ICompressWriteCoderProperties, %struct.ICompressSetCoderPropertiesOpt, %class.CMyUnknownImp, ptr, i64 }
%struct.ICompressCoder = type { %struct.IUnknown }
%struct.IUnknown = type { ptr }
%struct.ICompressSetCoderProperties = type { %struct.IUnknown }
%struct.ICompressWriteCoderProperties = type { %struct.IUnknown }
%struct.ICompressSetCoderPropertiesOpt = type { %struct.IUnknown }
%class.CMyUnknownImp = type { i32 }

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN9NCompress5NLzma11SetLzmaPropEjRK14tagPROPVARIANTR14_CLzmaEncProps(i32 noundef, ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(56)) #0

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN9NCompress5NLzma8CEncoder18SetCoderPropertiesEPKjPK14tagPROPVARIANTj(ptr noundef nonnull align 8 dereferenceable(56) %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) unnamed_addr #0 align 2 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca %struct._CLzmaEncProps, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = 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 i32 %3, ptr %9, align 4, !tbaa !9
  %16 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 56, ptr %10) #4
  call void @LzmaEncProps_Init(ptr noundef %10)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %64, %4
  %18 = load i32, ptr %11, align 4, !tbaa !9
  %19 = load i32, ptr %9, align 4, !tbaa !9
  %20 = icmp ult i32 %18, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %17
  store i32 2, ptr %12, align 4
  br label %67

22:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = load i32, ptr %11, align 4, !tbaa !9
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds %struct.tagPROPVARIANT, ptr %23, i64 %25
  store ptr %26, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = load i32, ptr %11, align 4, !tbaa !9
  %29 = zext i32 %28 to i64
  %30 = getelementptr inbounds i32, ptr %27, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !9
  store i32 %31, ptr %14, align 4, !tbaa !9
  %32 = load i32, ptr %14, align 4, !tbaa !9
  switch i32 %32, label %48 [
    i32 14, label %33
  ]

33:                                               ; preds = %22
  %34 = load ptr, ptr %13, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.tagPROPVARIANT, ptr %34, i32 0, i32 0
  %36 = load i16, ptr %35, align 8, !tbaa !11
  %37 = zext i16 %36 to i32
  %38 = icmp ne i32 %37, 11
  br i1 %38, label %39, label %40

39:                                               ; preds = %33
  store i32 -2147024809, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %61

40:                                               ; preds = %33
  %41 = load ptr, ptr %13, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.tagPROPVARIANT, ptr %41, i32 0, i32 4
  %43 = load i16, ptr %42, align 8, !tbaa !14
  %44 = sext i16 %43 to i32
  %45 = icmp ne i32 %44, 0
  %46 = zext i1 %45 to i32
  %47 = getelementptr inbounds %struct._CLzmaEncProps, ptr %10, i32 0, i32 10
  store i32 %46, ptr %47, align 8, !tbaa !15
  br label %60

48:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %49 = load i32, ptr %14, align 4, !tbaa !9
  %50 = load ptr, ptr %13, align 8, !tbaa !5
  %51 = call noundef i32 @_ZN9NCompress5NLzma11SetLzmaPropEjRK14tagPROPVARIANTR14_CLzmaEncProps(i32 noundef %49, ptr noundef nonnull align 8 dereferenceable(16) %50, ptr noundef nonnull align 8 dereferenceable(56) %10)
  store i32 %51, ptr %15, align 4, !tbaa !9
  %52 = load i32, ptr %15, align 4, !tbaa !9
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %54, label %56

54:                                               ; preds = %48
  %55 = load i32, ptr %15, align 4, !tbaa !9
  store i32 %55, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %57

56:                                               ; preds = %48
  store i32 0, ptr %12, align 4
  br label %57

57:                                               ; preds = %56, %54
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  %58 = load i32, ptr %12, align 4
  switch i32 %58, label %61 [
    i32 0, label %59
  ]

59:                                               ; preds = %57
  br label %60

60:                                               ; preds = %59, %40
  store i32 0, ptr %12, align 4
  br label %61

61:                                               ; preds = %60, %57, %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  %62 = load i32, ptr %12, align 4
  switch i32 %62, label %67 [
    i32 0, label %63
  ]

63:                                               ; preds = %61
  br label %64

64:                                               ; preds = %63
  %65 = load i32, ptr %11, align 4, !tbaa !9
  %66 = add i32 %65, 1
  store i32 %66, ptr %11, align 4, !tbaa !9
  br label %17, !llvm.loop !18

67:                                               ; preds = %61, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  %68 = load i32, ptr %12, align 4
  switch i32 %68, label %74 [
    i32 2, label %69
  ]

69:                                               ; preds = %67
  %70 = getelementptr inbounds %"class.NCompress::NLzma::CEncoder", ptr %16, i32 0, i32 5
  %71 = load ptr, ptr %70, align 8, !tbaa !20
  %72 = call i32 @LzmaEnc_SetProps(ptr noundef %71, ptr noundef %10)
  %73 = call noundef i32 @_Z13SResToHRESULTi(i32 noundef %72) #4
  store i32 %73, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %74

74:                                               ; preds = %69, %67
  call void @llvm.lifetime.end.p0(i64 56, ptr %10) #4
  %75 = load i32, ptr %5, align 4
  ret i32 %75
}

declare void @LzmaEncProps_Init(ptr noundef) #2

; Function Attrs: nounwind
declare noundef i32 @_Z13SResToHRESULTi(i32 noundef) #3

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

attributes #0 = { 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 #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 "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 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTS14tagPROPVARIANT", !13, i64 0, !13, i64 2, !13, i64 4, !13, i64 6, !7, i64 8}
!13 = !{!"short", !7, i64 0}
!14 = !{!7, !7, i64 0}
!15 = !{!16, !10, i64 40}
!16 = !{!"_ZTS14_CLzmaEncProps", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !17, i64 48}
!17 = !{!"long long", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!21, !6, i64 40}
!21 = !{!"_ZTSN9NCompress5NLzma8CEncoderE", !22, i64 0, !24, i64 8, !25, i64 16, !26, i64 24, !27, i64 32, !6, i64 40, !17, i64 48}
!22 = !{!"_ZTS14ICompressCoder", !23, i64 0}
!23 = !{!"_ZTS8IUnknown"}
!24 = !{!"_ZTS27ICompressSetCoderProperties", !23, i64 0}
!25 = !{!"_ZTS29ICompressWriteCoderProperties", !23, i64 0}
!26 = !{!"_ZTS30ICompressSetCoderPropertiesOpt", !23, i64 0}
!27 = !{!"_ZTS13CMyUnknownImp", !10, i64 0}


; 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._CLzmaEncProps = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i64 }
%struct.tagPROPVARIANT = type { i16, i16, i16, i16, %union.anon }
%union.anon = type { %struct._LARGE_INTEGER }
%struct._LARGE_INTEGER = type { i64 }

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN9NCompress5NLzma11SetLzmaPropEjRK14tagPROPVARIANTR14_CLzmaEncProps(i32 noundef, ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(56)) local_unnamed_addr #0

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN9NCompress5NLzma8CEncoder18SetCoderPropertiesEPKjPK14tagPROPVARIANTj(ptr nocapture noundef nonnull readonly align 8 dereferenceable(56) %0, ptr nocapture noundef readonly %1, ptr noundef %2, i32 noundef %3) unnamed_addr #0 align 2 {
  %5 = alloca %struct._CLzmaEncProps, align 8
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %5) #4
  call void @LzmaEncProps_Init(ptr noundef nonnull %5)
  %.not2837.not = icmp eq i32 %3, 0
  br i1 %.not2837.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4
  %6 = getelementptr inbounds i8, ptr %5, i64 40
  %wide.trip.count = zext i32 %3 to i64
  br label %7

7:                                                ; preds = %.lr.ph, %19
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %19 ]
  %8 = getelementptr inbounds %struct.tagPROPVARIANT, ptr %2, i64 %indvars.iv
  %9 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %cond1 = icmp eq i32 %10, 14
  br i1 %cond1, label %11, label %17

11:                                               ; preds = %7
  %12 = load i16, ptr %8, align 8, !tbaa !9
  %.not27 = icmp eq i16 %12, 11
  br i1 %.not27, label %.thread, label %.thread35

.thread:                                          ; preds = %11
  %13 = getelementptr inbounds i8, ptr %8, i64 8
  %14 = load i16, ptr %13, align 8, !tbaa !12
  %15 = icmp ne i16 %14, 0
  %16 = zext i1 %15 to i32
  store i32 %16, ptr %6, align 8, !tbaa !13
  br label %19

17:                                               ; preds = %7
  %18 = call noundef i32 @_ZN9NCompress5NLzma11SetLzmaPropEjRK14tagPROPVARIANTR14_CLzmaEncProps(i32 noundef %10, ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef nonnull align 8 dereferenceable(56) %5)
  %.not = icmp eq i32 %18, 0
  br i1 %.not, label %19, label %.thread35

19:                                               ; preds = %.thread, %17
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %7, !llvm.loop !16

._crit_edge:                                      ; preds = %19, %4
  %20 = getelementptr inbounds i8, ptr %0, i64 40
  %21 = load ptr, ptr %20, align 8, !tbaa !18
  %22 = call i32 @LzmaEnc_SetProps(ptr noundef %21, ptr noundef nonnull %5)
  %23 = call noundef i32 @_Z13SResToHRESULTi(i32 noundef %22) #4
  br label %.thread35

.thread35:                                        ; preds = %11, %17, %._crit_edge
  %.5 = phi i32 [ %23, %._crit_edge ], [ -2147024809, %11 ], [ %18, %17 ]
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %5) #4
  ret i32 %.5
}

declare void @LzmaEncProps_Init(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare noundef i32 @_Z13SResToHRESULTi(i32 noundef) local_unnamed_addr #3

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

attributes #0 = { 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 #1 = { mustprogress 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 "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTS14tagPROPVARIANT", !11, i64 0, !11, i64 2, !11, i64 4, !11, i64 6, !7, i64 8}
!11 = !{!"short", !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !6, i64 40}
!14 = !{!"_ZTS14_CLzmaEncProps", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 40, !6, i64 44, !15, i64 48}
!15 = !{!"long long", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!19, !26, i64 40}
!19 = !{!"_ZTSN9NCompress5NLzma8CEncoderE", !20, i64 0, !22, i64 8, !23, i64 16, !24, i64 24, !25, i64 32, !26, i64 40, !15, i64 48}
!20 = !{!"_ZTS14ICompressCoder", !21, i64 0}
!21 = !{!"_ZTS8IUnknown"}
!22 = !{!"_ZTS27ICompressSetCoderProperties", !21, i64 0}
!23 = !{!"_ZTS29ICompressWriteCoderProperties", !21, i64 0}
!24 = !{!"_ZTS30ICompressSetCoderPropertiesOpt", !21, i64 0}
!25 = !{!"_ZTS13CMyUnknownImp", !6, i64 0}
!26 = !{!"any pointer", !7, i64 0}


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