; 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
@heartbeat_message = external dso_local global [19 x i8], align 16

; 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_message(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 24, 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 19, 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 @heartbeat_message, i64 noundef 19)
  %45 = icmp ne i64 %44, 19
  br i1 %45, label %46, label %47

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

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

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

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

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

78:                                               ; preds = %66
  %79 = load i32, ptr %2, align 4, !tbaa !5
  %80 = call i32 @close(i32 noundef %79)
  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
@heartbeat_message = external dso_local global [19 x i8], align 16

; 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_message(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
  %.not19 = icmp eq i64 %8, 37
  br i1 %.not19, label %10, label %9

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

10:                                               ; preds = %7
  store i8 24, ptr %2, align 4, !tbaa !5
  store i8 0, ptr %3, align 1, !tbaa !5
  store i8 19, ptr %4, align 4, !tbaa !5
  %11 = call i64 @write(i32 noundef %0, ptr noundef nonnull %2, i64 noundef 5) #5
  %.not20 = icmp eq i64 %11, 5
  br i1 %.not20, 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 @heartbeat_message, i64 noundef 19) #5
  %.not21 = icmp eq i64 %14, 19
  br i1 %.not21, 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 37, ptr %4, align 4, !tbaa !5
  %17 = call i64 @write(i32 noundef %0, ptr noundef nonnull %2, i64 noundef 5) #5
  %.not22 = icmp eq i64 %17, 5
  br i1 %.not22, 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 37) #5
  %.not23 = icmp eq i64 %20, 37
  br i1 %.not23, label %22, label %21

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

22:                                               ; preds = %19
  %23 = 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