; LLVM IR from Iotic-Labs/py-lz4framed :: lz4 (lz4frame)

; 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.LZ4F_cctx_s = type { %struct.LZ4F_preferences_t, i32, i32, ptr, i64, i64, ptr, ptr, i64, i64, %struct.XXH32_state_s, ptr, i16, i16 }
%struct.LZ4F_preferences_t = type { %struct.LZ4F_frameInfo_t, i32, i32, i32, [3 x i32] }
%struct.LZ4F_frameInfo_t = type { i32, i32, i32, i32, i64, i32, i32 }
%struct.XXH32_state_s = type { i32, i32, i32, i32, i32, i32, [4 x i32], i32, i32 }
%union.LZ4_stream_u = type { [2052 x 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; 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
declare dso_local i64 @LZ4F_compressFrame_usingCDict(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i64 @LZ4F_compressFrame(ptr noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4) #2 {
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca %struct.LZ4F_cctx_s, align 8
  %13 = alloca %union.LZ4_stream_u, align 8
  %14 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i64 %1, ptr %7, align 8, !tbaa !9
  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) #5
  call void @llvm.lifetime.start.p0(i64 184, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 16416, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  store ptr %12, ptr %14, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %12, i8 0, i64 184, i1 false)
  %15 = getelementptr inbounds %struct.LZ4F_cctx_s, ptr %12, i32 0, i32 1
  store i32 100, ptr %15, align 8, !tbaa !11
  %16 = getelementptr inbounds %struct.LZ4F_cctx_s, ptr %12, i32 0, i32 5
  store i64 5242880, ptr %16, align 8, !tbaa !19
  %17 = load ptr, ptr %10, align 8, !tbaa !5
  %18 = icmp eq ptr %17, null
  br i1 %18, label %24, label %19

19:                                               ; preds = %5
  %20 = load ptr, ptr %10, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.LZ4F_preferences_t, ptr %20, i32 0, i32 1
  %22 = load i32, ptr %21, align 8, !tbaa !20
  %23 = icmp slt i32 %22, 3
  br i1 %23, label %24, label %32

24:                                               ; preds = %19, %5
  %25 = call ptr @LZ4_initStream(ptr noundef %13, i64 noundef 16416)
  %26 = load ptr, ptr %14, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.LZ4F_cctx_s, ptr %26, i32 0, i32 11
  store ptr %13, ptr %27, align 8, !tbaa !21
  %28 = load ptr, ptr %14, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.LZ4F_cctx_s, ptr %28, i32 0, i32 12
  store i16 1, ptr %29, align 8, !tbaa !22
  %30 = load ptr, ptr %14, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.LZ4F_cctx_s, ptr %30, i32 0, i32 13
  store i16 1, ptr %31, align 2, !tbaa !23
  br label %32

32:                                               ; preds = %24, %19
  %33 = load ptr, ptr %14, align 8, !tbaa !5
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = load i64, ptr %7, align 8, !tbaa !9
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = load i64, ptr %9, align 8, !tbaa !9
  %38 = load ptr, ptr %10, align 8, !tbaa !5
  %39 = call i64 @LZ4F_compressFrame_usingCDict(ptr noundef %33, ptr noundef %34, i64 noundef %35, ptr noundef %36, i64 noundef %37, ptr noundef null, ptr noundef %38)
  store i64 %39, ptr %11, align 8, !tbaa !9
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = icmp ne ptr %40, null
  br i1 %41, label %42, label %51

42:                                               ; preds = %32
  %43 = load ptr, ptr %10, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.LZ4F_preferences_t, ptr %43, i32 0, i32 1
  %45 = load i32, ptr %44, align 8, !tbaa !20
  %46 = icmp sge i32 %45, 3
  br i1 %46, label %47, label %51

47:                                               ; preds = %42
  %48 = load ptr, ptr %14, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.LZ4F_cctx_s, ptr %48, i32 0, i32 11
  %50 = load ptr, ptr %49, align 8, !tbaa !21
  call void @free(ptr noundef %50) #5
  br label %51

51:                                               ; preds = %47, %42, %32
  %52 = load i64, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 16416, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 184, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  ret i64 %52
}

declare ptr @LZ4_initStream(ptr noundef, i64 noundef) #3

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 #3 = { "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 "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 #5 = { 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 = !{!12, !15, i64 56}
!12 = !{!"LZ4F_cctx_s", !13, i64 0, !15, i64 56, !15, i64 60, !6, i64 64, !10, i64 72, !10, i64 80, !6, i64 88, !6, i64 96, !10, i64 104, !10, i64 112, !17, i64 120, !6, i64 168, !18, i64 176, !18, i64 178}
!13 = !{!"", !14, i64 0, !15, i64 32, !15, i64 36, !15, i64 40, !7, i64 44}
!14 = !{!"", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12, !16, i64 16, !15, i64 24, !15, i64 28}
!15 = !{!"int", !7, i64 0}
!16 = !{!"long long", !7, i64 0}
!17 = !{!"XXH32_state_s", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12, !15, i64 16, !15, i64 20, !7, i64 24, !15, i64 40, !15, i64 44}
!18 = !{!"short", !7, i64 0}
!19 = !{!12, !10, i64 80}
!20 = !{!13, !15, i64 32}
!21 = !{!12, !6, i64 168}
!22 = !{!12, !18, i64 176}
!23 = !{!12, !18, i64 178}


; 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.LZ4F_cctx_s = type { %struct.LZ4F_preferences_t, i32, i32, ptr, i64, i64, ptr, ptr, i64, i64, %struct.XXH32_state_s, ptr, i16, i16 }
%struct.LZ4F_preferences_t = type { %struct.LZ4F_frameInfo_t, i32, i32, i32, [3 x i32] }
%struct.LZ4F_frameInfo_t = type { i32, i32, i32, i32, i64, i32, i32 }
%struct.XXH32_state_s = type { i32, i32, i32, i32, i32, i32, [4 x i32], i32, i32 }
%union.LZ4_stream_u = type { [2052 x 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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: nounwind uwtable
declare dso_local i64 @LZ4F_compressFrame_usingCDict(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local i64 @LZ4F_compressFrame(ptr noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4) local_unnamed_addr #2 {
  %6 = alloca %struct.LZ4F_cctx_s, align 8
  %7 = alloca %union.LZ4_stream_u, align 8
  call void @llvm.lifetime.start.p0(i64 184, ptr nonnull %6) #5
  call void @llvm.lifetime.start.p0(i64 16416, ptr nonnull %7) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(184) %6, i8 0, i64 184, i1 false)
  %8 = getelementptr inbounds i8, ptr %6, i64 56
  store i32 100, ptr %8, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %6, i64 80
  store i64 5242880, ptr %9, align 8, !tbaa !17
  %10 = icmp eq ptr %4, null
  br i1 %10, label %16, label %11

11:                                               ; preds = %5
  %12 = getelementptr inbounds i8, ptr %4, i64 32
  %13 = load i32, ptr %12, align 8, !tbaa !18
  %14 = icmp slt i32 %13, 3
  br i1 %14, label %16, label %.thread

.thread:                                          ; preds = %11
  %15 = call i64 @LZ4F_compressFrame_usingCDict(ptr noundef nonnull %6, ptr noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef null, ptr noundef nonnull %4)
  br label %22

16:                                               ; preds = %5, %11
  %17 = call ptr @LZ4_initStream(ptr noundef nonnull %7, i64 noundef 16416) #5
  %18 = getelementptr inbounds i8, ptr %6, i64 168
  store ptr %7, ptr %18, align 8, !tbaa !19
  %19 = getelementptr inbounds i8, ptr %6, i64 176
  store i16 1, ptr %19, align 8, !tbaa !20
  %20 = getelementptr inbounds i8, ptr %6, i64 178
  store i16 1, ptr %20, align 2, !tbaa !21
  %21 = call i64 @LZ4F_compressFrame_usingCDict(ptr noundef nonnull %6, ptr noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef null, ptr noundef %4)
  br i1 %10, label %30, label %22

22:                                               ; preds = %.thread, %16
  %23 = phi i64 [ %15, %.thread ], [ %21, %16 ]
  %24 = getelementptr inbounds i8, ptr %4, i64 32
  %25 = load i32, ptr %24, align 8, !tbaa !18
  %26 = icmp sgt i32 %25, 2
  br i1 %26, label %27, label %30

27:                                               ; preds = %22
  %28 = getelementptr inbounds i8, ptr %6, i64 168
  %29 = load ptr, ptr %28, align 8, !tbaa !19
  call void @free(ptr noundef %29) #5
  br label %30

30:                                               ; preds = %27, %22, %16
  %31 = phi i64 [ %23, %27 ], [ %23, %22 ], [ %21, %16 ]
  call void @llvm.lifetime.end.p0(i64 16416, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 184, ptr nonnull %6) #5
  ret i64 %31
}

declare ptr @LZ4_initStream(ptr noundef, i64 noundef) local_unnamed_addr #3

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 #3 = { "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 = { 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 #5 = { 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, !9, i64 56}
!6 = !{!"LZ4F_cctx_s", !7, i64 0, !9, i64 56, !9, i64 60, !13, i64 64, !14, i64 72, !14, i64 80, !13, i64 88, !13, i64 96, !14, i64 104, !14, i64 112, !15, i64 120, !13, i64 168, !16, i64 176, !16, i64 178}
!7 = !{!"", !8, i64 0, !9, i64 32, !9, i64 36, !9, i64 40, !10, i64 44}
!8 = !{!"", !9, i64 0, !9, i64 4, !9, i64 8, !9, i64 12, !12, i64 16, !9, i64 24, !9, i64 28}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!"long long", !10, i64 0}
!13 = !{!"any pointer", !10, i64 0}
!14 = !{!"long", !10, i64 0}
!15 = !{!"XXH32_state_s", !9, i64 0, !9, i64 4, !9, i64 8, !9, i64 12, !9, i64 16, !9, i64 20, !10, i64 24, !9, i64 40, !9, i64 44}
!16 = !{!"short", !10, i64 0}
!17 = !{!6, !14, i64 80}
!18 = !{!7, !9, i64 32}
!19 = !{!6, !13, i64 168}
!20 = !{!6, !16, i64 176}
!21 = !{!6, !16, i64 178}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass