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

@__const.mock_client.protocols = external hidden unnamed_addr constant [2 x ptr], align 16
@.str.2 = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @mock_client(ptr noundef %0, i32 noundef %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca [2 x ptr], align 16
  %13 = alloca [65535 x i8], align 16
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  store ptr null, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  store ptr null, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %12, ptr align 16 @__const.mock_client.protocols, i64 16, i1 false)
  %16 = call i32 @sleep(i32 noundef 1)
  %17 = call ptr @s2n_connection_new(i32 noundef 1)
  store ptr %17, ptr %7, align 8, !tbaa !5
  %18 = call ptr @s2n_config_new()
  store ptr %18, ptr %8, align 8, !tbaa !5
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = getelementptr inbounds [2 x ptr], ptr %12, i64 0, i64 0
  %21 = call i32 @s2n_config_set_protocol_preferences(ptr noundef %19, ptr noundef %20, i32 noundef 2)
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = call i32 @s2n_config_disable_x509_verification(ptr noundef %22)
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = call i32 @s2n_connection_set_config(ptr noundef %24, ptr noundef %25)
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = call i32 @s2n_connection_set_io_pair(ptr noundef %27, ptr noundef %28)
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = call i32 @s2n_set_server_name(ptr noundef %30, ptr noundef @.str.2)
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = call i32 @s2n_negotiate(ptr noundef %32, ptr noundef %9)
  store i32 %33, ptr %11, align 4, !tbaa !9
  %34 = load i32, ptr %5, align 4, !tbaa !9
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %46

36:                                               ; preds = %3
  %37 = load i32, ptr %11, align 4, !tbaa !9
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %40, label %39

39:                                               ; preds = %36
  store i32 1, ptr %10, align 4, !tbaa !9
  br label %40

40:                                               ; preds = %39, %36
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = call i32 @s2n_connection_get_alert(ptr noundef %41)
  %43 = icmp ne i32 %42, 40
  br i1 %43, label %44, label %45

44:                                               ; preds = %40
  store i32 2, ptr %10, align 4, !tbaa !9
  br label %45

45:                                               ; preds = %44, %40
  br label %84

46:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 65535, ptr %13) #6
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = load i32, ptr %47, align 8
  %49 = lshr i32 %48, 6
  %50 = and i32 %49, 1
  %51 = load i32, ptr %6, align 4, !tbaa !9
  %52 = icmp ne i32 %50, %51
  br i1 %52, label %53, label %54

53:                                               ; preds = %46
  store i32 1, ptr %10, align 4, !tbaa !9
  br label %54

54:                                               ; preds = %53, %46
  %55 = load i32, ptr %11, align 4, !tbaa !9
  %56 = icmp slt i32 %55, 0
  br i1 %56, label %57, label %58

57:                                               ; preds = %54
  store i32 2, ptr %10, align 4, !tbaa !9
  br label %58

58:                                               ; preds = %57, %54
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  store i32 1, ptr %14, align 4, !tbaa !9
  br label %59

59:                                               ; preds = %73, %58
  %60 = load i32, ptr %14, align 4, !tbaa !9
  %61 = icmp slt i32 %60, 65535
  br i1 %61, label %63, label %62

62:                                               ; preds = %59
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %76

63:                                               ; preds = %59
  %64 = getelementptr inbounds [65535 x i8], ptr %13, i64 0, i64 0
  %65 = load i32, ptr %14, align 4, !tbaa !9
  %66 = sext i32 %65 to i64
  %67 = mul i64 1, %66
  call void @llvm.memset.p0.i64(ptr align 16 %64, i8 33, i64 %67, i1 false)
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = getelementptr inbounds [65535 x i8], ptr %13, i64 0, i64 0
  %70 = load i32, ptr %14, align 4, !tbaa !9
  %71 = sext i32 %70 to i64
  %72 = call i64 @s2n_send(ptr noundef %68, ptr noundef %69, i64 noundef %71, ptr noundef %9)
  br label %73

73:                                               ; preds = %63
  %74 = load i32, ptr %14, align 4, !tbaa !9
  %75 = add nsw i32 %74, 100
  store i32 %75, ptr %14, align 4, !tbaa !9
  br label %59, !llvm.loop !11

76:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  store i32 -1, ptr %15, align 4, !tbaa !9
  br label %77

77:                                               ; preds = %80, %76
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = call i32 @s2n_shutdown(ptr noundef %78, ptr noundef %9)
  store i32 %79, ptr %15, align 4, !tbaa !9
  br label %80

80:                                               ; preds = %77
  %81 = load i32, ptr %15, align 4, !tbaa !9
  %82 = icmp ne i32 %81, 0
  br i1 %82, label %77, label %83, !llvm.loop !13

83:                                               ; preds = %80
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 65535, ptr %13) #6
  br label %84

84:                                               ; preds = %83, %45
  %85 = load ptr, ptr %7, align 8, !tbaa !5
  %86 = call i32 @s2n_connection_free(ptr noundef %85)
  %87 = load ptr, ptr %8, align 8, !tbaa !5
  %88 = call i32 @s2n_config_free(ptr noundef %87)
  %89 = call i32 @sleep(i32 noundef 1)
  %90 = call i32 @s2n_cleanup()
  %91 = load ptr, ptr %4, align 8, !tbaa !5
  %92 = call i32 @s2n_io_pair_close_one_end(ptr noundef %91, i32 noundef 1)
  %93 = load i32, ptr %10, align 4, !tbaa !9
  call void @exit(i32 noundef %93) #7
  unreachable
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare i32 @sleep(i32 noundef) #3

declare ptr @s2n_connection_new(i32 noundef) #3

declare ptr @s2n_config_new() #3

declare i32 @s2n_config_set_protocol_preferences(ptr noundef, ptr noundef, i32 noundef) #3

declare i32 @s2n_config_disable_x509_verification(ptr noundef) #3

declare i32 @s2n_connection_set_config(ptr noundef, ptr noundef) #3

declare i32 @s2n_connection_set_io_pair(ptr noundef, ptr noundef) #3

declare i32 @s2n_set_server_name(ptr noundef, ptr noundef) #3

declare i32 @s2n_negotiate(ptr noundef, ptr noundef) #3

declare i32 @s2n_connection_get_alert(ptr noundef) #3

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

declare i64 @s2n_send(ptr noundef, ptr noundef, i64 noundef, ptr 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 @s2n_shutdown(ptr noundef, ptr noundef) #3

declare i32 @s2n_connection_free(ptr noundef) #3

declare i32 @s2n_config_free(ptr noundef) #3

declare i32 @s2n_cleanup() #3

declare i32 @s2n_io_pair_close_one_end(ptr noundef, i32 noundef) #3

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #5

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { noreturn nounwind "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 #6 = { nounwind }
attributes #7 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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"

@__const.mock_client.protocols = external hidden unnamed_addr constant [2 x ptr], align 16
@.str.2 = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: noreturn nounwind uwtable
define dso_local noundef i32 @mock_client(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = alloca i32, align 4
  %5 = alloca [2 x ptr], align 16
  %6 = alloca [65535 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %5, ptr noundef nonnull align 16 dereferenceable(16) @__const.mock_client.protocols, i64 16, i1 false)
  %7 = tail call i32 @sleep(i32 noundef 1) #6
  %8 = tail call ptr @s2n_connection_new(i32 noundef 1) #6
  %9 = tail call ptr @s2n_config_new() #6
  %10 = call i32 @s2n_config_set_protocol_preferences(ptr noundef %9, ptr noundef nonnull %5, i32 noundef 2) #6
  %11 = call i32 @s2n_config_disable_x509_verification(ptr noundef %9) #6
  %12 = call i32 @s2n_connection_set_config(ptr noundef %8, ptr noundef %9) #6
  %13 = call i32 @s2n_connection_set_io_pair(ptr noundef %8, ptr noundef %0) #6
  %14 = call i32 @s2n_set_server_name(ptr noundef %8, ptr noundef nonnull @.str.2) #6
  %15 = call i32 @s2n_negotiate(ptr noundef %8, ptr noundef nonnull %4) #6
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %18, label %16

16:                                               ; preds = %3
  %.not27 = icmp eq i32 %15, 0
  %spec.select = zext i1 %.not27 to i32
  %17 = call i32 @s2n_connection_get_alert(ptr noundef %8) #6
  %.not28 = icmp eq i32 %17, 40
  %spec.select30 = select i1 %.not28, i32 %spec.select, i32 2
  br label %28

18:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 65535, ptr nonnull %6) #6
  %19 = load i32, ptr %8, align 8
  %20 = lshr i32 %19, 6
  %21 = and i32 %20, 1
  %.not25 = icmp ne i32 %21, %2
  %22 = icmp slt i32 %15, 0
  br label %23

23:                                               ; preds = %18, %23
  %indvars.iv = phi i64 [ 1, %18 ], [ %indvars.iv.next, %23 ]
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1) %6, i8 33, i64 %indvars.iv, i1 false)
  %24 = call i64 @s2n_send(ptr noundef nonnull %8, ptr noundef nonnull %6, i64 noundef %indvars.iv, ptr noundef nonnull %4) #6
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 100
  %25 = icmp ult i64 %indvars.iv, 65435
  br i1 %25, label %23, label %.preheader.preheader, !llvm.loop !5

.preheader.preheader:                             ; preds = %23
  %spec.select29 = zext i1 %.not25 to i32
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %.preheader
  %26 = call i32 @s2n_shutdown(ptr noundef nonnull %8, ptr noundef nonnull %4) #6
  %.not26 = icmp eq i32 %26, 0
  br i1 %.not26, label %27, label %.preheader, !llvm.loop !7

27:                                               ; preds = %.preheader
  %.2 = select i1 %22, i32 2, i32 %spec.select29
  call void @llvm.lifetime.end.p0(i64 65535, ptr nonnull %6) #6
  br label %28

28:                                               ; preds = %16, %27
  %.3 = phi i32 [ %.2, %27 ], [ %spec.select30, %16 ]
  %29 = call i32 @s2n_connection_free(ptr noundef %8) #6
  %30 = call i32 @s2n_config_free(ptr noundef %9) #6
  %31 = call i32 @sleep(i32 noundef 1) #6
  %32 = call i32 @s2n_cleanup() #6
  %33 = call i32 @s2n_io_pair_close_one_end(ptr noundef %0, i32 noundef 1) #6
  call void @exit(i32 noundef %.3) #7
  unreachable
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare i32 @sleep(i32 noundef) local_unnamed_addr #3

declare ptr @s2n_connection_new(i32 noundef) local_unnamed_addr #3

declare ptr @s2n_config_new() local_unnamed_addr #3

declare i32 @s2n_config_set_protocol_preferences(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

declare i32 @s2n_config_disable_x509_verification(ptr noundef) local_unnamed_addr #3

declare i32 @s2n_connection_set_config(ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @s2n_connection_set_io_pair(ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @s2n_set_server_name(ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @s2n_negotiate(ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @s2n_connection_get_alert(ptr noundef) local_unnamed_addr #3

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

declare i64 @s2n_send(ptr noundef, ptr noundef, i64 noundef, ptr 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 @s2n_shutdown(ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @s2n_connection_free(ptr noundef) local_unnamed_addr #3

declare i32 @s2n_config_free(ptr noundef) local_unnamed_addr #3

declare i32 @s2n_cleanup() local_unnamed_addr #3

declare i32 @s2n_io_pair_close_one_end(ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #5

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass