; LLVM IR from aws/s2n-tls :: tests/unit (s2n_fragmentation_coalescing_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"

@server_hello_message = external dso_local global [74 x i8], align 16
@fatal_alert = external dso_local global [2 x i8], align 1

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

declare i64 @write(i32 noundef, ptr noundef, i64 noundef) #1

; Function Attrs: noreturn
declare void @_exit(i32 noundef) #2

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

declare i32 @close(i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @interleaved_fragmented_fatal_alert(i32 noundef %0) #3 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca [5 x i8], align 1
  %5 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 37, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 5, ptr %4) #4
  store i8 22, ptr %4, align 1, !tbaa !9
  %6 = getelementptr inbounds i8, ptr %4, i64 1
  store i8 3, ptr %6, align 1, !tbaa !9
  %7 = getelementptr inbounds i8, ptr %4, i64 2
  store i8 3, ptr %7, align 1, !tbaa !9
  %8 = getelementptr inbounds i8, ptr %4, i64 3
  %9 = load i32, ptr %3, align 4, !tbaa !5
  %10 = ashr i32 %9, 8
  %11 = trunc i32 %10 to i8
  store i8 %11, ptr %8, align 1, !tbaa !9
  %12 = getelementptr inbounds i8, ptr %4, i64 4
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = and i32 %13, 255
  %15 = trunc i32 %14 to i8
  store i8 %15, ptr %12, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !5
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 0
  %18 = call i64 @write(i32 noundef %16, ptr noundef %17, i64 noundef 5)
  %19 = icmp ne i64 %18, 5
  br i1 %19, label %20, label %21

20:                                               ; preds = %1
  call void @_exit(i32 noundef 100) #5
  unreachable

21:                                               ; preds = %1
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = load i32, ptr %3, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = call i64 @write(i32 noundef %22, ptr noundef @server_hello_message, i64 noundef %24)
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = icmp ne i64 %25, %27
  br i1 %28, label %29, label %30

29:                                               ; preds = %21
  call void @_exit(i32 noundef 100) #5
  unreachable

30:                                               ; preds = %21
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = add nsw i32 %32, %31
  store i32 %33, ptr %5, align 4, !tbaa !5
  %34 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 0
  store i8 21, ptr %34, align 1, !tbaa !9
  %35 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 3
  store i8 0, ptr %35, align 1, !tbaa !9
  %36 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 4
  store i8 1, ptr %36, align 1, !tbaa !9
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 0
  %39 = call i64 @write(i32 noundef %37, ptr noundef %38, i64 noundef 5)
  %40 = icmp ne i64 %39, 5
  br i1 %40, label %41, label %42

41:                                               ; preds = %30
  call void @_exit(i32 noundef 100) #5
  unreachable

42:                                               ; preds = %30
  %43 = load i32, ptr %2, align 4, !tbaa !5
  %44 = call i64 @write(i32 noundef %43, ptr noundef @fatal_alert, i64 noundef 1)
  %45 = icmp ne i64 %44, 1
  br i1 %45, label %46, label %47

46:                                               ; preds = %42
  call void @_exit(i32 noundef 100) #5
  unreachable

47:                                               ; preds = %42
  store i32 18, ptr %3, align 4, !tbaa !5
  %48 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 0
  store i8 22, ptr %48, align 1, !tbaa !9
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = ashr i32 %49, 8
  %51 = trunc i32 %50 to i8
  %52 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 3
  store i8 %51, ptr %52, align 1, !tbaa !9
  %53 = load i32, ptr %3, align 4, !tbaa !5
  %54 = and i32 %53, 255
  %55 = trunc i32 %54 to i8
  %56 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 4
  store i8 %55, ptr %56, align 1, !tbaa !9
  %57 = load i32, ptr %2, align 4, !tbaa !5
  %58 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 0
  %59 = call i64 @write(i32 noundef %57, ptr noundef %58, i64 noundef 5)
  %60 = icmp ne i64 %59, 5
  br i1 %60, label %61, label %62

61:                                               ; preds = %47
  call void @_exit(i32 noundef 100) #5
  unreachable

62:                                               ; preds = %47
  %63 = load i32, ptr %2, align 4, !tbaa !5
  %64 = load i32, ptr %5, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds i8, ptr @server_hello_message, i64 %65
  %67 = load i32, ptr %3, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = call i64 @write(i32 noundef %63, ptr noundef %66, i64 noundef %68)
  %70 = load i32, ptr %3, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = icmp ne i64 %69, %71
  br i1 %72, label %73, label %74

73:                                               ; preds = %62
  call void @_exit(i32 noundef 100) #5
  unreachable

74:                                               ; preds = %62
  %75 = load i32, ptr %3, align 4, !tbaa !5
  %76 = load i32, ptr %5, align 4, !tbaa !5
  %77 = add nsw i32 %76, %75
  store i32 %77, ptr %5, align 4, !tbaa !5
  %78 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 0
  store i8 21, ptr %78, align 1, !tbaa !9
  %79 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 3
  store i8 0, ptr %79, align 1, !tbaa !9
  %80 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 4
  store i8 1, ptr %80, align 1, !tbaa !9
  %81 = load i32, ptr %2, align 4, !tbaa !5
  %82 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 0
  %83 = call i64 @write(i32 noundef %81, ptr noundef %82, i64 noundef 5)
  %84 = icmp ne i64 %83, 5
  br i1 %84, label %85, label %86

85:                                               ; preds = %74
  call void @_exit(i32 noundef 100) #5
  unreachable

86:                                               ; preds = %74
  %87 = load i32, ptr %2, align 4, !tbaa !5
  %88 = call i64 @write(i32 noundef %87, ptr noundef getelementptr inbounds (i8, ptr @fatal_alert, i64 1), i64 noundef 1)
  %89 = icmp ne i64 %88, 1
  br i1 %89, label %90, label %91

90:                                               ; preds = %86
  call void @_exit(i32 noundef 100) #5
  unreachable

91:                                               ; preds = %86
  %92 = load i32, ptr %5, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = sub i64 74, %93
  %95 = trunc i64 %94 to i32
  store i32 %95, ptr %3, align 4, !tbaa !5
  %96 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 0
  store i8 22, ptr %96, align 1, !tbaa !9
  %97 = load i32, ptr %3, align 4, !tbaa !5
  %98 = ashr i32 %97, 8
  %99 = trunc i32 %98 to i8
  %100 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 3
  store i8 %99, ptr %100, align 1, !tbaa !9
  %101 = load i32, ptr %3, align 4, !tbaa !5
  %102 = and i32 %101, 255
  %103 = trunc i32 %102 to i8
  %104 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 4
  store i8 %103, ptr %104, align 1, !tbaa !9
  %105 = load i32, ptr %2, align 4, !tbaa !5
  %106 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 0
  %107 = call i64 @write(i32 noundef %105, ptr noundef %106, i64 noundef 5)
  %108 = icmp ne i64 %107, 5
  br i1 %108, label %109, label %110

109:                                              ; preds = %91
  call void @_exit(i32 noundef 100) #5
  unreachable

110:                                              ; preds = %91
  %111 = load i32, ptr %2, align 4, !tbaa !5
  %112 = load i32, ptr %5, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds i8, ptr @server_hello_message, i64 %113
  %115 = load i32, ptr %3, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = call i64 @write(i32 noundef %111, ptr noundef %114, i64 noundef %116)
  %118 = load i32, ptr %3, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = icmp ne i64 %117, %119
  br i1 %120, label %121, label %122

121:                                              ; preds = %110
  call void @_exit(i32 noundef 100) #5
  unreachable

122:                                              ; preds = %110
  %123 = load i32, ptr %2, align 4, !tbaa !5
  %124 = call i32 @close(i32 noundef %123)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 5, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { noreturn "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 = { noreturn }

!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 = !{!7, !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"

@server_hello_message = external dso_local global [74 x i8], align 16
@fatal_alert = external dso_local global [2 x i8], align 1

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

; Function Attrs: nofree
declare noundef i64 @write(i32 noundef, ptr nocapture noundef readonly, i64 noundef) local_unnamed_addr #1

; Function Attrs: noreturn
declare void @_exit(i32 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) #0

declare i32 @close(i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local void @interleaved_fragmented_fatal_alert(i32 noundef %0) local_unnamed_addr #4 {
  %2 = alloca [5 x i8], align 4
  call void @llvm.lifetime.start.p0(i64 5, ptr nonnull %2) #5
  %3 = getelementptr inbounds i8, ptr %2, i64 3
  store <4 x i8> <i8 22, i8 3, i8 3, i8 0>, ptr %2, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %2, i64 4
  store i8 37, ptr %4, align 4, !tbaa !5
  %5 = call i64 @write(i32 noundef %0, ptr noundef nonnull %2, i64 noundef 5) #5
  %.not = icmp eq i64 %5, 5
  br i1 %.not, label %7, label %6

6:                                                ; preds = %1
  tail call void @_exit(i32 noundef 100) #6
  unreachable

7:                                                ; preds = %1
  %8 = tail call i64 @write(i32 noundef %0, ptr noundef nonnull @server_hello_message, i64 noundef 37) #5
  %.not30 = icmp eq i64 %8, 37
  br i1 %.not30, label %10, label %9

9:                                                ; preds = %7
  tail call void @_exit(i32 noundef 100) #6
  unreachable

10:                                               ; preds = %7
  store i8 21, ptr %2, align 4, !tbaa !5
  store i8 0, ptr %3, align 1, !tbaa !5
  store i8 1, ptr %4, align 4, !tbaa !5
  %11 = call i64 @write(i32 noundef %0, ptr noundef nonnull %2, i64 noundef 5) #5
  %.not31 = icmp eq i64 %11, 5
  br i1 %.not31, label %13, label %12

12:                                               ; preds = %10
  tail call void @_exit(i32 noundef 100) #6
  unreachable

13:                                               ; preds = %10
  %14 = tail call i64 @write(i32 noundef %0, ptr noundef nonnull @fatal_alert, i64 noundef 1) #5
  %.not32 = icmp eq i64 %14, 1
  br i1 %.not32, label %16, label %15

15:                                               ; preds = %13
  tail call void @_exit(i32 noundef 100) #6
  unreachable

16:                                               ; preds = %13
  store i8 22, ptr %2, align 4, !tbaa !5
  store i8 0, ptr %3, align 1, !tbaa !5
  store i8 18, ptr %4, align 4, !tbaa !5
  %17 = call i64 @write(i32 noundef %0, ptr noundef nonnull %2, i64 noundef 5) #5
  %.not33 = icmp eq i64 %17, 5
  br i1 %.not33, label %19, label %18

18:                                               ; preds = %16
  tail call void @_exit(i32 noundef 100) #6
  unreachable

19:                                               ; preds = %16
  %20 = tail call i64 @write(i32 noundef %0, ptr noundef nonnull getelementptr inbounds (i8, ptr @server_hello_message, i64 37), i64 noundef 18) #5
  %.not34 = icmp eq i64 %20, 18
  br i1 %.not34, label %22, label %21

21:                                               ; preds = %19
  tail call void @_exit(i32 noundef 100) #6
  unreachable

22:                                               ; preds = %19
  store i8 21, ptr %2, align 4, !tbaa !5
  store i8 0, ptr %3, align 1, !tbaa !5
  store i8 1, ptr %4, align 4, !tbaa !5
  %23 = call i64 @write(i32 noundef %0, ptr noundef nonnull %2, i64 noundef 5) #5
  %.not35 = icmp eq i64 %23, 5
  br i1 %.not35, label %25, label %24

24:                                               ; preds = %22
  tail call void @_exit(i32 noundef 100) #6
  unreachable

25:                                               ; preds = %22
  %26 = tail call i64 @write(i32 noundef %0, ptr noundef nonnull getelementptr inbounds (i8, ptr @fatal_alert, i64 1), i64 noundef 1) #5
  %.not36 = icmp eq i64 %26, 1
  br i1 %.not36, label %28, label %27

27:                                               ; preds = %25
  tail call void @_exit(i32 noundef 100) #6
  unreachable

28:                                               ; preds = %25
  store i8 22, ptr %2, align 4, !tbaa !5
  store i8 0, ptr %3, align 1, !tbaa !5
  store i8 19, ptr %4, align 4, !tbaa !5
  %29 = call i64 @write(i32 noundef %0, ptr noundef nonnull %2, i64 noundef 5) #5
  %.not37 = icmp eq i64 %29, 5
  br i1 %.not37, label %31, label %30

30:                                               ; preds = %28
  tail call void @_exit(i32 noundef 100) #6
  unreachable

31:                                               ; preds = %28
  %32 = tail call i64 @write(i32 noundef %0, ptr noundef nonnull getelementptr inbounds (i8, ptr @server_hello_message, i64 55), i64 noundef 19) #5
  %.not38 = icmp eq i64 %32, 19
  br i1 %.not38, label %34, label %33

33:                                               ; preds = %31
  tail call void @_exit(i32 noundef 100) #6
  unreachable

34:                                               ; preds = %31
  %35 = tail call i32 @close(i32 noundef %0) #5
  call void @llvm.lifetime.end.p0(i64 5, ptr nonnull %2) #5
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nofree "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 = { noreturn "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 = { "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 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 = { 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 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SLPVectorizerPass,SROAPass,TailCallElimPass