; 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
@server_cert = external dso_local global [828 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 @coalesced_message(i32 noundef %0) #3 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca [5 x i8], align 1
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 902, 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
  %5 = getelementptr inbounds i8, ptr %4, i64 1
  store i8 3, ptr %5, align 1, !tbaa !9
  %6 = getelementptr inbounds i8, ptr %4, i64 2
  store i8 3, ptr %6, align 1, !tbaa !9
  %7 = getelementptr inbounds i8, ptr %4, i64 3
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = ashr i32 %8, 8
  %10 = trunc i32 %9 to i8
  store i8 %10, ptr %7, align 1, !tbaa !9
  %11 = getelementptr inbounds i8, ptr %4, i64 4
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = and i32 %12, 255
  %14 = trunc i32 %13 to i8
  store i8 %14, ptr %11, align 1, !tbaa !9
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 0
  %17 = call i64 @write(i32 noundef %15, ptr noundef %16, i64 noundef 5)
  %18 = icmp ne i64 %17, 5
  br i1 %18, label %19, label %20

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

20:                                               ; preds = %1
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = call i64 @write(i32 noundef %21, ptr noundef @server_hello_message, i64 noundef 74)
  %23 = icmp ne i64 %22, 74
  br i1 %23, label %24, label %25

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

25:                                               ; preds = %20
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = call i64 @write(i32 noundef %26, ptr noundef @server_cert, i64 noundef 828)
  %28 = icmp ne i64 %27, 828
  br i1 %28, label %29, label %30

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

30:                                               ; preds = %25
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = call i32 @close(i32 noundef %31)
  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
@server_cert = external dso_local global [828 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 @coalesced_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
  store <4 x i8> <i8 22, i8 3, i8 3, i8 3>, ptr %2, align 4, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %2, i64 4
  store i8 -122, ptr %3, align 4, !tbaa !5
  %4 = call i64 @write(i32 noundef %0, ptr noundef nonnull %2, i64 noundef 5) #5
  %.not = icmp eq i64 %4, 5
  br i1 %.not, label %6, label %5

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

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

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

9:                                                ; preds = %6
  %10 = tail call i64 @write(i32 noundef %0, ptr noundef nonnull @server_cert, i64 noundef 828) #5
  %.not7 = icmp eq i64 %10, 828
  br i1 %.not7, label %12, label %11

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

12:                                               ; preds = %9
  %13 = 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