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

; 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
@whirlpool_self_test.hNULL = external hidden constant [64 x i8], align 16
@whirlpool_self_test.H1 = external hidden constant [64 x i8], align 16
@whirlpool_self_test.ba_M1 = external hidden constant %struct.ByteArray_st, align 8

; Function Attrs: nounwind uwtable
declare dso_local ptr @whirlpool_alloc() #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

; 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 @whirlpool_update(ptr noundef, ptr noundef) #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @whirlpool_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 @whirlpool_alloc()
  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 312, i32 noundef %8)
  br label %75

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 @whirlpool_final(ptr noundef %13, ptr noundef %3)
  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 313, i32 noundef %18)
  br label %75

19:                                               ; preds = %12
  br label %20

20:                                               ; preds = %19
  br label %21

21:                                               ; preds = %20
  %22 = load ptr, ptr %3, align 8, !tbaa !9
  %23 = getelementptr inbounds %struct.ByteArray_st, ptr %22, i32 0, i32 1
  %24 = load i64, ptr %23, align 8, !tbaa !11
  %25 = icmp ne i64 %24, 64
  br i1 %25, label %32, label %26

26:                                               ; preds = %21
  %27 = load ptr, ptr %3, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct.ByteArray_st, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !14
  %30 = call i32 @memcmp(ptr noundef %29, ptr noundef @whirlpool_self_test.hNULL, i64 noundef 64) #5
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %37

32:                                               ; preds = %26, %21
  br label %33

33:                                               ; preds = %32
  store i32 33, ptr %1, align 4, !tbaa !5
  %34 = load i32, ptr %1, align 4, !tbaa !5
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 316, i32 noundef %34, ptr noundef null)
  br label %75

35:                                               ; No predecessors!
  br label %36

36:                                               ; preds = %35
  br label %37

37:                                               ; preds = %36, %26
  %38 = load ptr, ptr %3, align 8, !tbaa !9
  call void @ba_free(ptr noundef %38)
  store ptr null, ptr %3, align 8, !tbaa !9
  br label %39

39:                                               ; preds = %37
  %40 = load ptr, ptr %2, align 8, !tbaa !9
  %41 = call i32 @whirlpool_update(ptr noundef %40, ptr noundef @whirlpool_self_test.ba_M1)
  store i32 %41, ptr %1, align 4, !tbaa !5
  %42 = load i32, ptr %1, align 4, !tbaa !5
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %46

44:                                               ; preds = %39
  %45 = load i32, ptr %1, align 4, !tbaa !5
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 321, i32 noundef %45)
  br label %75

46:                                               ; preds = %39
  br label %47

47:                                               ; preds = %46
  br label %48

48:                                               ; preds = %47
  br label %49

49:                                               ; preds = %48
  %50 = load ptr, ptr %2, align 8, !tbaa !9
  %51 = call i32 @whirlpool_final(ptr noundef %50, ptr noundef %3)
  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 322, i32 noundef %55)
  br label %75

56:                                               ; preds = %49
  br label %57

57:                                               ; preds = %56
  br label %58

58:                                               ; preds = %57
  %59 = load ptr, ptr %3, align 8, !tbaa !9
  %60 = getelementptr inbounds %struct.ByteArray_st, ptr %59, i32 0, i32 1
  %61 = load i64, ptr %60, align 8, !tbaa !11
  %62 = icmp ne i64 %61, 64
  br i1 %62, label %69, label %63

63:                                               ; preds = %58
  %64 = load ptr, ptr %3, align 8, !tbaa !9
  %65 = getelementptr inbounds %struct.ByteArray_st, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !14
  %67 = call i32 @memcmp(ptr noundef %66, ptr noundef @whirlpool_self_test.H1, i64 noundef 64) #5
  %68 = icmp ne i32 %67, 0
  br i1 %68, label %69, label %74

69:                                               ; preds = %63, %58
  br label %70

70:                                               ; preds = %69
  store i32 33, ptr %1, align 4, !tbaa !5
  %71 = load i32, ptr %1, align 4, !tbaa !5
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 325, i32 noundef %71, ptr noundef null)
  br label %75

72:                                               ; No predecessors!
  br label %73

73:                                               ; preds = %72
  br label %74

74:                                               ; preds = %73, %63
  br label %75

75:                                               ; preds = %74, %70, %54, %44, %33, %17, %7
  %76 = load ptr, ptr %3, align 8, !tbaa !9
  call void @ba_free(ptr noundef %76)
  %77 = load ptr, ptr %2, align 8, !tbaa !9
  call void @whirlpool_free(ptr noundef %77)
  %78 = 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 %78
}

; 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
@whirlpool_self_test.hNULL = external hidden constant [64 x i8], align 16
@whirlpool_self_test.H1 = external hidden constant [64 x i8], align 16
@whirlpool_self_test.ba_M1 = external hidden constant %struct.ByteArray_st, align 8

; Function Attrs: nounwind uwtable
declare dso_local ptr @whirlpool_alloc() 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

; 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 @whirlpool_update(ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @whirlpool_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 @whirlpool_alloc()
  %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 312, i32 noundef 2) #4
  br label %28

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

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

8:                                                ; preds = %5
  %9 = load ptr, ptr %1, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 8
  %11 = load i64, ptr %10, align 8, !tbaa !9
  %.not17 = icmp eq i64 %11, 64
  br i1 %.not17, label %12, label %14

12:                                               ; preds = %8
  %13 = load ptr, ptr %9, align 8, !tbaa !12
  %bcmp = call i32 @bcmp(ptr noundef nonnull dereferenceable(64) %13, ptr noundef nonnull dereferenceable(64) @whirlpool_self_test.hNULL, i64 64)
  %.not18 = icmp eq i32 %bcmp, 0
  br i1 %.not18, label %15, label %14

14:                                               ; preds = %8, %12
  call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 316, i32 noundef 33, ptr noundef null) #4
  br label %28

15:                                               ; preds = %12
  call void @ba_free(ptr noundef nonnull %9) #4
  store ptr null, ptr %1, align 8, !tbaa !5
  %16 = call i32 @whirlpool_update(ptr noundef nonnull %2, ptr noundef nonnull @whirlpool_self_test.ba_M1)
  %.not19 = icmp eq i32 %16, 0
  br i1 %.not19, label %18, label %17

17:                                               ; preds = %15
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 321, i32 noundef %16) #4
  br label %28

18:                                               ; preds = %15
  %19 = call i32 @whirlpool_final(ptr noundef nonnull %2, ptr noundef nonnull %1)
  %.not20 = icmp eq i32 %19, 0
  br i1 %.not20, label %21, label %20

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

21:                                               ; preds = %18
  %22 = load ptr, ptr %1, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %22, i64 8
  %24 = load i64, ptr %23, align 8, !tbaa !9
  %.not21 = icmp eq i64 %24, 64
  br i1 %.not21, label %25, label %27

25:                                               ; preds = %21
  %26 = load ptr, ptr %22, align 8, !tbaa !12
  %bcmp22 = call i32 @bcmp(ptr noundef nonnull dereferenceable(64) %26, ptr noundef nonnull dereferenceable(64) @whirlpool_self_test.H1, i64 64)
  %.not23 = icmp eq i32 %bcmp22, 0
  br i1 %.not23, label %28, label %27

27:                                               ; preds = %21, %25
  call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 325, i32 noundef 33, ptr noundef null) #4
  br label %28

28:                                               ; preds = %25, %27, %20, %17, %14, %7, %4
  %.0 = phi i32 [ 2, %4 ], [ %6, %7 ], [ 33, %14 ], [ %16, %17 ], [ %19, %20 ], [ 33, %27 ], [ 0, %25 ]
  %29 = load ptr, ptr %1, align 8, !tbaa !5
  call void @ba_free(ptr noundef %29) #4
  call void @whirlpool_free(ptr noundef %2)
  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