; LLVM IR from aws/s2n-tls :: tests/unit (s2n_tls13_key_schedule_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.s2n_result = type { i32 }
%struct.s2n_hash_state = type { ptr, i32, i8, i64, %union.anon }
%union.anon = type { %struct.s2n_hash_evp_digest }
%struct.s2n_hash_evp_digest = type { %struct.s2n_evp_digest, %struct.s2n_evp_digest }
%struct.s2n_evp_digest = type { ptr, ptr }
%struct.s2n_blob = type { ptr, i32, i32, i8 }

@supported_hmacs = external hidden global [2 x i32], align 4

; Function Attrs: nounwind uwtable
define dso_local i32 @s2n_tls13_empty_transcripts_init() #0 {
  %1 = alloca %struct.s2n_result, align 4
  %2 = alloca %struct.s2n_hash_state, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca %struct.s2n_blob, align 8
  call void @llvm.lifetime.start.p0(i64 56, ptr %2) #4
  call void @llvm.memset.p0.i64(ptr align 8 %2, i8 0, i64 56, i1 false)
  br label %8

8:                                                ; preds = %0
  %9 = call i32 @s2n_hash_new(ptr noundef %2)
  %10 = icmp sgt i32 %9, -1
  br i1 %10, label %13, label %11

11:                                               ; preds = %8
  %12 = getelementptr inbounds %struct.s2n_result, ptr %1, i32 0, i32 0
  store i32 -1, ptr %12, align 4, !tbaa !5
  store i32 1, ptr %3, align 4
  br label %77

13:                                               ; preds = %8
  br label %14

14:                                               ; preds = %13
  br label %15

15:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store i64 0, ptr %5, align 8, !tbaa !11
  br label %16

16:                                               ; preds = %69, %15
  %17 = load i64, ptr %5, align 8, !tbaa !11
  %18 = icmp ult i64 %17, 2
  br i1 %18, label %20, label %19

19:                                               ; preds = %16
  store i32 4, ptr %3, align 4
  br label %72

20:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %21 = load i64, ptr %5, align 8, !tbaa !11
  %22 = getelementptr inbounds [2 x i32], ptr @supported_hmacs, i64 0, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !10
  store i32 %23, ptr %6, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #4
  %24 = getelementptr inbounds %struct.s2n_blob, ptr %7, i32 0, i32 0
  %25 = load i32, ptr %6, align 4, !tbaa !10
  %26 = call ptr @s2n_get_empty_context(i32 noundef %25)
  store ptr %26, ptr %24, align 8, !tbaa !13
  %27 = getelementptr inbounds %struct.s2n_blob, ptr %7, i32 0, i32 1
  %28 = load i32, ptr %6, align 4, !tbaa !10
  %29 = call zeroext i8 @s2n_get_hash_len(i32 noundef %28)
  %30 = zext i8 %29 to i32
  store i32 %30, ptr %27, align 8, !tbaa !16
  %31 = getelementptr inbounds %struct.s2n_blob, ptr %7, i32 0, i32 2
  store i32 0, ptr %31, align 4, !tbaa !17
  %32 = getelementptr inbounds %struct.s2n_blob, ptr %7, i32 0, i32 3
  %33 = load i8, ptr %32, align 8
  %34 = and i8 %33, -2
  %35 = or i8 %34, 0
  store i8 %35, ptr %32, align 8
  br label %36

36:                                               ; preds = %20
  %37 = load i32, ptr %6, align 4, !tbaa !10
  %38 = call i32 @s2n_hmac_hash_alg(i32 noundef %37, ptr noundef %4)
  %39 = icmp sgt i32 %38, -1
  br i1 %39, label %42, label %40

40:                                               ; preds = %36
  %41 = getelementptr inbounds %struct.s2n_result, ptr %1, i32 0, i32 0
  store i32 -1, ptr %41, align 4, !tbaa !5
  store i32 1, ptr %3, align 4
  br label %66

42:                                               ; preds = %36
  br label %43

43:                                               ; preds = %42
  br label %44

44:                                               ; preds = %43
  br label %45

45:                                               ; preds = %44
  %46 = load i32, ptr %4, align 4, !tbaa !10
  %47 = call i32 @s2n_hash_init(ptr noundef %2, i32 noundef %46)
  %48 = icmp sgt i32 %47, -1
  br i1 %48, label %51, label %49

49:                                               ; preds = %45
  %50 = getelementptr inbounds %struct.s2n_result, ptr %1, i32 0, i32 0
  store i32 -1, ptr %50, align 4, !tbaa !5
  store i32 1, ptr %3, align 4
  br label %66

51:                                               ; preds = %45
  br label %52

52:                                               ; preds = %51
  br label %53

53:                                               ; preds = %52
  br label %54

54:                                               ; preds = %53
  %55 = getelementptr inbounds %struct.s2n_blob, ptr %7, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !13
  %57 = getelementptr inbounds %struct.s2n_blob, ptr %7, i32 0, i32 1
  %58 = load i32, ptr %57, align 8, !tbaa !16
  %59 = call i32 @s2n_hash_digest(ptr noundef %2, ptr noundef %56, i32 noundef %58)
  %60 = icmp sgt i32 %59, -1
  br i1 %60, label %63, label %61

61:                                               ; preds = %54
  %62 = getelementptr inbounds %struct.s2n_result, ptr %1, i32 0, i32 0
  store i32 -1, ptr %62, align 4, !tbaa !5
  store i32 1, ptr %3, align 4
  br label %66

63:                                               ; preds = %54
  br label %64

64:                                               ; preds = %63
  br label %65

65:                                               ; preds = %64
  store i32 0, ptr %3, align 4
  br label %66

66:                                               ; preds = %65, %61, %49, %40
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %67 = load i32, ptr %3, align 4
  switch i32 %67, label %72 [
    i32 0, label %68
  ]

68:                                               ; preds = %66
  br label %69

69:                                               ; preds = %68
  %70 = load i64, ptr %5, align 8, !tbaa !11
  %71 = add i64 %70, 1
  store i64 %71, ptr %5, align 8, !tbaa !11
  br label %16, !llvm.loop !18

72:                                               ; preds = %66, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  %73 = load i32, ptr %3, align 4
  switch i32 %73, label %76 [
    i32 4, label %74
  ]

74:                                               ; preds = %72
  %75 = getelementptr inbounds %struct.s2n_result, ptr %1, i32 0, i32 0
  store i32 0, ptr %75, align 4, !tbaa !5
  store i32 1, ptr %3, align 4
  br label %76

76:                                               ; preds = %74, %72
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %77

77:                                               ; preds = %76, %11
  %78 = call i32 @s2n_hash_free(ptr noundef %2)
  call void @llvm.lifetime.end.p0(i64 56, ptr %2) #4
  %79 = getelementptr inbounds %struct.s2n_result, ptr %1, i32 0, i32 0
  %80 = load i32, ptr %79, align 4
  ret i32 %80
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

declare i32 @s2n_hash_free(ptr noundef) #3

declare i32 @s2n_hash_new(ptr noundef) #3

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i8 @s2n_get_hash_len(i32 noundef) #0

declare i32 @s2n_hmac_hash_alg(i32 noundef, ptr noundef) #3

declare i32 @s2n_hash_init(ptr noundef, i32 noundef) #3

declare i32 @s2n_hash_digest(ptr noundef, ptr noundef, i32 noundef) #3

; 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { "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 }

!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, !7, i64 0}
!6 = !{!"", !7, i64 0}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !8, i64 0}
!13 = !{!14, !15, i64 0}
!14 = !{!"s2n_blob", !15, i64 0, !7, i64 8, !7, i64 12, !7, i64 16}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!14, !7, i64 8}
!17 = !{!14, !7, i64 12}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; 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.s2n_hash_state = type { ptr, i32, i8, i64, %union.anon }
%union.anon = type { %struct.s2n_hash_evp_digest }
%struct.s2n_hash_evp_digest = type { %struct.s2n_evp_digest, %struct.s2n_evp_digest }
%struct.s2n_evp_digest = type { ptr, ptr }

@supported_hmacs = external hidden local_unnamed_addr global [2 x i32], align 4

; Function Attrs: nounwind uwtable
define dso_local i32 @s2n_tls13_empty_transcripts_init() local_unnamed_addr #0 {
  %1 = alloca %struct.s2n_hash_state, align 8
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %1) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(56) %1, i8 0, i64 56, i1 false)
  %3 = call i32 @s2n_hash_new(ptr noundef nonnull %1) #4
  %4 = icmp sgt i32 %3, -1
  br i1 %4, label %5, label %32

5:                                                ; preds = %0
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  %6 = load i32, ptr @supported_hmacs, align 4, !tbaa !5
  %7 = call ptr @s2n_get_empty_context(i32 noundef %6)
  %8 = call zeroext i8 @s2n_get_hash_len(i32 noundef %6)
  %9 = zext i8 %8 to i32
  %10 = call i32 @s2n_hmac_hash_alg(i32 noundef %6, ptr noundef nonnull %2) #4
  %11 = icmp sgt i32 %10, -1
  br i1 %11, label %25, label %.critedge

12:                                               ; preds = %29
  %13 = load i32, ptr getelementptr inbounds (i8, ptr @supported_hmacs, i64 4), align 4, !tbaa !5
  %14 = call ptr @s2n_get_empty_context(i32 noundef %13)
  %15 = call zeroext i8 @s2n_get_hash_len(i32 noundef %13)
  %16 = zext i8 %15 to i32
  %17 = call i32 @s2n_hmac_hash_alg(i32 noundef %13, ptr noundef nonnull %2) #4
  %18 = icmp sgt i32 %17, -1
  br i1 %18, label %19, label %.critedge

19:                                               ; preds = %12
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = call i32 @s2n_hash_init(ptr noundef nonnull %1, i32 noundef %20) #4
  %22 = icmp sgt i32 %21, -1
  br i1 %22, label %23, label %.critedge

23:                                               ; preds = %19
  %24 = call i32 @s2n_hash_digest(ptr noundef nonnull %1, ptr noundef %14, i32 noundef %16) #4
  %.lobit = ashr i32 %24, 31
  br label %.critedge

25:                                               ; preds = %5
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = call i32 @s2n_hash_init(ptr noundef nonnull %1, i32 noundef %26) #4
  %28 = icmp sgt i32 %27, -1
  br i1 %28, label %29, label %.critedge

29:                                               ; preds = %25
  %30 = call i32 @s2n_hash_digest(ptr noundef nonnull %1, ptr noundef %7, i32 noundef %9) #4
  %31 = icmp sgt i32 %30, -1
  br i1 %31, label %12, label %.critedge

.critedge:                                        ; preds = %23, %19, %12, %5, %25, %29
  %.lcssa = phi i32 [ -1, %5 ], [ -1, %25 ], [ -1, %29 ], [ -1, %12 ], [ -1, %19 ], [ %.lobit, %23 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  br label %32

32:                                               ; preds = %0, %.critedge
  %.sroa.09.4 = phi i32 [ %.lcssa, %.critedge ], [ -1, %0 ]
  %33 = call i32 @s2n_hash_free(ptr noundef nonnull %1) #4
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %1) #4
  ret i32 %.sroa.09.4
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

declare i32 @s2n_hash_free(ptr noundef) local_unnamed_addr #3

declare i32 @s2n_hash_new(ptr noundef) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i8 @s2n_get_hash_len(i32 noundef) local_unnamed_addr #0

declare i32 @s2n_hmac_hash_alg(i32 noundef, ptr noundef) local_unnamed_addr #3

declare i32 @s2n_hash_init(ptr noundef, i32 noundef) local_unnamed_addr #3

declare i32 @s2n_hash_digest(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { "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 }

!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"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,SROAPass,SimplifyCFGPass