; LLVM IR from jgaeddert/liquid-dsp :: src/framing/src (framingcf)

; 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.div_t = type { i32, i32 }
%struct.qpacketmodem_s = type { ptr, ptr, i32, i32, ptr, ptr, i32, i32, i32, i32, float }

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(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: nounwind uwtable
define dso_local ptr @qpacketmodem_create() #2 {
  %1 = alloca ptr, align 8
  %2 = alloca %struct.div_t, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #5
  %3 = call noalias ptr @malloc(i64 noundef 64) #6
  store ptr %3, ptr %1, align 8, !tbaa !5
  %4 = call ptr @modemcf_create(i32 noundef 40)
  %5 = load ptr, ptr %1, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.qpacketmodem_s, ptr %5, i32 0, i32 0
  store ptr %4, ptr %6, align 8, !tbaa !9
  %7 = load ptr, ptr %1, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.qpacketmodem_s, ptr %7, i32 0, i32 2
  store i32 2, ptr %8, align 8, !tbaa !13
  %9 = load ptr, ptr %1, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.qpacketmodem_s, ptr %9, i32 0, i32 3
  store i32 1, ptr %10, align 4, !tbaa !14
  %11 = load ptr, ptr %1, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.qpacketmodem_s, ptr %11, i32 0, i32 3
  %13 = load i32, ptr %12, align 4, !tbaa !14
  %14 = call ptr @packetizer_create(i32 noundef %13, i32 noundef 1, i32 noundef 1, i32 noundef 1)
  %15 = load ptr, ptr %1, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.qpacketmodem_s, ptr %15, i32 0, i32 1
  store ptr %14, ptr %16, align 8, !tbaa !15
  %17 = load ptr, ptr %1, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.qpacketmodem_s, ptr %17, i32 0, i32 1
  %19 = load ptr, ptr %18, align 8, !tbaa !15
  %20 = call i32 @packetizer_get_enc_msg_len(ptr noundef %19)
  %21 = load ptr, ptr %1, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.qpacketmodem_s, ptr %21, i32 0, i32 6
  store i32 %20, ptr %22, align 8, !tbaa !16
  %23 = load ptr, ptr %1, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.qpacketmodem_s, ptr %23, i32 0, i32 6
  %25 = load i32, ptr %24, align 8, !tbaa !16
  %26 = mul i32 8, %25
  %27 = load ptr, ptr %1, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.qpacketmodem_s, ptr %27, i32 0, i32 7
  store i32 %26, ptr %28, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  %29 = load ptr, ptr %1, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.qpacketmodem_s, ptr %29, i32 0, i32 7
  %31 = load i32, ptr %30, align 4, !tbaa !17
  %32 = load ptr, ptr %1, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.qpacketmodem_s, ptr %32, i32 0, i32 2
  %34 = load i32, ptr %33, align 8, !tbaa !13
  %35 = call i64 @div(i32 noundef %31, i32 noundef %34) #7
  store i64 %35, ptr %2, align 4
  %36 = getelementptr inbounds %struct.div_t, ptr %2, i32 0, i32 0
  %37 = load i32, ptr %36, align 4, !tbaa !18
  %38 = getelementptr inbounds %struct.div_t, ptr %2, i32 0, i32 1
  %39 = load i32, ptr %38, align 4, !tbaa !20
  %40 = icmp ne i32 %39, 0
  %41 = zext i1 %40 to i64
  %42 = select i1 %40, i32 1, i32 0
  %43 = add nsw i32 %37, %42
  %44 = load ptr, ptr %1, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.qpacketmodem_s, ptr %44, i32 0, i32 8
  store i32 %43, ptr %45, align 8, !tbaa !21
  %46 = load ptr, ptr %1, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.qpacketmodem_s, ptr %46, i32 0, i32 2
  %48 = load i32, ptr %47, align 8, !tbaa !13
  %49 = load ptr, ptr %1, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.qpacketmodem_s, ptr %49, i32 0, i32 8
  %51 = load i32, ptr %50, align 8, !tbaa !21
  %52 = mul i32 %48, %51
  %53 = zext i32 %52 to i64
  %54 = mul i64 %53, 1
  %55 = call noalias ptr @malloc(i64 noundef %54) #6
  %56 = load ptr, ptr %1, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.qpacketmodem_s, ptr %56, i32 0, i32 4
  store ptr %55, ptr %57, align 8, !tbaa !22
  %58 = load ptr, ptr %1, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.qpacketmodem_s, ptr %58, i32 0, i32 6
  %60 = load i32, ptr %59, align 8, !tbaa !16
  %61 = load ptr, ptr %1, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.qpacketmodem_s, ptr %61, i32 0, i32 2
  %63 = load i32, ptr %62, align 8, !tbaa !13
  %64 = mul i32 %60, %63
  %65 = load ptr, ptr %1, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.qpacketmodem_s, ptr %65, i32 0, i32 8
  store i32 %64, ptr %66, align 8, !tbaa !21
  %67 = load ptr, ptr %1, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.qpacketmodem_s, ptr %67, i32 0, i32 8
  %69 = load i32, ptr %68, align 8, !tbaa !21
  %70 = zext i32 %69 to i64
  %71 = mul i64 %70, 1
  %72 = call noalias ptr @malloc(i64 noundef %71) #6
  %73 = load ptr, ptr %1, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.qpacketmodem_s, ptr %73, i32 0, i32 5
  store ptr %72, ptr %74, align 8, !tbaa !23
  %75 = load ptr, ptr %1, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.qpacketmodem_s, ptr %75, i32 0, i32 9
  store i32 0, ptr %76, align 4, !tbaa !24
  %77 = load ptr, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #5
  ret ptr %77
}

declare ptr @modemcf_create(i32 noundef) #3

declare ptr @packetizer_create(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #3

declare i32 @packetizer_get_enc_msg_len(ptr noundef) #3

; Function Attrs: nounwind willreturn memory(none)
declare i64 @div(i32 noundef, i32 noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(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 = { 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 willreturn memory(none) "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 }
attributes #6 = { nounwind allocsize(0) }
attributes #7 = { nounwind willreturn memory(none) }

!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, !6, i64 0}
!10 = !{!"qpacketmodem_s", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !6, i64 24, !6, i64 32, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !12, i64 56}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!10, !11, i64 16}
!14 = !{!10, !11, i64 20}
!15 = !{!10, !6, i64 8}
!16 = !{!10, !11, i64 40}
!17 = !{!10, !11, i64 44}
!18 = !{!19, !11, i64 0}
!19 = !{!"", !11, i64 0, !11, i64 4}
!20 = !{!19, !11, i64 4}
!21 = !{!10, !11, i64 48}
!22 = !{!10, !6, i64 24}
!23 = !{!10, !6, i64 32}
!24 = !{!10, !11, i64 52}


; 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 nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @qpacketmodem_create() local_unnamed_addr #1 {
  %1 = tail call noalias dereferenceable_or_null(64) ptr @malloc(i64 noundef 64) #4
  %2 = tail call ptr @modemcf_create(i32 noundef 40) #5
  store ptr %2, ptr %1, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %1, i64 16
  store i32 2, ptr %3, align 8, !tbaa !12
  %4 = getelementptr inbounds i8, ptr %1, i64 20
  store i32 1, ptr %4, align 4, !tbaa !13
  %5 = tail call ptr @packetizer_create(i32 noundef 1, i32 noundef 1, i32 noundef 1, i32 noundef 1) #5
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  store ptr %5, ptr %6, align 8, !tbaa !14
  %7 = tail call i32 @packetizer_get_enc_msg_len(ptr noundef %5) #5
  %8 = getelementptr inbounds i8, ptr %1, i64 40
  store i32 %7, ptr %8, align 8, !tbaa !15
  %9 = shl i32 %7, 3
  %10 = getelementptr inbounds i8, ptr %1, i64 44
  store i32 %9, ptr %10, align 4, !tbaa !16
  %11 = tail call i64 @div(i32 noundef %9, i32 noundef 2) #6
  %.not = icmp ugt i64 %11, 4294967295
  %12 = zext i1 %.not to i64
  %13 = add i64 %11, %12
  %14 = getelementptr inbounds i8, ptr %1, i64 48
  %15 = shl i64 %13, 1
  %16 = and i64 %15, 4294967294
  %17 = tail call noalias ptr @malloc(i64 noundef %16) #4
  %18 = getelementptr inbounds i8, ptr %1, i64 24
  store ptr %17, ptr %18, align 8, !tbaa !17
  %19 = shl i32 %7, 1
  store i32 %19, ptr %14, align 8, !tbaa !18
  %20 = zext i32 %19 to i64
  %21 = tail call noalias ptr @malloc(i64 noundef %20) #4
  %22 = getelementptr inbounds i8, ptr %1, i64 32
  store ptr %21, ptr %22, align 8, !tbaa !19
  %23 = getelementptr inbounds i8, ptr %1, i64 52
  store i32 0, ptr %23, align 4, !tbaa !20
  ret ptr %1
}

declare ptr @modemcf_create(i32 noundef) local_unnamed_addr #2

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

declare i32 @packetizer_get_enc_msg_len(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare i64 @div(i32 noundef, i32 noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(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 #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 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 allocsize(0) }
attributes #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(none) }

!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 = !{!"qpacketmodem_s", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !7, i64 24, !7, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !11, i64 56}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!6, !10, i64 16}
!13 = !{!6, !10, i64 20}
!14 = !{!6, !7, i64 8}
!15 = !{!6, !10, i64 40}
!16 = !{!6, !10, i64 44}
!17 = !{!6, !7, i64 24}
!18 = !{!6, !10, i64 48}
!19 = !{!6, !7, i64 32}
!20 = !{!6, !10, i64 52}


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