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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @des_init_ctr(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 2142, i32 noundef %12, ptr noundef null)
  br label %91

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 2143, i32 noundef %20, ptr noundef null)
  br label %91

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 2144, i32 noundef %28, ptr noundef null)
  br label %91

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 %4, align 8, !tbaa !5
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = call i32 @des_init_base(ptr noundef %33, ptr noundef %34)
  store i32 %35, ptr %7, align 4, !tbaa !9
  %36 = load i32, ptr %7, align 4, !tbaa !9
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %40

38:                                               ; preds = %32
  %39 = load i32, ptr %7, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 2146, i32 noundef %39)
  br label %91

40:                                               ; preds = %32
  br label %41

41:                                               ; preds = %40
  br label %42

42:                                               ; preds = %41
  br label %43

43:                                               ; preds = %42
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.DesCtx_st, ptr %45, i32 0, i32 0
  %47 = getelementptr inbounds [24 x i8], ptr %46, i64 0, i64 0
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = call i64 @ba_get_len(ptr noundef %48)
  %50 = call i32 @ba_to_uint8(ptr noundef %44, ptr noundef %47, i64 noundef %49)
  store i32 %50, ptr %7, align 4, !tbaa !9
  %51 = load i32, ptr %7, align 4, !tbaa !9
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %55

53:                                               ; preds = %43
  %54 = load i32, ptr %7, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 2147, i32 noundef %54)
  br label %91

55:                                               ; preds = %43
  br label %56

56:                                               ; preds = %55
  br label %57

57:                                               ; preds = %56
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.DesCtx_st, ptr %59, i32 0, i32 1
  %61 = getelementptr inbounds [24 x i8], ptr %60, i64 0, i64 0
  call void @des_setup(ptr noundef %58, ptr noundef %61)
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.DesCtx_st, ptr %62, i32 0, i32 8
  store i32 1, ptr %63, align 8, !tbaa !11
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.DesCtx_st, ptr %64, i32 0, i32 3
  %66 = getelementptr inbounds [24 x i8], ptr %65, i64 0, i64 0
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.DesCtx_st, ptr %67, i32 0, i32 0
  %69 = getelementptr inbounds [24 x i8], ptr %68, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %66, ptr align 8 %69, i64 8, i1 false)
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.DesCtx_st, ptr %70, i32 0, i32 2
  %72 = getelementptr inbounds [24 x i8], ptr %71, i64 0, i64 0
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.DesCtx_st, ptr %73, i32 0, i32 0
  %75 = getelementptr inbounds [24 x i8], ptr %74, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %72, ptr align 8 %75, i64 8, i1 false)
  br label %76

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

84:                                               ; preds = %76
  %85 = load i32, ptr %7, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 2154, i32 noundef %85)
  br label %91

86:                                               ; preds = %76
  br label %87

87:                                               ; preds = %86
  br label %88

88:                                               ; preds = %87
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.DesCtx_st, ptr %89, i32 0, i32 4
  store i64 8, ptr %90, align 8, !tbaa !14
  br label %91

91:                                               ; preds = %88, %84, %53, %38, %27, %19, %11
  %92 = load i32, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret i32 %92
}

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, !10, i64 896}
!12 = !{!"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}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !13, i64 96}


; 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

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: nounwind uwtable
define dso_local i32 @des_init_ctr(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 2142, i32 noundef 2, ptr noundef null) #2
  br label %27

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

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

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

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

9:                                                ; preds = %7
  %10 = tail call i32 @des_init_base(ptr noundef nonnull %0, ptr noundef nonnull %1)
  %.not35 = icmp eq i32 %10, 0
  br i1 %.not35, label %12, label %11

11:                                               ; preds = %9
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 2146, i32 noundef %10) #2
  br label %27

12:                                               ; preds = %9
  %13 = tail call i64 @ba_get_len(ptr noundef nonnull %2) #2
  %14 = tail call i32 @ba_to_uint8(ptr noundef nonnull %2, ptr noundef nonnull %0, i64 noundef %13) #2
  %.not36 = icmp eq i32 %14, 0
  br i1 %.not36, label %16, label %15

15:                                               ; preds = %12
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 2147, i32 noundef %14) #2
  br label %27

16:                                               ; preds = %12
  %17 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void @des_setup(ptr noundef nonnull %0, ptr noundef nonnull %17)
  %18 = getelementptr inbounds i8, ptr %0, i64 896
  store i32 1, ptr %18, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %0, i64 72
  %20 = load i64, ptr %0, align 8
  store i64 %20, ptr %19, align 8
  %21 = getelementptr inbounds i8, ptr %0, i64 48
  store i64 %20, ptr %21, align 8
  %22 = getelementptr inbounds i8, ptr %0, i64 104
  %23 = tail call i32 @ba_to_uint8(ptr noundef nonnull %2, ptr noundef nonnull %22, i64 noundef 8) #2
  %.not37 = icmp eq i32 %23, 0
  br i1 %.not37, label %25, label %24

24:                                               ; preds = %16
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 2154, i32 noundef %23) #2
  br label %27

25:                                               ; preds = %16
  %26 = getelementptr inbounds i8, ptr %0, i64 96
  store i64 8, ptr %26, align 8, !tbaa !11
  br label %27

27:                                               ; preds = %25, %24, %15, %11, %8, %6, %4
  %.0 = phi i32 [ %10, %11 ], [ %14, %15 ], [ %23, %24 ], [ 0, %25 ], [ 2, %8 ], [ 2, %6 ], [ 2, %4 ]
  ret i32 %.0
}

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 = { 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 896}
!6 = !{!"DesCtx_st", !7, i64 0, !7, i64 24, !7, i64 48, !7, i64 72, !9, i64 96, !7, i64 104, !7, i64 128, !7, i64 512, !10, i64 896}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"long", !7, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!6, !9, i64 96}


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