; LLVM IR from intel/intel-ipsec-mb :: test/kat-app (hmac_sha1_test)

; 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.mac_test = type { i64, i64, i64, ptr, ptr, ptr, i32, i64, ptr, i64 }
%struct.test_suite_context = type { i32, i32, ptr }

@hmac_sha1_test_kat_json = external constant [0 x %struct.mac_test], align 8
@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [84 x i8], align 1
@__PRETTY_FUNCTION__.hmac_sha1_test = external hidden unnamed_addr constant [37 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [20 x i8], align 1

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

8:                                                ; preds = %14, %1
  %9 = load i32, ptr %5, align 4, !tbaa !9
  %10 = icmp ule i32 %9, 128
  br i1 %10, label %11, label %17

11:                                               ; preds = %8
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = load i32, ptr %5, align 4, !tbaa !9
  call void @test_hmac_sha1_std_vectors(ptr noundef %12, i32 noundef %13, ptr noundef %3)
  br label %14

14:                                               ; preds = %11
  %15 = load i32, ptr %5, align 4, !tbaa !9
  %16 = add i32 %15, 1
  store i32 %16, ptr %5, align 4, !tbaa !9
  br label %8, !llvm.loop !11

17:                                               ; preds = %8
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.mac_test, ptr %18, i32 0, i32 1
  %20 = load i64, ptr %19, align 8, !tbaa !13
  %21 = udiv i64 %20, 8
  %22 = icmp eq i64 %21, 20
  br i1 %22, label %23, label %24

23:                                               ; preds = %17
  br label %25

24:                                               ; preds = %17
  call void @__assert_fail(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 452, ptr noundef @__PRETTY_FUNCTION__.hmac_sha1_test) #5
  unreachable

25:                                               ; preds = %23
  store i32 4, ptr %6, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %41, %25
  %27 = load i32, ptr %6, align 4, !tbaa !9
  %28 = icmp ule i32 %27, 20
  br i1 %28, label %29, label %44

29:                                               ; preds = %26
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = zext i32 %32 to i64
  %34 = call i32 @test_hmac_sha1(ptr noundef %30, ptr noundef %31, i32 noundef 128, i64 noundef %33)
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %39

36:                                               ; preds = %29
  %37 = load i32, ptr %6, align 4, !tbaa !9
  %38 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %37)
  call void @test_suite_update(ptr noundef %3, i32 noundef 0, i32 noundef 1)
  br label %40

39:                                               ; preds = %29
  call void @test_suite_update(ptr noundef %3, i32 noundef 1, i32 noundef 0)
  br label %40

40:                                               ; preds = %39, %36
  br label %41

41:                                               ; preds = %40
  %42 = load i32, ptr %6, align 4, !tbaa !9
  %43 = add i32 %42, 1
  store i32 %43, ptr %6, align 4, !tbaa !9
  br label %26, !llvm.loop !16

44:                                               ; preds = %26
  %45 = call i32 @test_suite_end(ptr noundef %3)
  store i32 %45, ptr %4, align 4, !tbaa !9
  %46 = load i32, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #4
  ret i32 %46
}

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

declare void @test_suite_start(ptr noundef, ptr noundef) #2

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

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

declare i32 @printf(ptr noundef, ...) #2

declare void @test_suite_update(ptr noundef, i32 noundef, i32 noundef) #2

declare i32 @test_suite_end(ptr noundef) #2

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

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 = { noreturn nounwind "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 = { noreturn 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !15, i64 8}
!14 = !{!"mac_test", !15, i64 0, !15, i64 8, !15, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !10, i64 48, !15, i64 56, !6, i64 64, !15, i64 72}
!15 = !{!"long", !7, i64 0}
!16 = distinct !{!16, !12}


; 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.mac_test = type { i64, i64, i64, ptr, ptr, ptr, i32, i64, ptr, i64 }
%struct.test_suite_context = type { i32, i32, ptr }

@hmac_sha1_test_kat_json = external constant [0 x %struct.mac_test], align 8
@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [84 x i8], align 1
@__PRETTY_FUNCTION__.hmac_sha1_test = external hidden unnamed_addr constant [37 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @hmac_sha1_test(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca %struct.test_suite_context, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #5
  call void @test_suite_start(ptr noundef nonnull %2, ptr noundef nonnull @.str) #5
  br label %3

3:                                                ; preds = %1, %3
  %.01112 = phi i32 [ 1, %1 ], [ %4, %3 ]
  call void @test_hmac_sha1_std_vectors(ptr noundef %0, i32 noundef %.01112, ptr noundef nonnull %2)
  %4 = add nuw nsw i32 %.01112, 1
  %exitcond.not = icmp eq i32 %4, 129
  br i1 %exitcond.not, label %5, label %3, !llvm.loop !5

5:                                                ; preds = %3
  %6 = load i64, ptr getelementptr inbounds (i8, ptr @hmac_sha1_test_kat_json, i64 8), align 8, !tbaa !7
  %.mask = and i64 %6, -8
  %7 = icmp eq i64 %.mask, 160
  br i1 %7, label %.preheader, label %8

8:                                                ; preds = %5
  call void @__assert_fail(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 452, ptr noundef nonnull @__PRETTY_FUNCTION__.hmac_sha1_test) #6
  unreachable

.preheader:                                       ; preds = %5, %14
  %indvars.iv = phi i64 [ %indvars.iv.next, %14 ], [ 4, %5 ]
  %9 = call i32 @test_hmac_sha1(ptr noundef %0, ptr noundef nonnull @hmac_sha1_test_kat_json, i32 noundef 128, i64 noundef %indvars.iv)
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %13, label %10

10:                                               ; preds = %.preheader
  %11 = trunc nuw nsw i64 %indvars.iv to i32
  %12 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %11)
  call void @test_suite_update(ptr noundef nonnull %2, i32 noundef 0, i32 noundef 1) #5
  br label %14

13:                                               ; preds = %.preheader
  call void @test_suite_update(ptr noundef nonnull %2, i32 noundef 1, i32 noundef 0) #5
  br label %14

14:                                               ; preds = %10, %13
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond15.not = icmp eq i64 %indvars.iv.next, 21
  br i1 %exitcond15.not, label %15, label %.preheader, !llvm.loop !14

15:                                               ; preds = %14
  %16 = call i32 @test_suite_end(ptr noundef nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #5
  ret i32 %16
}

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

declare void @test_suite_start(ptr noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4

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

declare i32 @test_suite_end(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

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 = { noreturn nounwind "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 = { nofree nounwind "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 #5 = { nounwind }
attributes #6 = { noreturn 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !9, i64 8}
!8 = !{!"mac_test", !9, i64 0, !9, i64 8, !9, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !13, i64 48, !9, i64 56, !12, i64 64, !9, i64 72}
!9 = !{!"long", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!"any pointer", !10, i64 0}
!13 = !{!"int", !10, i64 0}
!14 = distinct !{!14, !6}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass