; LLVM IR from litespeedtech/ls-qpack :: lsqpack (lsqpack_enc_preinit)

; 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.lsqpack_enc = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, %struct.lsqpack_enc_head, ptr, %struct.anon, %struct.anon.0, %struct.anon.1, %struct.anon.2, %struct.anon.3, i32, i32, ptr, float, float, ptr, i32, i32, i32 }
%struct.lsqpack_enc_head = type { ptr, ptr }
%struct.anon = type { ptr, ptr }
%struct.anon.0 = type { ptr, ptr }
%struct.anon.1 = type { ptr, ptr }
%struct.anon.2 = type { ptr, ptr, i32, i32, i32, i32 }
%struct.anon.3 = type { %struct.lsqpack_dec_int_state, ptr }
%struct.lsqpack_dec_int_state = type { i32, i32, i32, i64 }

@.str = external hidden unnamed_addr constant [14 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @lsqpack_enc_preinit(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %5, i8 0, i64 240, i1 false)
  br label %6

6:                                                ; preds = %2
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.lsqpack_enc, ptr %7, i32 0, i32 14
  %9 = getelementptr inbounds %struct.lsqpack_enc_head, ptr %8, i32 0, i32 0
  store ptr null, ptr %9, align 8, !tbaa !9
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.lsqpack_enc, ptr %10, i32 0, i32 14
  %12 = getelementptr inbounds %struct.lsqpack_enc_head, ptr %11, i32 0, i32 0
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.lsqpack_enc, ptr %13, i32 0, i32 14
  %15 = getelementptr inbounds %struct.lsqpack_enc_head, ptr %14, i32 0, i32 1
  store ptr %12, ptr %15, align 8, !tbaa !19
  br label %16

16:                                               ; preds = %6
  br label %17

17:                                               ; preds = %16
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.lsqpack_enc, ptr %18, i32 0, i32 16
  %20 = getelementptr inbounds %struct.anon, ptr %19, i32 0, i32 0
  store ptr null, ptr %20, align 8, !tbaa !20
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.lsqpack_enc, ptr %21, i32 0, i32 16
  %23 = getelementptr inbounds %struct.anon, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.lsqpack_enc, ptr %24, i32 0, i32 16
  %26 = getelementptr inbounds %struct.anon, ptr %25, i32 0, i32 1
  store ptr %23, ptr %26, align 8, !tbaa !21
  br label %27

27:                                               ; preds = %17
  br label %28

28:                                               ; preds = %27
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.lsqpack_enc, ptr %29, i32 0, i32 17
  %31 = getelementptr inbounds %struct.anon.0, ptr %30, i32 0, i32 0
  store ptr null, ptr %31, align 8, !tbaa !22
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.lsqpack_enc, ptr %32, i32 0, i32 17
  %34 = getelementptr inbounds %struct.anon.0, ptr %33, i32 0, i32 0
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.lsqpack_enc, ptr %35, i32 0, i32 17
  %37 = getelementptr inbounds %struct.anon.0, ptr %36, i32 0, i32 1
  store ptr %34, ptr %37, align 8, !tbaa !23
  br label %38

38:                                               ; preds = %28
  br label %39

39:                                               ; preds = %38
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.lsqpack_enc, ptr %40, i32 0, i32 18
  %42 = getelementptr inbounds %struct.anon.1, ptr %41, i32 0, i32 0
  store ptr null, ptr %42, align 8, !tbaa !24
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.lsqpack_enc, ptr %43, i32 0, i32 18
  %45 = getelementptr inbounds %struct.anon.1, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.lsqpack_enc, ptr %46, i32 0, i32 18
  %48 = getelementptr inbounds %struct.anon.1, ptr %47, i32 0, i32 1
  store ptr %45, ptr %48, align 8, !tbaa !25
  br label %49

49:                                               ; preds = %39
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.lsqpack_enc, ptr %51, i32 0, i32 23
  store ptr %50, ptr %52, align 8, !tbaa !26
  br label %53

53:                                               ; preds = %49
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.lsqpack_enc, ptr %54, i32 0, i32 23
  %56 = load ptr, ptr %55, align 8, !tbaa !26
  %57 = icmp ne ptr %56, null
  br i1 %57, label %58, label %71

58:                                               ; preds = %53
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.lsqpack_enc, ptr %59, i32 0, i32 23
  %61 = load ptr, ptr %60, align 8, !tbaa !26
  %62 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %61, ptr noundef @.str) #3
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.lsqpack_enc, ptr %63, i32 0, i32 23
  %65 = load ptr, ptr %64, align 8, !tbaa !26
  %66 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %65, ptr noundef @.str.1) #3
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.lsqpack_enc, ptr %67, i32 0, i32 23
  %69 = load ptr, ptr %68, align 8, !tbaa !26
  %70 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %69, ptr noundef @.str.2) #3
  br label %71

71:                                               ; preds = %58, %53
  br label %72

72:                                               ; preds = %71
  ret void
}

; 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: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

attributes #0 = { 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 #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 #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, !6, i64 56}
!10 = !{!"lsqpack_enc", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !12, i64 56, !6, i64 72, !13, i64 80, !13, i64 96, !13, i64 112, !14, i64 128, !15, i64 160, !11, i64 192, !11, i64 196, !6, i64 200, !18, i64 208, !18, i64 212, !6, i64 216, !11, i64 224, !11, i64 228, !11, i64 232}
!11 = !{!"int", !7, i64 0}
!12 = !{!"lsqpack_enc_head", !6, i64 0, !6, i64 8}
!13 = !{!"", !6, i64 0, !6, i64 8}
!14 = !{!"", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28}
!15 = !{!"", !16, i64 0, !6, i64 24}
!16 = !{!"lsqpack_dec_int_state", !11, i64 0, !11, i64 4, !11, i64 8, !17, i64 16}
!17 = !{!"long", !7, i64 0}
!18 = !{!"float", !7, i64 0}
!19 = !{!10, !6, i64 64}
!20 = !{!10, !6, i64 80}
!21 = !{!10, !6, i64 88}
!22 = !{!10, !6, i64 96}
!23 = !{!10, !6, i64 104}
!24 = !{!10, !6, i64 112}
!25 = !{!10, !6, i64 120}
!26 = !{!10, !6, i64 200}


; 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"

@.str = external hidden unnamed_addr constant [14 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local void @lsqpack_enc_preinit(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 56
  %4 = getelementptr inbounds i8, ptr %0, i64 64
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(240) %0, i8 0, i64 240, i1 false)
  store ptr %3, ptr %4, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 80
  %6 = getelementptr inbounds i8, ptr %0, i64 88
  store ptr %5, ptr %6, align 8, !tbaa !18
  %7 = getelementptr inbounds i8, ptr %0, i64 96
  %8 = getelementptr inbounds i8, ptr %0, i64 104
  store ptr %7, ptr %8, align 8, !tbaa !19
  %9 = getelementptr inbounds i8, ptr %0, i64 112
  %10 = getelementptr inbounds i8, ptr %0, i64 120
  store ptr %9, ptr %10, align 8, !tbaa !20
  %11 = getelementptr inbounds i8, ptr %0, i64 200
  store ptr %1, ptr %11, align 8, !tbaa !21
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %18, label %12

12:                                               ; preds = %2
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %1, ptr noundef nonnull @.str) #3
  %14 = load ptr, ptr %11, align 8, !tbaa !21
  %15 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str.1) #3
  %16 = load ptr, ptr %11, align 8, !tbaa !21
  %17 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str.2) #3
  br label %18

18:                                               ; preds = %2, %12
  ret void
}

; 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: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

attributes #0 = { nofree 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 #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { nofree 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 #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, !11, i64 64}
!6 = !{!"lsqpack_enc", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !7, i64 48, !7, i64 52, !10, i64 56, !11, i64 72, !12, i64 80, !12, i64 96, !12, i64 112, !13, i64 128, !14, i64 160, !7, i64 192, !7, i64 196, !11, i64 200, !17, i64 208, !17, i64 212, !11, i64 216, !7, i64 224, !7, i64 228, !7, i64 232}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"lsqpack_enc_head", !11, i64 0, !11, i64 8}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"", !11, i64 0, !11, i64 8}
!13 = !{!"", !11, i64 0, !11, i64 8, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28}
!14 = !{!"", !15, i64 0, !11, i64 24}
!15 = !{!"lsqpack_dec_int_state", !7, i64 0, !7, i64 4, !7, i64 8, !16, i64 16}
!16 = !{!"long", !8, i64 0}
!17 = !{!"float", !8, i64 0}
!18 = !{!6, !11, i64 88}
!19 = !{!6, !11, i64 104}
!20 = !{!6, !11, i64 120}
!21 = !{!6, !11, i64 200}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass