; LLVM IR from aws/s2n-tls :: tests/unit (s2n_client_auth_handshake_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_debug_info = type { ptr, ptr }
%struct.s2n_blob = type { ptr, i32, i32, i8 }
%struct.s2n_tls13_keys = type { i32, i32, i8, %struct.s2n_blob, %struct.s2n_blob, [48 x i8], [48 x i8], %struct.s2n_hmac_state }
%struct.s2n_hmac_state = type { i32, i16, i32, i16, i8, %struct.s2n_hash_state, %struct.s2n_hash_state, %struct.s2n_hash_state, %struct.s2n_hash_state, [128 x i8], [64 x i8] }
%struct.s2n_hash_state = type { ptr, i32, i8, i64, %union.anon.0 }
%union.anon.0 = 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 }

@_s2n_debug_info = external thread_local global %struct.s2n_debug_info, align 8
@s2n_errno = external thread_local global i32, align 4
@.str.20 = external hidden unnamed_addr constant [95 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [95 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [95 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #0

; Function Attrs: nounwind willreturn memory(read)
declare ptr @strrchr(ptr noundef, i32 noundef) #1

declare i32 @s2n_calculate_stacktrace() #2

; Function Attrs: nounwind uwtable
define dso_local i32 @s2n_tls13_mac_verify(ptr noundef %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  br label %8

8:                                                ; preds = %3
  %9 = load ptr, ptr %7, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.s2n_blob, ptr %9, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = icmp ne ptr %11, null
  br i1 %12, label %44, label %13

13:                                               ; preds = %8
  br label %14

14:                                               ; preds = %13
  br label %15

15:                                               ; preds = %14
  %16 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %17 = getelementptr inbounds %struct.s2n_debug_info, ptr %16, i32 0, i32 0
  store ptr @.str.20, ptr %17, align 8, !tbaa !12
  %18 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %19 = getelementptr inbounds %struct.s2n_debug_info, ptr %18, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8, !tbaa !12
  %21 = getelementptr inbounds i8, ptr %20, i64 21
  %22 = call ptr @strrchr(ptr noundef %21, i32 noundef 47) #4
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %31

24:                                               ; preds = %15
  %25 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %26 = getelementptr inbounds %struct.s2n_debug_info, ptr %25, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !12
  %28 = getelementptr inbounds i8, ptr %27, i64 21
  %29 = call ptr @strrchr(ptr noundef %28, i32 noundef 47) #4
  %30 = getelementptr inbounds i8, ptr %29, i64 1
  br label %36

31:                                               ; preds = %15
  %32 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %33 = getelementptr inbounds %struct.s2n_debug_info, ptr %32, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8, !tbaa !12
  %35 = getelementptr inbounds i8, ptr %34, i64 21
  br label %36

36:                                               ; preds = %31, %24
  %37 = phi ptr [ %30, %24 ], [ %35, %31 ]
  %38 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %39 = getelementptr inbounds %struct.s2n_debug_info, ptr %38, i32 0, i32 1
  store ptr %37, ptr %39, align 8, !tbaa !14
  %40 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653193, ptr %40, align 4, !tbaa !15
  %41 = call i32 @s2n_calculate_stacktrace()
  br label %42

42:                                               ; preds = %36
  store i32 -1, ptr %4, align 4
  br label %133

43:                                               ; No predecessors!
  br label %44

44:                                               ; preds = %43, %8
  br label %45

45:                                               ; preds = %44
  br label %46

46:                                               ; preds = %45
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.s2n_blob, ptr %47, i32 0, i32 1
  %49 = load i32, ptr %48, align 8, !tbaa !16
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.s2n_tls13_keys, ptr %50, i32 0, i32 2
  %52 = load i8, ptr %51, align 8, !tbaa !17
  %53 = zext i8 %52 to i32
  %54 = icmp eq i32 %49, %53
  br i1 %54, label %86, label %55

55:                                               ; preds = %46
  br label %56

56:                                               ; preds = %55
  br label %57

57:                                               ; preds = %56
  %58 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %59 = getelementptr inbounds %struct.s2n_debug_info, ptr %58, i32 0, i32 0
  store ptr @.str.21, ptr %59, align 8, !tbaa !12
  %60 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %61 = getelementptr inbounds %struct.s2n_debug_info, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !12
  %63 = getelementptr inbounds i8, ptr %62, i64 21
  %64 = call ptr @strrchr(ptr noundef %63, i32 noundef 47) #4
  %65 = icmp ne ptr %64, null
  br i1 %65, label %66, label %73

66:                                               ; preds = %57
  %67 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %68 = getelementptr inbounds %struct.s2n_debug_info, ptr %67, i32 0, i32 0
  %69 = load ptr, ptr %68, align 8, !tbaa !12
  %70 = getelementptr inbounds i8, ptr %69, i64 21
  %71 = call ptr @strrchr(ptr noundef %70, i32 noundef 47) #4
  %72 = getelementptr inbounds i8, ptr %71, i64 1
  br label %78

73:                                               ; preds = %57
  %74 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %75 = getelementptr inbounds %struct.s2n_debug_info, ptr %74, i32 0, i32 0
  %76 = load ptr, ptr %75, align 8, !tbaa !12
  %77 = getelementptr inbounds i8, ptr %76, i64 21
  br label %78

78:                                               ; preds = %73, %66
  %79 = phi ptr [ %72, %66 ], [ %77, %73 ]
  %80 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %81 = getelementptr inbounds %struct.s2n_debug_info, ptr %80, i32 0, i32 1
  store ptr %79, ptr %81, align 8, !tbaa !14
  %82 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 402653194, ptr %82, align 4, !tbaa !15
  %83 = call i32 @s2n_calculate_stacktrace()
  br label %84

84:                                               ; preds = %78
  store i32 -1, ptr %4, align 4
  br label %133

85:                                               ; No predecessors!
  br label %86

86:                                               ; preds = %85, %46
  br label %87

87:                                               ; preds = %86
  br label %88

88:                                               ; preds = %87
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.s2n_blob, ptr %89, i32 0, i32 0
  %91 = load ptr, ptr %90, align 8, !tbaa !9
  %92 = load ptr, ptr %7, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.s2n_blob, ptr %92, i32 0, i32 0
  %94 = load ptr, ptr %93, align 8, !tbaa !9
  %95 = load ptr, ptr %5, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.s2n_tls13_keys, ptr %95, i32 0, i32 2
  %97 = load i8, ptr %96, align 8, !tbaa !17
  %98 = zext i8 %97 to i32
  %99 = call zeroext i1 @s2n_constant_time_equals(ptr noundef %91, ptr noundef %94, i32 noundef %98)
  br i1 %99, label %131, label %100

100:                                              ; preds = %88
  br label %101

101:                                              ; preds = %100
  br label %102

102:                                              ; preds = %101
  %103 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %104 = getelementptr inbounds %struct.s2n_debug_info, ptr %103, i32 0, i32 0
  store ptr @.str.22, ptr %104, align 8, !tbaa !12
  %105 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %106 = getelementptr inbounds %struct.s2n_debug_info, ptr %105, i32 0, i32 0
  %107 = load ptr, ptr %106, align 8, !tbaa !12
  %108 = getelementptr inbounds i8, ptr %107, i64 21
  %109 = call ptr @strrchr(ptr noundef %108, i32 noundef 47) #4
  %110 = icmp ne ptr %109, null
  br i1 %110, label %111, label %118

111:                                              ; preds = %102
  %112 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %113 = getelementptr inbounds %struct.s2n_debug_info, ptr %112, i32 0, i32 0
  %114 = load ptr, ptr %113, align 8, !tbaa !12
  %115 = getelementptr inbounds i8, ptr %114, i64 21
  %116 = call ptr @strrchr(ptr noundef %115, i32 noundef 47) #4
  %117 = getelementptr inbounds i8, ptr %116, i64 1
  br label %123

118:                                              ; preds = %102
  %119 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %120 = getelementptr inbounds %struct.s2n_debug_info, ptr %119, i32 0, i32 0
  %121 = load ptr, ptr %120, align 8, !tbaa !12
  %122 = getelementptr inbounds i8, ptr %121, i64 21
  br label %123

123:                                              ; preds = %118, %111
  %124 = phi ptr [ %117, %111 ], [ %122, %118 ]
  %125 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %126 = getelementptr inbounds %struct.s2n_debug_info, ptr %125, i32 0, i32 1
  store ptr %124, ptr %126, align 8, !tbaa !14
  %127 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 335544322, ptr %127, align 4, !tbaa !15
  %128 = call i32 @s2n_calculate_stacktrace()
  br label %129

129:                                              ; preds = %123
  store i32 -1, ptr %4, align 4
  br label %133

130:                                              ; No predecessors!
  br label %131

131:                                              ; preds = %130, %88
  br label %132

132:                                              ; preds = %131
  store i32 0, ptr %4, align 4
  br label %133

133:                                              ; preds = %132, %129, %84, %42
  %134 = load i32, ptr %4, align 4
  ret i32 %134
}

declare zeroext i1 @s2n_constant_time_equals(ptr noundef, ptr noundef, i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 #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 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 #4 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"s2n_blob", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !6, i64 0}
!13 = !{!"s2n_debug_info", !6, i64 0, !6, i64 8}
!14 = !{!13, !6, i64 8}
!15 = !{!11, !11, i64 0}
!16 = !{!10, !11, i64 8}
!17 = !{!18, !7, i64 8}
!18 = !{!"s2n_tls13_keys", !11, i64 0, !11, i64 4, !7, i64 8, !10, i64 16, !10, i64 40, !7, i64 64, !7, i64 112, !19, i64 160}
!19 = !{!"s2n_hmac_state", !11, i64 0, !20, i64 4, !11, i64 8, !20, i64 12, !7, i64 14, !21, i64 16, !21, i64 72, !21, i64 128, !21, i64 184, !7, i64 240, !7, i64 368}
!20 = !{!"short", !7, i64 0}
!21 = !{!"s2n_hash_state", !6, i64 0, !11, i64 8, !7, i64 12, !22, i64 16, !7, i64 24}
!22 = !{!"long", !7, 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.s2n_debug_info = type { ptr, ptr }

@_s2n_debug_info = external thread_local local_unnamed_addr global %struct.s2n_debug_info, align 8
@s2n_errno = external thread_local local_unnamed_addr global i32, align 4
@.str.20 = external hidden unnamed_addr constant [95 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [95 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [95 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare ptr @strrchr(ptr noundef, i32 noundef) local_unnamed_addr #1

declare i32 @s2n_calculate_stacktrace() local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @s2n_tls13_mac_verify(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2) local_unnamed_addr #3 {
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %.sink.split, label %5

5:                                                ; preds = %3
  %6 = getelementptr inbounds i8, ptr %2, i64 8
  %7 = load i32, ptr %6, align 8, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load i8, ptr %8, align 8, !tbaa !12
  %10 = zext i8 %9 to i32
  %11 = icmp eq i32 %7, %10
  br i1 %11, label %12, label %.sink.split

12:                                               ; preds = %5
  %13 = load ptr, ptr %1, align 8, !tbaa !5
  %14 = tail call zeroext i1 @s2n_constant_time_equals(ptr noundef %13, ptr noundef nonnull %4, i32 noundef %7) #4
  br i1 %14, label %22, label %.sink.split

.sink.split:                                      ; preds = %12, %5, %3
  %.str.22.sink = phi ptr [ @.str.20, %3 ], [ @.str.21, %5 ], [ @.str.22, %12 ]
  %.sink22 = phi ptr [ getelementptr inbounds (i8, ptr @.str.20, i64 21), %3 ], [ getelementptr inbounds (i8, ptr @.str.21, i64 21), %5 ], [ getelementptr inbounds (i8, ptr @.str.22, i64 21), %12 ]
  %.sink = phi i32 [ 402653193, %3 ], [ 402653194, %5 ], [ 335544322, %12 ]
  %15 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr %.str.22.sink, ptr %15, align 8, !tbaa !18
  %16 = tail call ptr @strrchr(ptr noundef nonnull dereferenceable(1) %.sink22, i32 noundef 47) #5
  %.not13 = icmp eq ptr %16, null
  %17 = getelementptr inbounds i8, ptr %16, i64 1
  %18 = select i1 %.not13, ptr %.sink22, ptr %17
  %19 = getelementptr inbounds i8, ptr %15, i64 8
  store ptr %18, ptr %19, align 8, !tbaa !20
  %20 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 %.sink, ptr %20, align 4, !tbaa !21
  %21 = tail call i32 @s2n_calculate_stacktrace() #4
  br label %22

22:                                               ; preds = %.sink.split, %12
  %.0 = phi i32 [ 0, %12 ], [ -1, %.sink.split ]
  ret i32 %.0
}

declare zeroext i1 @s2n_constant_time_equals(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree nounwind willreturn memory(argmem: 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 #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 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 #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, !7, i64 0}
!6 = !{!"s2n_blob", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!13, !8, i64 8}
!13 = !{!"s2n_tls13_keys", !10, i64 0, !10, i64 4, !8, i64 8, !6, i64 16, !6, i64 40, !8, i64 64, !8, i64 112, !14, i64 160}
!14 = !{!"s2n_hmac_state", !10, i64 0, !15, i64 4, !10, i64 8, !15, i64 12, !8, i64 14, !16, i64 16, !16, i64 72, !16, i64 128, !16, i64 184, !8, i64 240, !8, i64 368}
!15 = !{!"short", !8, i64 0}
!16 = !{!"s2n_hash_state", !7, i64 0, !10, i64 8, !8, i64 12, !17, i64 16, !8, i64 24}
!17 = !{!"long", !8, i64 0}
!18 = !{!19, !7, i64 0}
!19 = !{!"s2n_debug_info", !7, i64 0, !7, i64 8}
!20 = !{!19, !7, i64 8}
!21 = !{!10, !10, i64 0}


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