; LLVM IR from aws/s2n-tls :: tls (s2n_kem)

; 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_stuffer = type { %struct.s2n_blob, i32, i32, i32, i8 }
%struct.s2n_blob = type { ptr, i32, i32, i8 }
%struct.s2n_kem = type { ptr, i32, i16, i16, i16, i16, i16, ptr, 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.36 = external hidden unnamed_addr constant [84 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3

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

; Function Attrs: nounwind uwtable
define dso_local i32 @s2n_choose_kem_with_peer_pref_list(ptr noundef %0, ptr noundef %1, ptr noundef %2, i8 noundef zeroext %3, ptr noundef %4) #4 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i8, align 1
  %11 = alloca ptr, align 8
  %12 = alloca %struct.s2n_stuffer, align 8
  %13 = alloca i32, align 4
  %14 = alloca i8, align 1
  %15 = alloca i8, align 1
  %16 = alloca ptr, align 8
  %17 = alloca i8, align 1
  %18 = alloca i8, align 1
  %19 = alloca i16, align 2
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store i8 %3, ptr %10, align 1, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 40, ptr %12) #6
  call void @llvm.memset.p0.i64(ptr align 8 %12, i8 0, i64 40, i1 false)
  br label %20

20:                                               ; preds = %5
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = call i32 @s2n_stuffer_init(ptr noundef %12, ptr noundef %21)
  %23 = icmp sgt i32 %22, -1
  br i1 %23, label %25, label %24

24:                                               ; preds = %20
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %151

25:                                               ; preds = %20
  br label %26

26:                                               ; preds = %25
  br label %27

27:                                               ; preds = %26
  br label %28

28:                                               ; preds = %27
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = call i32 @s2n_stuffer_write(ptr noundef %12, ptr noundef %29)
  %31 = icmp sgt i32 %30, -1
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %151

33:                                               ; preds = %28
  br label %34

34:                                               ; preds = %33
  br label %35

35:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #6
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.s2n_blob, ptr %36, i32 0, i32 1
  %38 = load i32, ptr %37, align 8, !tbaa !10
  %39 = udiv i32 %38, 2
  %40 = trunc i32 %39 to i8
  store i8 %40, ptr %14, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #6
  store i8 0, ptr %15, align 1, !tbaa !9
  br label %41

41:                                               ; preds = %112, %35
  %42 = load i8, ptr %15, align 1, !tbaa !9
  %43 = zext i8 %42 to i32
  %44 = load i8, ptr %10, align 1, !tbaa !9
  %45 = zext i8 %44 to i32
  %46 = icmp slt i32 %43, %45
  br i1 %46, label %48, label %47

47:                                               ; preds = %41
  store i32 6, ptr %13, align 4
  br label %115

48:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %50 = load i8, ptr %15, align 1, !tbaa !9
  %51 = zext i8 %50 to i64
  %52 = getelementptr inbounds ptr, ptr %49, i64 %51
  %53 = load ptr, ptr %52, align 8, !tbaa !5
  store ptr %53, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %17) #6
  store i8 0, ptr %17, align 1, !tbaa !9
  br label %54

54:                                               ; preds = %48
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = load ptr, ptr %16, align 8, !tbaa !5
  %57 = call i32 @s2n_kem_check_kem_compatibility(ptr noundef %55, ptr noundef %56, ptr noundef %17)
  %58 = icmp sgt i32 %57, -1
  br i1 %58, label %60, label %59

59:                                               ; preds = %54
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %109

60:                                               ; preds = %54
  br label %61

61:                                               ; preds = %60
  br label %62

62:                                               ; preds = %61
  %63 = load i8, ptr %17, align 1, !tbaa !9
  %64 = icmp ne i8 %63, 0
  br i1 %64, label %66, label %65

65:                                               ; preds = %62
  store i32 8, ptr %13, align 4
  br label %109

66:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 1, ptr %18) #6
  store i8 0, ptr %18, align 1, !tbaa !9
  br label %67

67:                                               ; preds = %96, %66
  %68 = load i8, ptr %18, align 1, !tbaa !9
  %69 = zext i8 %68 to i32
  %70 = load i8, ptr %14, align 1, !tbaa !9
  %71 = zext i8 %70 to i32
  %72 = icmp slt i32 %69, %71
  br i1 %72, label %74, label %73

73:                                               ; preds = %67
  store i32 11, ptr %13, align 4
  br label %99

74:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 2, ptr %19) #6
  store i16 0, ptr %19, align 2, !tbaa !13
  br label %75

75:                                               ; preds = %74
  %76 = call i32 @s2n_stuffer_read_uint16(ptr noundef %12, ptr noundef %19)
  %77 = icmp sgt i32 %76, -1
  br i1 %77, label %79, label %78

78:                                               ; preds = %75
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %93

79:                                               ; preds = %75
  br label %80

80:                                               ; preds = %79
  br label %81

81:                                               ; preds = %80
  %82 = load ptr, ptr %16, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.s2n_kem, ptr %82, i32 0, i32 2
  %84 = load i16, ptr %83, align 4, !tbaa !15
  %85 = zext i16 %84 to i32
  %86 = load i16, ptr %19, align 2, !tbaa !13
  %87 = zext i16 %86 to i32
  %88 = icmp eq i32 %85, %87
  br i1 %88, label %89, label %92

89:                                               ; preds = %81
  %90 = load ptr, ptr %16, align 8, !tbaa !5
  %91 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %90, ptr %91, align 8, !tbaa !5
  store i32 0, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %93

92:                                               ; preds = %81
  store i32 0, ptr %13, align 4
  br label %93

93:                                               ; preds = %92, %89, %78
  call void @llvm.lifetime.end.p0(i64 2, ptr %19) #6
  %94 = load i32, ptr %13, align 4
  switch i32 %94, label %99 [
    i32 0, label %95
  ]

95:                                               ; preds = %93
  br label %96

96:                                               ; preds = %95
  %97 = load i8, ptr %18, align 1, !tbaa !9
  %98 = add i8 %97, 1
  store i8 %98, ptr %18, align 1, !tbaa !9
  br label %67, !llvm.loop !17

99:                                               ; preds = %93, %73
  call void @llvm.lifetime.end.p0(i64 1, ptr %18) #6
  %100 = load i32, ptr %13, align 4
  switch i32 %100, label %109 [
    i32 11, label %101
  ]

101:                                              ; preds = %99
  br label %102

102:                                              ; preds = %101
  %103 = call i32 @s2n_stuffer_reread(ptr noundef %12)
  %104 = icmp sgt i32 %103, -1
  br i1 %104, label %106, label %105

105:                                              ; preds = %102
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %109

106:                                              ; preds = %102
  br label %107

107:                                              ; preds = %106
  br label %108

108:                                              ; preds = %107
  store i32 0, ptr %13, align 4
  br label %109

109:                                              ; preds = %108, %105, %99, %65, %59
  call void @llvm.lifetime.end.p0(i64 1, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  %110 = load i32, ptr %13, align 4
  switch i32 %110, label %115 [
    i32 0, label %111
    i32 8, label %112
  ]

111:                                              ; preds = %109
  br label %112

112:                                              ; preds = %111, %109
  %113 = load i8, ptr %15, align 1, !tbaa !9
  %114 = add i8 %113, 1
  store i8 %114, ptr %15, align 1, !tbaa !9
  br label %41, !llvm.loop !19

115:                                              ; preds = %109, %47
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #6
  %116 = load i32, ptr %13, align 4
  switch i32 %116, label %150 [
    i32 6, label %117
  ]

117:                                              ; preds = %115
  br label %118

118:                                              ; preds = %117
  br label %119

119:                                              ; preds = %118
  %120 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %121 = getelementptr inbounds %struct.s2n_debug_info, ptr %120, i32 0, i32 0
  store ptr @.str.36, ptr %121, align 8, !tbaa !20
  %122 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %123 = getelementptr inbounds %struct.s2n_debug_info, ptr %122, i32 0, i32 0
  %124 = load ptr, ptr %123, align 8, !tbaa !20
  %125 = getelementptr inbounds i8, ptr %124, i64 21
  %126 = call ptr @strrchr(ptr noundef %125, i32 noundef 47) #7
  %127 = icmp ne ptr %126, null
  br i1 %127, label %128, label %135

128:                                              ; preds = %119
  %129 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %130 = getelementptr inbounds %struct.s2n_debug_info, ptr %129, i32 0, i32 0
  %131 = load ptr, ptr %130, align 8, !tbaa !20
  %132 = getelementptr inbounds i8, ptr %131, i64 21
  %133 = call ptr @strrchr(ptr noundef %132, i32 noundef 47) #7
  %134 = getelementptr inbounds i8, ptr %133, i64 1
  br label %140

135:                                              ; preds = %119
  %136 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %137 = getelementptr inbounds %struct.s2n_debug_info, ptr %136, i32 0, i32 0
  %138 = load ptr, ptr %137, align 8, !tbaa !20
  %139 = getelementptr inbounds i8, ptr %138, i64 21
  br label %140

140:                                              ; preds = %135, %128
  %141 = phi ptr [ %134, %128 ], [ %139, %135 ]
  %142 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  %143 = getelementptr inbounds %struct.s2n_debug_info, ptr %142, i32 0, i32 1
  store ptr %141, ptr %143, align 8, !tbaa !22
  %144 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 335544361, ptr %144, align 4, !tbaa !23
  %145 = call i32 @s2n_calculate_stacktrace()
  br label %146

146:                                              ; preds = %140
  br label %147

147:                                              ; preds = %146
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %150

148:                                              ; No predecessors!
  br label %149

149:                                              ; preds = %148
  store i32 0, ptr %13, align 4
  br label %150

150:                                              ; preds = %149, %147, %115
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #6
  br label %151

151:                                              ; preds = %150, %32, %24
  call void @llvm.lifetime.end.p0(i64 40, ptr %12) #6
  %152 = load i32, ptr %13, align 4
  switch i32 %152, label %155 [
    i32 0, label %153
    i32 1, label %153
  ]

153:                                              ; preds = %151, %151
  %154 = load i32, ptr %6, align 4
  ret i32 %154

155:                                              ; preds = %151
  unreachable
}

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

declare i32 @s2n_stuffer_init(ptr noundef, ptr noundef) #2

declare i32 @s2n_stuffer_write(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @s2n_kem_check_kem_compatibility(ptr noundef, ptr noundef, ptr noundef) #4

declare i32 @s2n_stuffer_read_uint16(ptr noundef, ptr noundef) #2

declare i32 @s2n_stuffer_reread(ptr 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind }
attributes #7 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !12, i64 8}
!11 = !{!"s2n_blob", !6, i64 0, !12, i64 8, !12, i64 12, !12, i64 16}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!16, !14, i64 12}
!16 = !{!"s2n_kem", !6, i64 0, !12, i64 8, !14, i64 12, !14, i64 14, !14, i64 16, !14, i64 18, !14, i64 20, !6, i64 24, !6, i64 32, !6, i64 40}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = !{!21, !6, i64 0}
!21 = !{!"s2n_debug_info", !6, i64 0, !6, i64 8}
!22 = !{!21, !6, i64 8}
!23 = !{!12, !12, 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 }
%struct.s2n_stuffer = type { %struct.s2n_blob, i32, i32, i32, i8 }
%struct.s2n_blob = type { ptr, i32, i32, i8 }

@_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.36 = external hidden unnamed_addr constant [84 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @s2n_choose_kem_with_peer_pref_list(ptr noundef %0, ptr noundef %1, ptr nocapture noundef readonly %2, i8 noundef zeroext %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #4 {
  %6 = alloca %struct.s2n_stuffer, align 8
  %7 = alloca i8, align 1
  %8 = alloca i16, align 2
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %6) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %6, i8 0, i64 40, i1 false)
  %9 = call i32 @s2n_stuffer_init(ptr noundef nonnull %6, ptr noundef %1) #6
  %10 = icmp sgt i32 %9, -1
  br i1 %10, label %11, label %53

11:                                               ; preds = %5
  %12 = call i32 @s2n_stuffer_write(ptr noundef nonnull %6, ptr noundef %1) #6
  %13 = icmp sgt i32 %12, -1
  br i1 %13, label %14, label %53

14:                                               ; preds = %11
  %.not3050.not = icmp eq i8 %3, 0
  br i1 %.not3050.not, label %.thread41, label %.lr.ph53

.lr.ph53:                                         ; preds = %14
  %15 = getelementptr inbounds i8, ptr %1, i64 8
  %16 = load i32, ptr %15, align 8, !tbaa !5
  %.fr = freeze i32 %16
  %17 = and i32 %.fr, 510
  %.not2948.not = icmp eq i32 %17, 0
  %wide.trip.count66 = zext i8 %3 to i64
  br i1 %.not2948.not, label %.lr.ph53.split, label %.lr.ph53.split.us.preheader

.lr.ph53.split.us.preheader:                      ; preds = %.lr.ph53
  %18 = lshr i32 %.fr, 1
  %19 = trunc i32 %18 to i8
  br label %.lr.ph53.split.us

.lr.ph53.split.us:                                ; preds = %.lr.ph53.split.us.preheader, %select.unfold.us
  %indvars.iv = phi i64 [ 0, %.lr.ph53.split.us.preheader ], [ %indvars.iv.next, %select.unfold.us ]
  %20 = getelementptr inbounds ptr, ptr %2, i64 %indvars.iv
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %7) #6
  store i8 0, ptr %7, align 1, !tbaa !12
  %22 = call i32 @s2n_kem_check_kem_compatibility(ptr noundef %0, ptr noundef %21, ptr noundef nonnull %7)
  %23 = icmp sgt i32 %22, -1
  br i1 %23, label %24, label %.thread43

24:                                               ; preds = %.lr.ph53.split.us
  %25 = load i8, ptr %7, align 1, !tbaa !12
  %.not.us = icmp eq i8 %25, 0
  br i1 %.not.us, label %select.unfold.us, label %.preheader.us

26:                                               ; preds = %.preheader.us, %33
  %.049.us = phi i8 [ 0, %.preheader.us ], [ %34, %33 ]
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %8) #6
  store i16 0, ptr %8, align 2, !tbaa !13
  %27 = call i32 @s2n_stuffer_read_uint16(ptr noundef nonnull %6, ptr noundef nonnull %8) #6
  %28 = icmp sgt i32 %27, -1
  br i1 %28, label %29, label %.thread34

29:                                               ; preds = %26
  %30 = load i16, ptr %35, align 4, !tbaa !15
  %31 = load i16, ptr %8, align 2, !tbaa !13
  %32 = icmp eq i16 %30, %31
  br i1 %32, label %.split.us, label %33

33:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %8) #6
  %34 = add nuw i8 %.049.us, 1
  %.not29.us = icmp ult i8 %34, %19
  br i1 %.not29.us, label %26, label %._crit_edge.us, !llvm.loop !17

select.unfold.us:                                 ; preds = %._crit_edge.us, %24
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %7) #6
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count66
  br i1 %exitcond.not, label %.thread41, label %.lr.ph53.split.us, !llvm.loop !19

.preheader.us:                                    ; preds = %24
  %35 = getelementptr inbounds i8, ptr %21, i64 12
  br label %26

._crit_edge.us:                                   ; preds = %33
  %36 = call i32 @s2n_stuffer_reread(ptr noundef nonnull %6) #6
  %37 = icmp sgt i32 %36, -1
  br i1 %37, label %select.unfold.us, label %.loopexit

.lr.ph53.split:                                   ; preds = %.lr.ph53, %select.unfold
  %indvars.iv63 = phi i64 [ %indvars.iv.next64, %select.unfold ], [ 0, %.lr.ph53 ]
  %38 = getelementptr inbounds ptr, ptr %2, i64 %indvars.iv63
  %39 = load ptr, ptr %38, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %7) #6
  store i8 0, ptr %7, align 1, !tbaa !12
  %40 = call i32 @s2n_kem_check_kem_compatibility(ptr noundef %0, ptr noundef %39, ptr noundef nonnull %7)
  %41 = icmp sgt i32 %40, -1
  br i1 %41, label %42, label %.thread43

.thread43:                                        ; preds = %.lr.ph53.split.us, %.lr.ph53.split
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %7) #6
  br label %53

42:                                               ; preds = %.lr.ph53.split
  %43 = load i8, ptr %7, align 1, !tbaa !12
  %.not = icmp eq i8 %43, 0
  br i1 %.not, label %select.unfold, label %.preheader

.preheader:                                       ; preds = %42
  %44 = call i32 @s2n_stuffer_reread(ptr noundef nonnull %6) #6
  %45 = icmp sgt i32 %44, -1
  br i1 %45, label %select.unfold, label %.loopexit

.split.us:                                        ; preds = %29
  store ptr %21, ptr %4, align 8, !tbaa !11
  br label %.thread34

.thread34:                                        ; preds = %26, %.split.us
  %.2.ph = phi i32 [ 0, %.split.us ], [ -1, %26 ]
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %8) #6
  br label %.loopexit

select.unfold:                                    ; preds = %.preheader, %42
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %7) #6
  %indvars.iv.next64 = add nuw nsw i64 %indvars.iv63, 1
  %exitcond67.not = icmp eq i64 %indvars.iv.next64, %wide.trip.count66
  br i1 %exitcond67.not, label %.thread41, label %.lr.ph53.split, !llvm.loop !19

.loopexit:                                        ; preds = %._crit_edge.us, %.preheader, %.thread34
  %.4.ph = phi i32 [ %.2.ph, %.thread34 ], [ -1, %.preheader ], [ -1, %._crit_edge.us ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %7) #6
  br label %53

.thread41:                                        ; preds = %select.unfold.us, %select.unfold, %14
  %46 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @_s2n_debug_info)
  store ptr @.str.36, ptr %46, align 8, !tbaa !20
  %47 = call ptr @strrchr(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @.str.36, i64 21), i32 noundef 47) #7
  %.not31 = icmp eq ptr %47, null
  %48 = getelementptr inbounds i8, ptr %47, i64 1
  %49 = select i1 %.not31, ptr getelementptr inbounds (i8, ptr @.str.36, i64 21), ptr %48
  %50 = getelementptr inbounds i8, ptr %46, i64 8
  store ptr %49, ptr %50, align 8, !tbaa !22
  %51 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  store i32 335544361, ptr %51, align 4, !tbaa !23
  %52 = call i32 @s2n_calculate_stacktrace() #6
  br label %53

53:                                               ; preds = %.loopexit, %.thread43, %.thread41, %11, %5
  %.7 = phi i32 [ -1, %5 ], [ -1, %11 ], [ -1, %.thread41 ], [ %.4.ph, %.loopexit ], [ -1, %.thread43 ]
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %6) #6
  ret i32 %.7
}

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

declare i32 @s2n_stuffer_init(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @s2n_stuffer_write(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden i32 @s2n_kem_check_kem_compatibility(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

declare i32 @s2n_stuffer_read_uint16(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @s2n_stuffer_reread(ptr 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind }
attributes #7 = { 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, !10, i64 8}
!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 = !{!7, !7, i64 0}
!12 = !{!8, !8, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"short", !8, i64 0}
!15 = !{!16, !14, i64 12}
!16 = !{!"s2n_kem", !7, i64 0, !10, i64 8, !14, i64 12, !14, i64 14, !14, i64 16, !14, i64 18, !14, i64 20, !7, i64 24, !7, i64 32, !7, i64 40}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = !{!21, !7, i64 0}
!21 = !{!"s2n_debug_info", !7, i64 0, !7, i64 8}
!22 = !{!21, !7, i64 8}
!23 = !{!10, !10, i64 0}


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass