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

@.str = external hidden unnamed_addr constant [18 x i8], align 1

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

declare void @stacktrace_create(ptr noundef, i64 noundef, i32 noundef, ptr noundef) #1

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

declare void @stacktrace_add(ptr noundef, i64 noundef, i32 noundef) #1

declare void @gf2m_free(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @dstu7624_init(ptr noundef, ptr noundef, i64 noundef) #2

declare i64 @ba_get_len(ptr noundef) #1

declare i32 @ba_to_uint8(ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

declare ptr @gf2m_alloc(ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @dstu7624_init_xts(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca [5 x i32], align 16
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 20, ptr %7) #4
  call void @llvm.memset.p0.i64(ptr align 16 %7, i8 0, i64 20, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %3
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %14, label %12

12:                                               ; preds = %9
  store i32 2, ptr %8, align 4, !tbaa !9
  %13 = load i32, ptr %8, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 4092, i32 noundef %13, ptr noundef null)
  br label %107

14:                                               ; preds = %9
  br label %15

15:                                               ; preds = %14
  br label %16

16:                                               ; preds = %15
  br label %17

17:                                               ; preds = %16
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %22, label %20

20:                                               ; preds = %17
  store i32 2, ptr %8, align 4, !tbaa !9
  %21 = load i32, ptr %8, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 4093, i32 noundef %21, ptr noundef null)
  br label %107

22:                                               ; preds = %17
  br label %23

23:                                               ; preds = %22
  br label %24

24:                                               ; preds = %23
  br label %25

25:                                               ; preds = %24
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %30, label %28

28:                                               ; preds = %25
  store i32 2, ptr %8, align 4, !tbaa !9
  %29 = load i32, ptr %8, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 4094, i32 noundef %29, ptr noundef null)
  br label %107

30:                                               ; preds = %25
  br label %31

31:                                               ; preds = %30
  br label %32

32:                                               ; preds = %31
  br label %33

33:                                               ; preds = %32
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = call i64 @ba_get_len(ptr noundef %36)
  %38 = call i32 @dstu7624_init(ptr noundef %34, ptr noundef %35, i64 noundef %37)
  store i32 %38, ptr %8, align 4, !tbaa !9
  %39 = load i32, ptr %8, align 4, !tbaa !9
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %43

41:                                               ; preds = %33
  %42 = load i32, ptr %8, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 4096, i32 noundef %42)
  br label %107

43:                                               ; preds = %33
  br label %44

44:                                               ; preds = %43
  br label %45

45:                                               ; preds = %44
  br label %46

46:                                               ; preds = %45
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.Dstu7624Ctx_st, ptr %48, i32 0, i32 11
  %50 = getelementptr inbounds %struct.Dstu7624XtsCtx_st, ptr %49, i32 0, i32 0
  %51 = getelementptr inbounds [64 x i8], ptr %50, i64 0, i64 0
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.Dstu7624Ctx_st, ptr %52, i32 0, i32 9
  %54 = load i64, ptr %53, align 8, !tbaa !11
  %55 = call i32 @ba_to_uint8(ptr noundef %47, ptr noundef %51, i64 noundef %54)
  store i32 %55, ptr %8, align 4, !tbaa !9
  %56 = load i32, ptr %8, align 4, !tbaa !9
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %58, label %60

58:                                               ; preds = %46
  %59 = load i32, ptr %8, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 4097, i32 noundef %59)
  br label %107

60:                                               ; preds = %46
  br label %61

61:                                               ; preds = %60
  br label %62

62:                                               ; preds = %61
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.Dstu7624Ctx_st, ptr %63, i32 0, i32 9
  %65 = load i64, ptr %64, align 8, !tbaa !11
  switch i64 %65, label %84 [
    i64 16, label %66
    i64 32, label %72
    i64 64, label %78
  ]

66:                                               ; preds = %62
  %67 = getelementptr inbounds [5 x i32], ptr %7, i64 0, i64 0
  store i32 128, ptr %67, align 16, !tbaa !9
  %68 = getelementptr inbounds [5 x i32], ptr %7, i64 0, i64 1
  store i32 7, ptr %68, align 4, !tbaa !9
  %69 = getelementptr inbounds [5 x i32], ptr %7, i64 0, i64 2
  store i32 2, ptr %69, align 8, !tbaa !9
  %70 = getelementptr inbounds [5 x i32], ptr %7, i64 0, i64 3
  store i32 1, ptr %70, align 4, !tbaa !9
  %71 = getelementptr inbounds [5 x i32], ptr %7, i64 0, i64 4
  store i32 0, ptr %71, align 16, !tbaa !9
  br label %85

72:                                               ; preds = %62
  %73 = getelementptr inbounds [5 x i32], ptr %7, i64 0, i64 0
  store i32 256, ptr %73, align 16, !tbaa !9
  %74 = getelementptr inbounds [5 x i32], ptr %7, i64 0, i64 1
  store i32 10, ptr %74, align 4, !tbaa !9
  %75 = getelementptr inbounds [5 x i32], ptr %7, i64 0, i64 2
  store i32 5, ptr %75, align 8, !tbaa !9
  %76 = getelementptr inbounds [5 x i32], ptr %7, i64 0, i64 3
  store i32 2, ptr %76, align 4, !tbaa !9
  %77 = getelementptr inbounds [5 x i32], ptr %7, i64 0, i64 4
  store i32 0, ptr %77, align 16, !tbaa !9
  br label %85

78:                                               ; preds = %62
  %79 = getelementptr inbounds [5 x i32], ptr %7, i64 0, i64 0
  store i32 512, ptr %79, align 16, !tbaa !9
  %80 = getelementptr inbounds [5 x i32], ptr %7, i64 0, i64 1
  store i32 8, ptr %80, align 4, !tbaa !9
  %81 = getelementptr inbounds [5 x i32], ptr %7, i64 0, i64 2
  store i32 5, ptr %81, align 8, !tbaa !9
  %82 = getelementptr inbounds [5 x i32], ptr %7, i64 0, i64 3
  store i32 2, ptr %82, align 4, !tbaa !9
  %83 = getelementptr inbounds [5 x i32], ptr %7, i64 0, i64 4
  store i32 0, ptr %83, align 16, !tbaa !9
  br label %85

84:                                               ; preds = %62
  br label %85

85:                                               ; preds = %84, %78, %72, %66
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.Dstu7624Ctx_st, ptr %86, i32 0, i32 11
  %88 = getelementptr inbounds %struct.Dstu7624XtsCtx_st, ptr %87, i32 0, i32 1
  %89 = load ptr, ptr %88, align 8, !tbaa !14
  call void @gf2m_free(ptr noundef %89)
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.Dstu7624Ctx_st, ptr %90, i32 0, i32 11
  %92 = getelementptr inbounds %struct.Dstu7624XtsCtx_st, ptr %91, i32 0, i32 1
  store ptr null, ptr %92, align 8, !tbaa !14
  br label %93

93:                                               ; preds = %85
  %94 = getelementptr inbounds [5 x i32], ptr %7, i64 0, i64 0
  %95 = call ptr @gf2m_alloc(ptr noundef %94, i64 noundef 5)
  %96 = load ptr, ptr %4, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.Dstu7624Ctx_st, ptr %96, i32 0, i32 11
  %98 = getelementptr inbounds %struct.Dstu7624XtsCtx_st, ptr %97, i32 0, i32 1
  store ptr %95, ptr %98, align 8, !tbaa !14
  %99 = icmp eq ptr null, %95
  br i1 %99, label %100, label %102

100:                                              ; preds = %93
  store i32 2, ptr %8, align 4, !tbaa !9
  %101 = load i32, ptr %8, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 4128, i32 noundef %101)
  br label %107

102:                                              ; preds = %93
  br label %103

103:                                              ; preds = %102
  br label %104

104:                                              ; preds = %103
  %105 = load ptr, ptr %4, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.Dstu7624Ctx_st, ptr %105, i32 0, i32 0
  store i32 7, ptr %106, align 8, !tbaa !15
  br label %107

107:                                              ; preds = %104, %100, %58, %41, %28, %20, %12
  %108 = load i32, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 20, ptr %7) #4
  ret i32 %108
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 55376}
!12 = !{!"Dstu7624Ctx_st", !10, i64 0, !7, i64 8, !7, i64 16392, !7, i64 32776, !7, i64 33800, !7, i64 34824, !7, i64 45064, !7, i64 55304, !13, i64 55368, !13, i64 55376, !13, i64 55384, !7, i64 55392, !6, i64 55616, !6, i64 55624, !6, i64 55632}
!13 = !{!"long", !7, i64 0}
!14 = !{!7, !7, i64 0}
!15 = !{!12, !10, 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"

@.str = external hidden unnamed_addr constant [18 x i8], align 1

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

declare void @stacktrace_create(ptr noundef, i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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

declare void @stacktrace_add(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

declare void @gf2m_free(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @dstu7624_init(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

declare i64 @ba_get_len(ptr noundef) local_unnamed_addr #1

declare i32 @ba_to_uint8(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

declare ptr @gf2m_alloc(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @dstu7624_init_xts(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #2 {
  %4 = alloca [5 x i32], align 16
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %4) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(20) %4, i8 0, i64 20, i1 false)
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %5, label %6

5:                                                ; preds = %3
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 4092, i32 noundef 2, ptr noundef null) #4
  br label %36

6:                                                ; preds = %3
  %.not27 = icmp eq ptr %1, null
  br i1 %.not27, label %7, label %8

7:                                                ; preds = %6
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 4093, i32 noundef 2, ptr noundef null) #4
  br label %36

8:                                                ; preds = %6
  %.not28 = icmp eq ptr %2, null
  br i1 %.not28, label %9, label %10

9:                                                ; preds = %8
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 4094, i32 noundef 2, ptr noundef null) #4
  br label %36

10:                                               ; preds = %8
  %11 = tail call i64 @ba_get_len(ptr noundef nonnull %2) #4
  %12 = tail call i32 @dstu7624_init(ptr noundef nonnull %0, ptr noundef nonnull %1, i64 noundef %11)
  %.not29 = icmp eq i32 %12, 0
  br i1 %.not29, label %14, label %13

13:                                               ; preds = %10
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 4096, i32 noundef %12) #4
  br label %36

14:                                               ; preds = %10
  %15 = getelementptr inbounds i8, ptr %0, i64 55392
  %16 = getelementptr inbounds i8, ptr %0, i64 55376
  %17 = load i64, ptr %16, align 8, !tbaa !5
  %18 = tail call i32 @ba_to_uint8(ptr noundef nonnull %2, ptr noundef nonnull %15, i64 noundef %17) #4
  %.not30 = icmp eq i32 %18, 0
  br i1 %.not30, label %20, label %19

19:                                               ; preds = %14
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 4097, i32 noundef %18) #4
  br label %36

20:                                               ; preds = %14
  %21 = load i64, ptr %16, align 8, !tbaa !5
  switch i64 %21, label %29 [
    i64 16, label %22
    i64 32, label %23
    i64 64, label %24
  ]

22:                                               ; preds = %20
  store i32 128, ptr %4, align 16, !tbaa !12
  br label %.sink.split

23:                                               ; preds = %20
  store i32 256, ptr %4, align 16, !tbaa !12
  br label %.sink.split

24:                                               ; preds = %20
  store i32 512, ptr %4, align 16, !tbaa !12
  br label %.sink.split

.sink.split:                                      ; preds = %22, %23, %24
  %.sink = phi i32 [ 2, %24 ], [ 2, %23 ], [ 1, %22 ]
  %25 = phi <2 x i32> [ <i32 8, i32 5>, %24 ], [ <i32 10, i32 5>, %23 ], [ <i32 7, i32 2>, %22 ]
  %26 = getelementptr inbounds i8, ptr %4, i64 4
  store <2 x i32> %25, ptr %26, align 4, !tbaa !12
  %27 = getelementptr inbounds i8, ptr %4, i64 12
  store i32 %.sink, ptr %27, align 4, !tbaa !12
  %28 = getelementptr inbounds i8, ptr %4, i64 16
  store i32 0, ptr %28, align 16, !tbaa !12
  br label %29

29:                                               ; preds = %.sink.split, %20
  %30 = getelementptr inbounds i8, ptr %0, i64 55456
  %31 = load ptr, ptr %30, align 8, !tbaa !13
  tail call void @gf2m_free(ptr noundef %31) #4
  store ptr null, ptr %30, align 8, !tbaa !13
  %32 = call ptr @gf2m_alloc(ptr noundef nonnull %4, i64 noundef 5) #4
  store ptr %32, ptr %30, align 8, !tbaa !13
  %33 = icmp eq ptr %32, null
  br i1 %33, label %34, label %35

34:                                               ; preds = %29
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 4128, i32 noundef 2) #4
  br label %36

35:                                               ; preds = %29
  store i32 7, ptr %0, align 8, !tbaa !14
  br label %36

36:                                               ; preds = %35, %34, %19, %13, %9, %7, %5
  %.0 = phi i32 [ %12, %13 ], [ %18, %19 ], [ 2, %34 ], [ 0, %35 ], [ 2, %9 ], [ 2, %7 ], [ 2, %5 ]
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %4) #4
  ret i32 %.0
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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, !10, i64 55376}
!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 = !{!7, !7, i64 0}
!13 = !{!8, !8, i64 0}
!14 = !{!6, !7, i64 0}


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