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

; Function Attrs: nounwind allocsize(1)
declare ptr @realloc(ptr noundef, i64 noundef) #1

declare i32 @packetizer_get_enc_msg_len(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local i32 @qpacketmodem_configure(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) #4 {
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca %struct.div_t, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !9
  store i32 %5, ptr %12, align 4, !tbaa !9
  %14 = load i32, ptr %8, align 4, !tbaa !9
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.qpacketmodem_s, ptr %15, i32 0, i32 3
  store i32 %14, ptr %16, align 4, !tbaa !11
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.qpacketmodem_s, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !14
  %20 = load i32, ptr %12, align 4, !tbaa !9
  %21 = call ptr @modemcf_recreate(ptr noundef %19, i32 noundef %20)
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.qpacketmodem_s, ptr %22, i32 0, i32 0
  store ptr %21, ptr %23, align 8, !tbaa !14
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.qpacketmodem_s, ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !14
  %27 = call i32 @modemcf_get_bps(ptr noundef %26)
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.qpacketmodem_s, ptr %28, i32 0, i32 2
  store i32 %27, ptr %29, align 8, !tbaa !15
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.qpacketmodem_s, ptr %30, i32 0, i32 1
  %32 = load ptr, ptr %31, align 8, !tbaa !16
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.qpacketmodem_s, ptr %33, i32 0, i32 3
  %35 = load i32, ptr %34, align 4, !tbaa !11
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = load i32, ptr %10, align 4, !tbaa !9
  %38 = load i32, ptr %11, align 4, !tbaa !9
  %39 = call ptr @packetizer_recreate(ptr noundef %32, i32 noundef %35, i32 noundef %36, i32 noundef %37, i32 noundef %38)
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.qpacketmodem_s, ptr %40, i32 0, i32 1
  store ptr %39, ptr %41, align 8, !tbaa !16
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.qpacketmodem_s, ptr %42, i32 0, i32 1
  %44 = load ptr, ptr %43, align 8, !tbaa !16
  %45 = call i32 @packetizer_get_enc_msg_len(ptr noundef %44)
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.qpacketmodem_s, ptr %46, i32 0, i32 6
  store i32 %45, ptr %47, align 8, !tbaa !17
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.qpacketmodem_s, ptr %48, i32 0, i32 6
  %50 = load i32, ptr %49, align 8, !tbaa !17
  %51 = mul i32 8, %50
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.qpacketmodem_s, ptr %52, i32 0, i32 7
  store i32 %51, ptr %53, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.qpacketmodem_s, ptr %54, i32 0, i32 7
  %56 = load i32, ptr %55, align 4, !tbaa !18
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.qpacketmodem_s, ptr %57, i32 0, i32 2
  %59 = load i32, ptr %58, align 8, !tbaa !15
  %60 = call i64 @div(i32 noundef %56, i32 noundef %59) #6
  store i64 %60, ptr %13, align 4
  %61 = getelementptr inbounds %struct.div_t, ptr %13, i32 0, i32 0
  %62 = load i32, ptr %61, align 4, !tbaa !19
  %63 = getelementptr inbounds %struct.div_t, ptr %13, i32 0, i32 1
  %64 = load i32, ptr %63, align 4, !tbaa !21
  %65 = icmp ne i32 %64, 0
  %66 = zext i1 %65 to i64
  %67 = select i1 %65, i32 1, i32 0
  %68 = add nsw i32 %62, %67
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.qpacketmodem_s, ptr %69, i32 0, i32 8
  store i32 %68, ptr %70, align 8, !tbaa !22
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.qpacketmodem_s, ptr %71, i32 0, i32 4
  %73 = load ptr, ptr %72, align 8, !tbaa !23
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.qpacketmodem_s, ptr %74, i32 0, i32 2
  %76 = load i32, ptr %75, align 8, !tbaa !15
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.qpacketmodem_s, ptr %77, i32 0, i32 8
  %79 = load i32, ptr %78, align 8, !tbaa !22
  %80 = mul i32 %76, %79
  %81 = zext i32 %80 to i64
  %82 = mul i64 %81, 1
  %83 = call ptr @realloc(ptr noundef %73, i64 noundef %82) #7
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.qpacketmodem_s, ptr %84, i32 0, i32 4
  store ptr %83, ptr %85, align 8, !tbaa !23
  %86 = load ptr, ptr %7, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.qpacketmodem_s, ptr %86, i32 0, i32 5
  %88 = load ptr, ptr %87, align 8, !tbaa !24
  %89 = load ptr, ptr %7, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.qpacketmodem_s, ptr %89, i32 0, i32 8
  %91 = load i32, ptr %90, align 8, !tbaa !22
  %92 = zext i32 %91 to i64
  %93 = mul i64 %92, 1
  %94 = call ptr @realloc(ptr noundef %88, i64 noundef %93) #7
  %95 = load ptr, ptr %7, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.qpacketmodem_s, ptr %95, i32 0, i32 5
  store ptr %94, ptr %96, align 8, !tbaa !24
  %97 = load ptr, ptr %7, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.qpacketmodem_s, ptr %97, i32 0, i32 9
  store i32 0, ptr %98, align 4, !tbaa !25
  %99 = load ptr, ptr %7, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.qpacketmodem_s, ptr %99, i32 0, i32 10
  store float 0.000000e+00, ptr %100, align 8, !tbaa !26
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  ret i32 0
}

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

declare i32 @modemcf_get_bps(ptr noundef) #2

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

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

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


; 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 nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias noundef ptr @realloc(ptr allocptr nocapture noundef, i64 noundef) local_unnamed_addr #0

declare i32 @packetizer_get_enc_msg_len(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @qpacketmodem_configure(ptr nocapture noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #3 {
  %7 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 %1, ptr %7, align 4, !tbaa !5
  %8 = load ptr, ptr %0, align 8, !tbaa !12
  %9 = tail call ptr @modemcf_recreate(ptr noundef %8, i32 noundef %5) #4
  store ptr %9, ptr %0, align 8, !tbaa !12
  %10 = tail call i32 @modemcf_get_bps(ptr noundef %9) #4
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %10, ptr %11, align 8, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !14
  %14 = load i32, ptr %7, align 4, !tbaa !5
  %15 = tail call ptr @packetizer_recreate(ptr noundef %13, i32 noundef %14, i32 noundef %2, i32 noundef %3, i32 noundef %4) #4
  store ptr %15, ptr %12, align 8, !tbaa !14
  %16 = tail call i32 @packetizer_get_enc_msg_len(ptr noundef %15) #4
  %17 = getelementptr inbounds i8, ptr %0, i64 40
  store i32 %16, ptr %17, align 8, !tbaa !15
  %18 = shl i32 %16, 3
  %19 = getelementptr inbounds i8, ptr %0, i64 44
  store i32 %18, ptr %19, align 4, !tbaa !16
  %20 = load i32, ptr %11, align 8, !tbaa !13
  %21 = tail call i64 @div(i32 noundef %18, i32 noundef %20) #5
  %.sroa.0.0.extract.trunc = trunc i64 %21 to i32
  %.not = icmp ugt i64 %21, 4294967295
  %22 = zext i1 %.not to i32
  %23 = add nsw i32 %22, %.sroa.0.0.extract.trunc
  %24 = getelementptr inbounds i8, ptr %0, i64 48
  store i32 %23, ptr %24, align 8, !tbaa !17
  %25 = getelementptr inbounds i8, ptr %0, i64 24
  %26 = load ptr, ptr %25, align 8, !tbaa !18
  %27 = mul i32 %23, %20
  %28 = zext i32 %27 to i64
  %29 = tail call ptr @realloc(ptr noundef %26, i64 noundef %28) #6
  store ptr %29, ptr %25, align 8, !tbaa !18
  %30 = getelementptr inbounds i8, ptr %0, i64 32
  %31 = load ptr, ptr %30, align 8, !tbaa !19
  %32 = load i32, ptr %24, align 8, !tbaa !17
  %33 = zext i32 %32 to i64
  %34 = tail call ptr @realloc(ptr noundef %31, i64 noundef %33) #6
  store ptr %34, ptr %30, align 8, !tbaa !19
  %35 = getelementptr inbounds i8, ptr %0, i64 52
  store i32 0, ptr %35, align 4, !tbaa !20
  %36 = getelementptr inbounds i8, ptr %0, i64 56
  store float 0.000000e+00, ptr %36, align 8, !tbaa !21
  ret i32 0
}

declare ptr @modemcf_recreate(ptr noundef, i32 noundef) local_unnamed_addr #1

declare i32 @modemcf_get_bps(ptr noundef) local_unnamed_addr #1

declare ptr @packetizer_recreate(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nounwind willreturn allockind("realloc") allocsize(1) 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 #1 = { "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 = { 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 #3 = { 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 #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(none) }
attributes #6 = { nounwind allocsize(1) }

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


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