; 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.ByteArray_st = type { ptr, i64 }
%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.Dstu7624CfbCtx_st = type { i64, [64 x i8], [64 x i8], i64 }

@.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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @dstu7624_init_cfb(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i64 %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !11
  br label %10

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

13:                                               ; preds = %10
  store i32 2, ptr %9, align 4, !tbaa !11
  %14 = load i32, ptr %9, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 3973, i32 noundef %14, ptr noundef null)
  br label %127

15:                                               ; preds = %10
  br label %16

16:                                               ; preds = %15
  br label %17

17:                                               ; preds = %16
  br label %18

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

21:                                               ; preds = %18
  store i32 2, ptr %9, align 4, !tbaa !11
  %22 = load i32, ptr %9, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 3974, i32 noundef %22, ptr noundef null)
  br label %127

23:                                               ; preds = %18
  br label %24

24:                                               ; preds = %23
  br label %25

25:                                               ; preds = %24
  br label %26

26:                                               ; preds = %25
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = icmp ne ptr %27, null
  br i1 %28, label %31, label %29

29:                                               ; preds = %26
  store i32 2, ptr %9, align 4, !tbaa !11
  %30 = load i32, ptr %9, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 3975, i32 noundef %30, ptr noundef null)
  br label %127

31:                                               ; preds = %26
  br label %32

32:                                               ; preds = %31
  br label %33

33:                                               ; preds = %32
  br label %34

34:                                               ; preds = %33
  %35 = load i64, ptr %8, align 8, !tbaa !9
  %36 = icmp ne i64 %35, 0
  br i1 %36, label %37, label %43

37:                                               ; preds = %34
  %38 = load i64, ptr %8, align 8, !tbaa !9
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.ByteArray_st, ptr %39, i32 0, i32 1
  %41 = load i64, ptr %40, align 8, !tbaa !13
  %42 = icmp ule i64 %38, %41
  br i1 %42, label %45, label %43

43:                                               ; preds = %37, %34
  store i32 2, ptr %9, align 4, !tbaa !11
  %44 = load i32, ptr %9, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 3976, i32 noundef %44, ptr noundef null)
  br label %127

45:                                               ; preds = %37
  br label %46

46:                                               ; preds = %45
  br label %47

47:                                               ; preds = %46
  br label %48

48:                                               ; preds = %47
  %49 = load i64, ptr %8, align 8, !tbaa !9
  %50 = icmp eq i64 %49, 1
  br i1 %50, label %65, label %51

51:                                               ; preds = %48
  %52 = load i64, ptr %8, align 8, !tbaa !9
  %53 = icmp eq i64 %52, 8
  br i1 %53, label %65, label %54

54:                                               ; preds = %51
  %55 = load i64, ptr %8, align 8, !tbaa !9
  %56 = icmp eq i64 %55, 16
  br i1 %56, label %65, label %57

57:                                               ; preds = %54
  %58 = load i64, ptr %8, align 8, !tbaa !9
  %59 = icmp eq i64 %58, 32
  br i1 %59, label %65, label %60

60:                                               ; preds = %57
  %61 = load i64, ptr %8, align 8, !tbaa !9
  %62 = icmp eq i64 %61, 64
  br i1 %62, label %65, label %63

63:                                               ; preds = %60
  store i32 2, ptr %9, align 4, !tbaa !11
  %64 = load i32, ptr %9, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 3977, i32 noundef %64, ptr noundef null)
  br label %127

65:                                               ; preds = %60, %57, %54, %51, %48
  br label %66

66:                                               ; preds = %65
  br label %67

67:                                               ; preds = %66
  br label %68

68:                                               ; preds = %67
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = call i64 @ba_get_len(ptr noundef %71)
  %73 = call i32 @dstu7624_init(ptr noundef %69, ptr noundef %70, i64 noundef %72)
  store i32 %73, ptr %9, align 4, !tbaa !11
  %74 = load i32, ptr %9, align 4, !tbaa !11
  %75 = icmp ne i32 %74, 0
  br i1 %75, label %76, label %78

76:                                               ; preds = %68
  %77 = load i32, ptr %9, align 4, !tbaa !11
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 3979, i32 noundef %77)
  br label %127

78:                                               ; preds = %68
  br label %79

79:                                               ; preds = %78
  br label %80

80:                                               ; preds = %79
  br label %81

81:                                               ; preds = %80
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.Dstu7624Ctx_st, ptr %83, i32 0, i32 11
  %85 = getelementptr inbounds %struct.Dstu7624CfbCtx_st, ptr %84, i32 0, i32 1
  %86 = getelementptr inbounds [64 x i8], ptr %85, i64 0, i64 0
  %87 = load ptr, ptr %5, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.Dstu7624Ctx_st, ptr %87, i32 0, i32 9
  %89 = load i64, ptr %88, align 8, !tbaa !15
  %90 = call i32 @ba_to_uint8(ptr noundef %82, ptr noundef %86, i64 noundef %89)
  store i32 %90, ptr %9, align 4, !tbaa !11
  %91 = load i32, ptr %9, align 4, !tbaa !11
  %92 = icmp ne i32 %91, 0
  br i1 %92, label %93, label %95

93:                                               ; preds = %81
  %94 = load i32, ptr %9, align 4, !tbaa !11
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 3980, i32 noundef %94)
  br label %127

95:                                               ; preds = %81
  br label %96

96:                                               ; preds = %95
  br label %97

97:                                               ; preds = %96
  %98 = load i64, ptr %8, align 8, !tbaa !9
  %99 = load ptr, ptr %5, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.Dstu7624Ctx_st, ptr %99, i32 0, i32 11
  %101 = getelementptr inbounds %struct.Dstu7624CfbCtx_st, ptr %100, i32 0, i32 0
  store i64 %98, ptr %101, align 8, !tbaa !17
  br label %102

102:                                              ; preds = %97
  %103 = load ptr, ptr %7, align 8, !tbaa !5
  %104 = load ptr, ptr %5, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.Dstu7624Ctx_st, ptr %104, i32 0, i32 11
  %106 = getelementptr inbounds %struct.Dstu7624CfbCtx_st, ptr %105, i32 0, i32 2
  %107 = getelementptr inbounds [64 x i8], ptr %106, i64 0, i64 0
  %108 = load ptr, ptr %5, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.Dstu7624Ctx_st, ptr %108, i32 0, i32 9
  %110 = load i64, ptr %109, align 8, !tbaa !15
  %111 = call i32 @ba_to_uint8(ptr noundef %103, ptr noundef %107, i64 noundef %110)
  store i32 %111, ptr %9, align 4, !tbaa !11
  %112 = load i32, ptr %9, align 4, !tbaa !11
  %113 = icmp ne i32 %112, 0
  br i1 %113, label %114, label %116

114:                                              ; preds = %102
  %115 = load i32, ptr %9, align 4, !tbaa !11
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 3984, i32 noundef %115)
  br label %127

116:                                              ; preds = %102
  br label %117

117:                                              ; preds = %116
  br label %118

118:                                              ; preds = %117
  %119 = load ptr, ptr %5, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.Dstu7624Ctx_st, ptr %119, i32 0, i32 9
  %121 = load i64, ptr %120, align 8, !tbaa !15
  %122 = load ptr, ptr %5, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.Dstu7624Ctx_st, ptr %122, i32 0, i32 11
  %124 = getelementptr inbounds %struct.Dstu7624CfbCtx_st, ptr %123, i32 0, i32 3
  store i64 %121, ptr %124, align 8, !tbaa !17
  %125 = load ptr, ptr %5, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.Dstu7624Ctx_st, ptr %125, i32 0, i32 0
  store i32 3, ptr %126, align 8, !tbaa !18
  br label %127

127:                                              ; preds = %118, %114, %93, %76, %63, %43, %29, %21, %13
  %128 = load i32, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret i32 %128
}

declare i64 @ba_get_len(ptr noundef) #1

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @dstu7624_init_cfb(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %5, label %6

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

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

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

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

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

10:                                               ; preds = %8
  %.not52 = icmp eq i64 %3, 0
  br i1 %.not52, label %14, label %11

11:                                               ; preds = %10
  %12 = getelementptr inbounds i8, ptr %2, i64 8
  %13 = load i64, ptr %12, align 8, !tbaa !5
  %.not53 = icmp ult i64 %13, %3
  br i1 %.not53, label %14, label %15

14:                                               ; preds = %11, %10
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 3976, i32 noundef 2, ptr noundef null) #2
  br label %36

15:                                               ; preds = %11
  switch i64 %3, label %16 [
    i64 64, label %17
    i64 32, label %17
    i64 16, label %17
    i64 8, label %17
    i64 1, label %17
  ]

16:                                               ; preds = %15
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 3977, i32 noundef 2, ptr noundef null) #2
  br label %36

17:                                               ; preds = %15, %15, %15, %15, %15
  %18 = tail call i64 @ba_get_len(ptr noundef nonnull %2) #2
  %19 = tail call i32 @dstu7624_init(ptr noundef nonnull %0, ptr noundef nonnull %1, i64 noundef %18)
  %.not54 = icmp eq i32 %19, 0
  br i1 %.not54, label %21, label %20

20:                                               ; preds = %17
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 3979, i32 noundef %19) #2
  br label %36

21:                                               ; preds = %17
  %22 = getelementptr inbounds i8, ptr %0, i64 55400
  %23 = getelementptr inbounds i8, ptr %0, i64 55376
  %24 = load i64, ptr %23, align 8, !tbaa !11
  %25 = tail call i32 @ba_to_uint8(ptr noundef nonnull %2, ptr noundef nonnull %22, i64 noundef %24) #2
  %.not55 = icmp eq i32 %25, 0
  br i1 %.not55, label %27, label %26

26:                                               ; preds = %21
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 3980, i32 noundef %25) #2
  br label %36

27:                                               ; preds = %21
  %28 = getelementptr inbounds i8, ptr %0, i64 55392
  store i64 %3, ptr %28, align 8, !tbaa !14
  %29 = getelementptr inbounds i8, ptr %0, i64 55464
  %30 = load i64, ptr %23, align 8, !tbaa !11
  %31 = tail call i32 @ba_to_uint8(ptr noundef nonnull %2, ptr noundef nonnull %29, i64 noundef %30) #2
  %.not56 = icmp eq i32 %31, 0
  br i1 %.not56, label %33, label %32

32:                                               ; preds = %27
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 3984, i32 noundef %31) #2
  br label %36

33:                                               ; preds = %27
  %34 = load i64, ptr %23, align 8, !tbaa !11
  %35 = getelementptr inbounds i8, ptr %0, i64 55528
  store i64 %34, ptr %35, align 8, !tbaa !14
  store i32 3, ptr %0, align 8, !tbaa !15
  br label %36

36:                                               ; preds = %33, %32, %26, %20, %16, %14, %9, %7, %5
  %.0 = phi i32 [ %19, %20 ], [ %25, %26 ], [ %31, %32 ], [ 0, %33 ], [ 2, %16 ], [ 2, %14 ], [ 2, %9 ], [ 2, %7 ], [ 2, %5 ]
  ret i32 %.0
}

declare i64 @ba_get_len(ptr noundef) local_unnamed_addr #0

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

attributes #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 = { 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 = { 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 8}
!6 = !{!"ByteArray_st", !7, i64 0, !10, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!12, !10, i64 55376}
!12 = !{!"Dstu7624Ctx_st", !13, 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, !7, i64 55616, !7, i64 55624, !7, i64 55632}
!13 = !{!"int", !8, i64 0}
!14 = !{!8, !8, i64 0}
!15 = !{!12, !13, i64 0}


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