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

; 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.DesCtx_st = type { [24 x i8], [24 x i8], [24 x i8], [24 x i8], i64, [24 x i8], [96 x i32], [96 x i32], i32 }

@.str = external hidden unnamed_addr constant [13 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

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

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

; Function Attrs: nounwind uwtable
declare hidden void @des_setup(ptr 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

; Function Attrs: nounwind uwtable
define dso_local i32 @des_init_cbc(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = 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 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %8

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

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

13:                                               ; preds = %8
  br label %14

14:                                               ; preds = %13
  br label %15

15:                                               ; preds = %14
  br label %16

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

19:                                               ; preds = %16
  store i32 2, ptr %7, align 4, !tbaa !9
  %20 = load i32, ptr %7, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 2098, i32 noundef %20, ptr noundef null)
  br label %110

21:                                               ; preds = %16
  br label %22

22:                                               ; preds = %21
  br label %23

23:                                               ; preds = %22
  br label %24

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

27:                                               ; preds = %24
  store i32 2, ptr %7, align 4, !tbaa !9
  %28 = load i32, ptr %7, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 2099, i32 noundef %28, ptr noundef null)
  br label %110

29:                                               ; preds = %24
  br label %30

30:                                               ; preds = %29
  br label %31

31:                                               ; preds = %30
  br label %32

32:                                               ; preds = %31
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.ByteArray_st, ptr %33, i32 0, i32 1
  %35 = load i64, ptr %34, align 8, !tbaa !11
  %36 = icmp eq i64 %35, 8
  br i1 %36, label %39, label %37

37:                                               ; preds = %32
  store i32 2, ptr %7, align 4, !tbaa !9
  %38 = load i32, ptr %7, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 2100, i32 noundef %38, ptr noundef null)
  br label %110

39:                                               ; preds = %32
  br label %40

40:                                               ; preds = %39
  br label %41

41:                                               ; preds = %40
  br label %42

42:                                               ; preds = %41
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.ByteArray_st, ptr %43, i32 0, i32 1
  %45 = load i64, ptr %44, align 8, !tbaa !11
  %46 = icmp eq i64 %45, 8
  br i1 %46, label %59, label %47

47:                                               ; preds = %42
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.ByteArray_st, ptr %48, i32 0, i32 1
  %50 = load i64, ptr %49, align 8, !tbaa !11
  %51 = icmp eq i64 %50, 16
  br i1 %51, label %59, label %52

52:                                               ; preds = %47
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.ByteArray_st, ptr %53, i32 0, i32 1
  %55 = load i64, ptr %54, align 8, !tbaa !11
  %56 = icmp eq i64 %55, 24
  br i1 %56, label %59, label %57

57:                                               ; preds = %52
  store i32 2, ptr %7, align 4, !tbaa !9
  %58 = load i32, ptr %7, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 2101, i32 noundef %58, ptr noundef null)
  br label %110

59:                                               ; preds = %52, %47, %42
  br label %60

60:                                               ; preds = %59
  br label %61

61:                                               ; preds = %60
  br label %62

62:                                               ; preds = %61
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = call i32 @des_init_base(ptr noundef %63, ptr noundef %64)
  store i32 %65, ptr %7, align 4, !tbaa !9
  %66 = load i32, ptr %7, align 4, !tbaa !9
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %68, label %70

68:                                               ; preds = %62
  %69 = load i32, ptr %7, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 2103, i32 noundef %69)
  br label %110

70:                                               ; preds = %62
  br label %71

71:                                               ; preds = %70
  br label %72

72:                                               ; preds = %71
  br label %73

73:                                               ; preds = %72
  %74 = load ptr, ptr %6, align 8, !tbaa !5
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.DesCtx_st, ptr %75, i32 0, i32 0
  %77 = getelementptr inbounds [24 x i8], ptr %76, i64 0, i64 0
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  %79 = call i64 @ba_get_len(ptr noundef %78)
  %80 = call i32 @ba_to_uint8(ptr noundef %74, ptr noundef %77, i64 noundef %79)
  store i32 %80, ptr %7, align 4, !tbaa !9
  %81 = load i32, ptr %7, align 4, !tbaa !9
  %82 = icmp ne i32 %81, 0
  br i1 %82, label %83, label %85

83:                                               ; preds = %73
  %84 = load i32, ptr %7, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 2104, i32 noundef %84)
  br label %110

85:                                               ; preds = %73
  br label %86

86:                                               ; preds = %85
  br label %87

87:                                               ; preds = %86
  %88 = load ptr, ptr %4, align 8, !tbaa !5
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.DesCtx_st, ptr %89, i32 0, i32 1
  %91 = getelementptr inbounds [24 x i8], ptr %90, i64 0, i64 0
  call void @des_setup(ptr noundef %88, ptr noundef %91)
  %92 = load ptr, ptr %4, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.DesCtx_st, ptr %92, i32 0, i32 8
  store i32 4, ptr %93, align 8, !tbaa !14
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.DesCtx_st, ptr %94, i32 0, i32 3
  %96 = getelementptr inbounds [24 x i8], ptr %95, i64 0, i64 0
  %97 = load ptr, ptr %4, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.DesCtx_st, ptr %97, i32 0, i32 0
  %99 = getelementptr inbounds [24 x i8], ptr %98, i64 0, i64 0
  %100 = load ptr, ptr %6, align 8, !tbaa !5
  %101 = call i64 @ba_get_len(ptr noundef %100)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %96, ptr align 8 %99, i64 %101, i1 false)
  %102 = load ptr, ptr %4, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.DesCtx_st, ptr %102, i32 0, i32 2
  %104 = getelementptr inbounds [24 x i8], ptr %103, i64 0, i64 0
  %105 = load ptr, ptr %4, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.DesCtx_st, ptr %105, i32 0, i32 0
  %107 = getelementptr inbounds [24 x i8], ptr %106, i64 0, i64 0
  %108 = load ptr, ptr %6, align 8, !tbaa !5
  %109 = call i64 @ba_get_len(ptr noundef %108)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %104, ptr align 8 %107, i64 %109, i1 false)
  br label %110

110:                                              ; preds = %87, %83, %68, %57, %37, %27, %19, %11
  %111 = load i32, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret i32 %111
}

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

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

declare i64 @ba_get_len(ptr noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 8}
!12 = !{!"ByteArray_st", !6, i64 0, !13, i64 8}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !10, i64 896}
!15 = !{!"DesCtx_st", !7, i64 0, !7, i64 24, !7, i64 48, !7, i64 72, !13, i64 96, !7, i64 104, !7, i64 128, !7, i64 512, !10, i64 896}


; 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 [13 x i8], align 1

; Function Attrs: nounwind uwtable
declare hidden i32 @des_init_base(ptr noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare hidden void @des_setup(ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

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

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

7:                                                ; preds = %5
  %.not37 = icmp eq ptr %2, null
  br i1 %.not37, label %8, label %9

8:                                                ; preds = %7
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 2099, i32 noundef 2, ptr noundef null) #3
  br label %32

9:                                                ; preds = %7
  %10 = getelementptr inbounds i8, ptr %2, i64 8
  %11 = load i64, ptr %10, align 8, !tbaa !5
  %12 = icmp eq i64 %11, 8
  br i1 %12, label %14, label %13

13:                                               ; preds = %9
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 2100, i32 noundef 2, ptr noundef null) #3
  br label %32

14:                                               ; preds = %9
  %15 = getelementptr inbounds i8, ptr %1, i64 8
  %16 = load i64, ptr %15, align 8, !tbaa !5
  switch i64 %16, label %17 [
    i64 8, label %18
    i64 16, label %18
    i64 24, label %18
  ]

17:                                               ; preds = %14
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 2101, i32 noundef 2, ptr noundef null) #3
  br label %32

18:                                               ; preds = %14, %14, %14
  %19 = tail call i32 @des_init_base(ptr noundef nonnull %0, ptr noundef nonnull %1)
  %.not38 = icmp eq i32 %19, 0
  br i1 %.not38, label %21, label %20

20:                                               ; preds = %18
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 2103, i32 noundef %19) #3
  br label %32

21:                                               ; preds = %18
  %22 = tail call i64 @ba_get_len(ptr noundef nonnull %2) #3
  %23 = tail call i32 @ba_to_uint8(ptr noundef nonnull %2, ptr noundef nonnull %0, i64 noundef %22) #3
  %.not39 = icmp eq i32 %23, 0
  br i1 %.not39, label %25, label %24

24:                                               ; preds = %21
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 2104, i32 noundef %23) #3
  br label %32

25:                                               ; preds = %21
  %26 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void @des_setup(ptr noundef nonnull %0, ptr noundef nonnull %26)
  %27 = getelementptr inbounds i8, ptr %0, i64 896
  store i32 4, ptr %27, align 8, !tbaa !11
  %28 = getelementptr inbounds i8, ptr %0, i64 72
  %29 = tail call i64 @ba_get_len(ptr noundef nonnull %2) #3
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %28, ptr nonnull align 8 %0, i64 %29, i1 false)
  %30 = getelementptr inbounds i8, ptr %0, i64 48
  %31 = tail call i64 @ba_get_len(ptr noundef nonnull %2) #3
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %30, ptr nonnull align 8 %0, i64 %31, i1 false)
  br label %32

32:                                               ; preds = %25, %24, %20, %17, %13, %8, %6, %4
  %.0 = phi i32 [ %19, %20 ], [ %23, %24 ], [ 0, %25 ], [ 2, %17 ], [ 2, %13 ], [ 2, %8 ], [ 2, %6 ], [ 2, %4 ]
  ret i32 %.0
}

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

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

declare i64 @ba_get_len(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #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 = { "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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !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, !13, i64 896}
!12 = !{!"DesCtx_st", !8, i64 0, !8, i64 24, !8, i64 48, !8, i64 72, !10, i64 96, !8, i64 104, !8, i64 128, !8, i64 512, !13, i64 896}
!13 = !{!"int", !8, i64 0}


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