; LLVM IR from specinfo-ua/UAPKI :: library/uapkic/src (dstu7624)

; 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.Dstu7624Ctx_st = type { i32, [8 x [256 x i64]], [8 x [256 x i64]], [1024 x i8], [1024 x i8], [1280 x i64], [1280 x i64], [8 x i64], i64, i64, i64, %union.anon, ptr, ptr, ptr }
%union.anon = type { %struct.Dstu7624GmacCtx_st }
%struct.Dstu7624GmacCtx_st = type { [8 x i64], [8 x i64], [64 x i8], i64, i64, i64, ptr }
%struct.Dstu7624XtsCtx_st = type { [64 x i8], ptr }
%struct.Dstu7624GcmCtx_st = type { [8 x i64], i64, ptr }

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

; Function Attrs: nounwind uwtable
define dso_local void @dstu7624_free(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = icmp ne ptr %3, null
  br i1 %4, label %5, label %28

5:                                                ; preds = %1
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.Dstu7624Ctx_st, ptr %6, i32 0, i32 0
  %8 = load i32, ptr %7, align 8, !tbaa !9
  switch i32 %8, label %24 [
    i32 1, label %25
    i32 4, label %25
    i32 2, label %25
    i32 3, label %25
    i32 8, label %25
    i32 5, label %25
    i32 7, label %9
    i32 9, label %14
    i32 10, label %19
  ]

9:                                                ; preds = %5
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.Dstu7624Ctx_st, ptr %10, i32 0, i32 11
  %12 = getelementptr inbounds %struct.Dstu7624XtsCtx_st, ptr %11, i32 0, i32 1
  %13 = load ptr, ptr %12, align 8, !tbaa !13
  call void @gf2m_free(ptr noundef %13)
  br label %25

14:                                               ; preds = %5
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.Dstu7624Ctx_st, ptr %15, i32 0, i32 11
  %17 = getelementptr inbounds %struct.Dstu7624GcmCtx_st, ptr %16, i32 0, i32 2
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  call void @gf2m_free(ptr noundef %18)
  br label %25

19:                                               ; preds = %5
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.Dstu7624Ctx_st, ptr %20, i32 0, i32 11
  %22 = getelementptr inbounds %struct.Dstu7624GmacCtx_st, ptr %21, i32 0, i32 6
  %23 = load ptr, ptr %22, align 8, !tbaa !13
  call void @gf2m_free(ptr noundef %23)
  br label %25

24:                                               ; preds = %5
  br label %25

25:                                               ; preds = %24, %19, %14, %9, %5, %5, %5, %5, %5, %5
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  call void @secure_zero(ptr noundef %26, i64 noundef 55640)
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  call void @free(ptr noundef %27) #3
  br label %28

28:                                               ; preds = %25, %1
  ret void
}

declare void @gf2m_free(ptr noundef) #2

declare void @secure_zero(ptr noundef, i64 noundef) #2

attributes #0 = { 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 #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 = { 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, !11, i64 0}
!10 = !{!"Dstu7624Ctx_st", !11, i64 0, !7, i64 8, !7, i64 16392, !7, i64 32776, !7, i64 33800, !7, i64 34824, !7, i64 45064, !7, i64 55304, !12, i64 55368, !12, i64 55376, !12, i64 55384, !7, i64 55392, !6, i64 55616, !6, i64 55624, !6, i64 55632}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!7, !7, 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"

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

; Function Attrs: nounwind uwtable
define dso_local void @dstu7624_free(ptr noundef %0) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %9, label %2

2:                                                ; preds = %1
  %3 = load i32, ptr %0, align 8, !tbaa !5
  switch i32 %3, label %8 [
    i32 10, label %5
    i32 9, label %4
    i32 7, label %.sink.split
  ]

4:                                                ; preds = %2
  br label %.sink.split

5:                                                ; preds = %2
  br label %.sink.split

.sink.split:                                      ; preds = %2, %4, %5
  %.sink = phi i64 [ 55608, %5 ], [ 55464, %4 ], [ 55456, %2 ]
  %6 = getelementptr inbounds i8, ptr %0, i64 %.sink
  %7 = load ptr, ptr %6, align 8, !tbaa !12
  tail call void @gf2m_free(ptr noundef %7) #3
  br label %8

8:                                                ; preds = %.sink.split, %2
  tail call void @secure_zero(ptr noundef nonnull %0, i64 noundef 55640) #3
  tail call void @free(ptr noundef nonnull %0) #3
  br label %9

9:                                                ; preds = %8, %1
  ret void
}

declare void @gf2m_free(ptr noundef) local_unnamed_addr #2

declare void @secure_zero(ptr noundef, i64 noundef) local_unnamed_addr #2

attributes #0 = { 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 #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 = { 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, !7, i64 0}
!6 = !{!"Dstu7624Ctx_st", !7, i64 0, !8, i64 8, !8, i64 16392, !8, i64 32776, !8, i64 33800, !8, i64 34824, !8, i64 45064, !8, i64 55304, !10, i64 55368, !10, i64 55376, !10, i64 55384, !8, i64 55392, !11, i64 55616, !11, i64 55624, !11, i64 55632}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!8, !8, i64 0}


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