; 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

; Function Attrs: nounwind uwtable
define dso_local void @fragmented_message(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = 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 0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %51, %1
  %8 = load i32, ptr %4, align 4, !tbaa !5
  %9 = icmp slt i32 %8, 5
  br i1 %9, label %11, label %10

10:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %54

11:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 14, ptr %5, align 4, !tbaa !5
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %14, label %19

14:                                               ; preds = %11
  %15 = load i32, ptr %5, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = add i64 %16, 4
  %18 = trunc i64 %17 to i32
  store i32 %18, ptr %5, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %14, %11
  call void @llvm.lifetime.start.p0(i64 5, ptr %6) #4
  store i8 22, ptr %6, align 1, !tbaa !9
  %20 = getelementptr inbounds i8, ptr %6, i64 1
  store i8 3, ptr %20, align 1, !tbaa !9
  %21 = getelementptr inbounds i8, ptr %6, i64 2
  store i8 3, ptr %21, align 1, !tbaa !9
  %22 = getelementptr inbounds i8, ptr %6, i64 3
  %23 = load i32, ptr %5, align 4, !tbaa !5
  %24 = ashr i32 %23, 8
  %25 = trunc i32 %24 to i8
  store i8 %25, ptr %22, align 1, !tbaa !9
  %26 = getelementptr inbounds i8, ptr %6, i64 4
  %27 = load i32, ptr %5, align 4, !tbaa !5
  %28 = and i32 %27, 255
  %29 = trunc i32 %28 to i8
  store i8 %29, ptr %26, align 1, !tbaa !9
  %30 = load i32, ptr %2, align 4, !tbaa !5
  %31 = getelementptr inbounds [5 x i8], ptr %6, i64 0, i64 0
  %32 = call i64 @write(i32 noundef %30, ptr noundef %31, i64 noundef 5)
  %33 = icmp ne i64 %32, 5
  br i1 %33, label %34, label %35

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

35:                                               ; preds = %19
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i8, ptr @server_hello_message, i64 %38
  %40 = load i32, ptr %5, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = call i64 @write(i32 noundef %36, ptr noundef %39, i64 noundef %41)
  %43 = load i32, ptr %5, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = icmp ne i64 %42, %44
  br i1 %45, label %46, label %47

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

47:                                               ; preds = %35
  %48 = load i32, ptr %5, align 4, !tbaa !5
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = add nsw i32 %49, %48
  store i32 %50, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 5, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %51

51:                                               ; preds = %47
  %52 = load i32, ptr %4, align 4, !tbaa !5
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %4, align 4, !tbaa !5
  br label %7, !llvm.loop !10

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

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

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

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

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

declare i32 @close(i32 noundef) #2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


; 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

; Function Attrs: nounwind uwtable
define dso_local void @fragmented_message(i32 noundef %0) local_unnamed_addr #0 {
  %2 = alloca [5 x i8], align 4
  %3 = getelementptr inbounds i8, ptr %2, i64 4
  call void @llvm.lifetime.start.p0(i64 5, ptr nonnull %2) #5
  store <4 x i8> <i8 22, i8 3, i8 3, i8 0>, ptr %2, align 4, !tbaa !5
  store i8 18, 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 = %21, %17, %13, %9, %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 18) #5
  %.not16 = icmp eq i64 %7, 18
  br i1 %.not16, label %9, label %8

8:                                                ; preds = %23, %19, %15, %11, %6
  tail call void @_exit(i32 noundef 100) #6
  unreachable

9:                                                ; preds = %6
  call void @llvm.lifetime.end.p0(i64 5, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 5, ptr nonnull %2) #5
  store <4 x i8> <i8 22, i8 3, i8 3, i8 0>, ptr %2, align 4, !tbaa !5
  store i8 14, ptr %3, align 4, !tbaa !5
  %10 = call i64 @write(i32 noundef %0, ptr noundef nonnull %2, i64 noundef 5) #5
  %.not.1 = icmp eq i64 %10, 5
  br i1 %.not.1, label %11, label %5

11:                                               ; preds = %9
  %12 = tail call i64 @write(i32 noundef %0, ptr noundef nonnull getelementptr inbounds (i8, ptr @server_hello_message, i64 18), i64 noundef 14) #5
  %.not16.1 = icmp eq i64 %12, 14
  br i1 %.not16.1, label %13, label %8

13:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 5, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 5, ptr nonnull %2) #5
  store <4 x i8> <i8 22, i8 3, i8 3, i8 0>, ptr %2, align 4, !tbaa !5
  store i8 14, ptr %3, align 4, !tbaa !5
  %14 = call i64 @write(i32 noundef %0, ptr noundef nonnull %2, i64 noundef 5) #5
  %.not.2 = icmp eq i64 %14, 5
  br i1 %.not.2, label %15, label %5

15:                                               ; preds = %13
  %16 = tail call i64 @write(i32 noundef %0, ptr noundef nonnull getelementptr inbounds (i8, ptr @server_hello_message, i64 32), i64 noundef 14) #5
  %.not16.2 = icmp eq i64 %16, 14
  br i1 %.not16.2, label %17, label %8

17:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 5, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 5, ptr nonnull %2) #5
  store <4 x i8> <i8 22, i8 3, i8 3, i8 0>, ptr %2, align 4, !tbaa !5
  store i8 14, ptr %3, align 4, !tbaa !5
  %18 = call i64 @write(i32 noundef %0, ptr noundef nonnull %2, i64 noundef 5) #5
  %.not.3 = icmp eq i64 %18, 5
  br i1 %.not.3, label %19, label %5

19:                                               ; preds = %17
  %20 = tail call i64 @write(i32 noundef %0, ptr noundef nonnull getelementptr inbounds (i8, ptr @server_hello_message, i64 46), i64 noundef 14) #5
  %.not16.3 = icmp eq i64 %20, 14
  br i1 %.not16.3, label %21, label %8

21:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 5, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 5, ptr nonnull %2) #5
  store <4 x i8> <i8 22, i8 3, i8 3, i8 0>, ptr %2, align 4, !tbaa !5
  store i8 14, ptr %3, align 4, !tbaa !5
  %22 = call i64 @write(i32 noundef %0, ptr noundef nonnull %2, i64 noundef 5) #5
  %.not.4 = icmp eq i64 %22, 5
  br i1 %.not.4, label %23, label %5

23:                                               ; preds = %21
  %24 = tail call i64 @write(i32 noundef %0, ptr noundef nonnull getelementptr inbounds (i8, ptr @server_hello_message, i64 60), i64 noundef 14) #5
  %.not16.4 = icmp eq i64 %24, 14
  br i1 %.not16.4, label %25, label %8

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

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

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

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

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

declare i32 @close(i32 noundef) local_unnamed_addr #4

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { "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,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass