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

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

@.str = external hidden unnamed_addr constant [19 x i8], align 1
@gost34311_self_test.H1 = external hidden constant [32 x i8], align 16
@gost34311_self_test.H2 = external hidden constant [32 x i8], align 16
@gost34311_self_test.ba_M1 = external hidden constant %struct.ByteArray_st, align 8
@gost34311_self_test.ba_M2 = external hidden constant %struct.ByteArray_st, align 8

; Function Attrs: nounwind uwtable
declare dso_local ptr @gost34311_alloc(i32 noundef, ptr noundef) #0

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @gost34311_free(ptr noundef) #0

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @gost34311_update(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @gost34311_final(ptr noundef, ptr noundef) #0

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

4:                                                ; preds = %0
  %5 = call ptr @gost34311_alloc(i32 noundef 11, ptr noundef null)
  store ptr %5, ptr %2, align 8, !tbaa !9
  %6 = icmp eq ptr null, %5
  br i1 %6, label %7, label %9

7:                                                ; preds = %4
  store i32 2, ptr %1, align 4, !tbaa !5
  %8 = load i32, ptr %1, align 4, !tbaa !5
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 460, i32 noundef %8)
  br label %85

9:                                                ; preds = %4
  br label %10

10:                                               ; preds = %9
  br label %11

11:                                               ; preds = %10
  br label %12

12:                                               ; preds = %11
  %13 = load ptr, ptr %2, align 8, !tbaa !9
  %14 = call i32 @gost34311_update(ptr noundef %13, ptr noundef @gost34311_self_test.ba_M1)
  store i32 %14, ptr %1, align 4, !tbaa !5
  %15 = load i32, ptr %1, align 4, !tbaa !5
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %19

17:                                               ; preds = %12
  %18 = load i32, ptr %1, align 4, !tbaa !5
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 461, i32 noundef %18)
  br label %85

19:                                               ; preds = %12
  br label %20

20:                                               ; preds = %19
  br label %21

21:                                               ; preds = %20
  br label %22

22:                                               ; preds = %21
  %23 = load ptr, ptr %2, align 8, !tbaa !9
  %24 = call i32 @gost34311_final(ptr noundef %23, ptr noundef %3)
  store i32 %24, ptr %1, align 4, !tbaa !5
  %25 = load i32, ptr %1, align 4, !tbaa !5
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %29

27:                                               ; preds = %22
  %28 = load i32, ptr %1, align 4, !tbaa !5
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 462, i32 noundef %28)
  br label %85

29:                                               ; preds = %22
  br label %30

30:                                               ; preds = %29
  br label %31

31:                                               ; preds = %30
  %32 = load ptr, ptr %3, align 8, !tbaa !9
  %33 = getelementptr inbounds %struct.ByteArray_st, ptr %32, i32 0, i32 1
  %34 = load i64, ptr %33, align 8, !tbaa !11
  %35 = icmp ne i64 %34, 32
  br i1 %35, label %42, label %36

36:                                               ; preds = %31
  %37 = load ptr, ptr %3, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.ByteArray_st, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !14
  %40 = call i32 @memcmp(ptr noundef %39, ptr noundef @gost34311_self_test.H1, i64 noundef 32) #5
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %42, label %47

42:                                               ; preds = %36, %31
  br label %43

43:                                               ; preds = %42
  store i32 33, ptr %1, align 4, !tbaa !5
  %44 = load i32, ptr %1, align 4, !tbaa !5
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 465, i32 noundef %44, ptr noundef null)
  br label %85

45:                                               ; No predecessors!
  br label %46

46:                                               ; preds = %45
  br label %47

47:                                               ; preds = %46, %36
  %48 = load ptr, ptr %3, align 8, !tbaa !9
  call void @ba_free(ptr noundef %48)
  store ptr null, ptr %3, align 8, !tbaa !9
  br label %49

49:                                               ; preds = %47
  %50 = load ptr, ptr %2, align 8, !tbaa !9
  %51 = call i32 @gost34311_update(ptr noundef %50, ptr noundef @gost34311_self_test.ba_M2)
  store i32 %51, ptr %1, align 4, !tbaa !5
  %52 = load i32, ptr %1, align 4, !tbaa !5
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %54, label %56

54:                                               ; preds = %49
  %55 = load i32, ptr %1, align 4, !tbaa !5
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 470, i32 noundef %55)
  br label %85

56:                                               ; preds = %49
  br label %57

57:                                               ; preds = %56
  br label %58

58:                                               ; preds = %57
  br label %59

59:                                               ; preds = %58
  %60 = load ptr, ptr %2, align 8, !tbaa !9
  %61 = call i32 @gost34311_final(ptr noundef %60, ptr noundef %3)
  store i32 %61, ptr %1, align 4, !tbaa !5
  %62 = load i32, ptr %1, align 4, !tbaa !5
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %66

64:                                               ; preds = %59
  %65 = load i32, ptr %1, align 4, !tbaa !5
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 471, i32 noundef %65)
  br label %85

66:                                               ; preds = %59
  br label %67

67:                                               ; preds = %66
  br label %68

68:                                               ; preds = %67
  %69 = load ptr, ptr %3, align 8, !tbaa !9
  %70 = getelementptr inbounds %struct.ByteArray_st, ptr %69, i32 0, i32 1
  %71 = load i64, ptr %70, align 8, !tbaa !11
  %72 = icmp ne i64 %71, 32
  br i1 %72, label %79, label %73

73:                                               ; preds = %68
  %74 = load ptr, ptr %3, align 8, !tbaa !9
  %75 = getelementptr inbounds %struct.ByteArray_st, ptr %74, i32 0, i32 0
  %76 = load ptr, ptr %75, align 8, !tbaa !14
  %77 = call i32 @memcmp(ptr noundef %76, ptr noundef @gost34311_self_test.H2, i64 noundef 32) #5
  %78 = icmp ne i32 %77, 0
  br i1 %78, label %79, label %84

79:                                               ; preds = %73, %68
  br label %80

80:                                               ; preds = %79
  store i32 33, ptr %1, align 4, !tbaa !5
  %81 = load i32, ptr %1, align 4, !tbaa !5
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 474, i32 noundef %81, ptr noundef null)
  br label %85

82:                                               ; No predecessors!
  br label %83

83:                                               ; preds = %82
  br label %84

84:                                               ; preds = %83, %73
  br label %85

85:                                               ; preds = %84, %80, %64, %54, %43, %27, %17, %7
  %86 = load ptr, ptr %2, align 8, !tbaa !9
  call void @gost34311_free(ptr noundef %86)
  %87 = load ptr, ptr %3, align 8, !tbaa !9
  call void @ba_free(ptr noundef %87)
  %88 = load i32, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  ret i32 %88
}

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #3

declare void @ba_free(ptr noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 willreturn memory(read) "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 #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !13, i64 8}
!12 = !{!"ByteArray_st", !10, i64 0, !13, i64 8}
!13 = !{!"long", !7, i64 0}
!14 = !{!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"

%struct.ByteArray_st = type { ptr, i64 }

@.str = external hidden unnamed_addr constant [19 x i8], align 1
@gost34311_self_test.H1 = external hidden constant [32 x i8], align 16
@gost34311_self_test.H2 = external hidden constant [32 x i8], align 16
@gost34311_self_test.ba_M1 = external hidden constant %struct.ByteArray_st, align 8
@gost34311_self_test.ba_M2 = external hidden constant %struct.ByteArray_st, align 8

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @gost34311_free(ptr noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @gost34311_self_test() local_unnamed_addr #0 {
  %1 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  store ptr null, ptr %1, align 8, !tbaa !5
  %2 = tail call ptr @gost34311_alloc(i32 noundef 11, ptr noundef null)
  %3 = icmp eq ptr %2, null
  br i1 %3, label %4, label %5

4:                                                ; preds = %0
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 460, i32 noundef 2) #4
  br label %31

5:                                                ; preds = %0
  %6 = tail call i32 @gost34311_update(ptr noundef nonnull %2, ptr noundef nonnull @gost34311_self_test.ba_M1)
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %8, label %7

7:                                                ; preds = %5
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 461, i32 noundef %6) #4
  br label %31

8:                                                ; preds = %5
  %9 = call i32 @gost34311_final(ptr noundef nonnull %2, ptr noundef nonnull %1)
  %.not21 = icmp eq i32 %9, 0
  br i1 %.not21, label %11, label %10

10:                                               ; preds = %8
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 462, i32 noundef %9) #4
  br label %31

11:                                               ; preds = %8
  %12 = load ptr, ptr %1, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %12, i64 8
  %14 = load i64, ptr %13, align 8, !tbaa !9
  %.not22 = icmp eq i64 %14, 32
  br i1 %.not22, label %15, label %17

15:                                               ; preds = %11
  %16 = load ptr, ptr %12, align 8, !tbaa !12
  %bcmp = call i32 @bcmp(ptr noundef nonnull dereferenceable(32) %16, ptr noundef nonnull dereferenceable(32) @gost34311_self_test.H1, i64 32)
  %.not23 = icmp eq i32 %bcmp, 0
  br i1 %.not23, label %18, label %17

17:                                               ; preds = %11, %15
  call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 465, i32 noundef 33, ptr noundef null) #4
  br label %31

18:                                               ; preds = %15
  call void @ba_free(ptr noundef nonnull %12) #4
  store ptr null, ptr %1, align 8, !tbaa !5
  %19 = call i32 @gost34311_update(ptr noundef nonnull %2, ptr noundef nonnull @gost34311_self_test.ba_M2)
  %.not24 = icmp eq i32 %19, 0
  br i1 %.not24, label %21, label %20

20:                                               ; preds = %18
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 470, i32 noundef %19) #4
  br label %31

21:                                               ; preds = %18
  %22 = call i32 @gost34311_final(ptr noundef nonnull %2, ptr noundef nonnull %1)
  %.not25 = icmp eq i32 %22, 0
  br i1 %.not25, label %24, label %23

23:                                               ; preds = %21
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 471, i32 noundef %22) #4
  br label %31

24:                                               ; preds = %21
  %25 = load ptr, ptr %1, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %25, i64 8
  %27 = load i64, ptr %26, align 8, !tbaa !9
  %.not26 = icmp eq i64 %27, 32
  br i1 %.not26, label %28, label %30

28:                                               ; preds = %24
  %29 = load ptr, ptr %25, align 8, !tbaa !12
  %bcmp27 = call i32 @bcmp(ptr noundef nonnull dereferenceable(32) %29, ptr noundef nonnull dereferenceable(32) @gost34311_self_test.H2, i64 32)
  %.not28 = icmp eq i32 %bcmp27, 0
  br i1 %.not28, label %31, label %30

30:                                               ; preds = %24, %28
  call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 474, i32 noundef 33, ptr noundef null) #4
  br label %31

31:                                               ; preds = %28, %30, %23, %20, %17, %10, %7, %4
  %.0 = phi i32 [ 2, %4 ], [ %6, %7 ], [ %9, %10 ], [ 33, %17 ], [ %19, %20 ], [ %22, %23 ], [ 33, %30 ], [ 0, %28 ]
  call void @gost34311_free(ptr noundef %2)
  %32 = load ptr, ptr %1, align 8, !tbaa !5
  call void @ba_free(ptr noundef %32) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  ret i32 %.0
}

declare void @ba_free(ptr noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #3

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nofree nounwind willreturn memory(argmem: read) }
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, !11, i64 8}
!10 = !{!"ByteArray_st", !6, i64 0, !11, i64 8}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !6, i64 0}


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