; LLVM IR from aws/s2n-tls :: bin (https)

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

@str_buffer = external hidden global [1024 x i8], align 16
@.str = external hidden unnamed_addr constant [18 x i8], align 1
@blocked = external hidden global i32, align 4
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@stdout = external global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [28 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @bench_handler(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca [65536 x i8], align 16
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %2
  br label %12

12:                                               ; preds = %11
  %13 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef @str_buffer, ptr noundef @.str) #6
  br label %14

14:                                               ; preds = %12
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = call i64 @strlen(ptr noundef @str_buffer) #7
  %17 = call i64 @s2n_send(ptr noundef %15, ptr noundef @str_buffer, i64 noundef %16, ptr noundef @blocked)
  %18 = icmp sgt i64 %17, -1
  br i1 %18, label %20, label %19

19:                                               ; preds = %14
  store i32 -1, ptr %3, align 4
  br label %84

20:                                               ; preds = %14
  br label %21

21:                                               ; preds = %20
  br label %22

22:                                               ; preds = %21
  br label %23

23:                                               ; preds = %22
  %24 = load i32, ptr %5, align 4, !tbaa !9
  %25 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef @str_buffer, ptr noundef @.str.1, i32 noundef %24) #6
  br label %26

26:                                               ; preds = %23
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = call i64 @strlen(ptr noundef @str_buffer) #7
  %29 = call i64 @s2n_send(ptr noundef %27, ptr noundef @str_buffer, i64 noundef %28, ptr noundef @blocked)
  %30 = icmp sgt i64 %29, -1
  br i1 %30, label %32, label %31

31:                                               ; preds = %26
  store i32 -1, ptr %3, align 4
  br label %84

32:                                               ; preds = %26
  br label %33

33:                                               ; preds = %32
  br label %34

34:                                               ; preds = %33
  br label %35

35:                                               ; preds = %34
  %36 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef @str_buffer, ptr noundef @.str.2) #6
  br label %37

37:                                               ; preds = %35
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = call i64 @strlen(ptr noundef @str_buffer) #7
  %40 = call i64 @s2n_send(ptr noundef %38, ptr noundef @str_buffer, i64 noundef %39, ptr noundef @blocked)
  %41 = icmp sgt i64 %40, -1
  br i1 %41, label %43, label %42

42:                                               ; preds = %37
  store i32 -1, ptr %3, align 4
  br label %84

43:                                               ; preds = %37
  br label %44

44:                                               ; preds = %43
  br label %45

45:                                               ; preds = %44
  br label %46

46:                                               ; preds = %45
  %47 = load ptr, ptr @stdout, align 8, !tbaa !5
  %48 = load i32, ptr %5, align 4, !tbaa !9
  %49 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %47, ptr noundef @.str.3, i32 noundef %48) #6
  call void @llvm.lifetime.start.p0(i64 65536, ptr %6) #6
  call void @llvm.memset.p0.i64(ptr align 16 %6, i8 0, i64 65536, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 65536, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %50 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %50, ptr %8, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %79, %46
  %52 = load i32, ptr %8, align 4, !tbaa !9
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %54, label %80

54:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %55 = load i32, ptr %8, align 4, !tbaa !9
  %56 = load i32, ptr %7, align 4, !tbaa !9
  %57 = icmp ult i32 %55, %56
  br i1 %57, label %58, label %60

58:                                               ; preds = %54
  %59 = load i32, ptr %8, align 4, !tbaa !9
  br label %62

60:                                               ; preds = %54
  %61 = load i32, ptr %7, align 4, !tbaa !9
  br label %62

62:                                               ; preds = %60, %58
  %63 = phi i32 [ %59, %58 ], [ %61, %60 ]
  store i32 %63, ptr %9, align 4, !tbaa !9
  br label %64

64:                                               ; preds = %62
  %65 = load i32, ptr %9, align 4, !tbaa !9
  %66 = getelementptr inbounds [65536 x i8], ptr %6, i64 0, i64 0
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = call i32 @flush(i32 noundef %65, ptr noundef %66, ptr noundef %67, ptr noundef @blocked)
  %69 = icmp sgt i32 %68, -1
  br i1 %69, label %71, label %70

70:                                               ; preds = %64
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %77

71:                                               ; preds = %64
  br label %72

72:                                               ; preds = %71
  br label %73

73:                                               ; preds = %72
  %74 = load i32, ptr %9, align 4, !tbaa !9
  %75 = load i32, ptr %8, align 4, !tbaa !9
  %76 = sub i32 %75, %74
  store i32 %76, ptr %8, align 4, !tbaa !9
  store i32 0, ptr %10, align 4
  br label %77

77:                                               ; preds = %73, %70
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  %78 = load i32, ptr %10, align 4
  switch i32 %78, label %83 [
    i32 0, label %79
  ]

79:                                               ; preds = %77
  br label %51, !llvm.loop !11

80:                                               ; preds = %51
  %81 = load ptr, ptr @stdout, align 8, !tbaa !5
  %82 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %81, ptr noundef @.str.4) #6
  store i32 0, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %83

83:                                               ; preds = %80, %77
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 65536, ptr %6) #6
  br label %84

84:                                               ; preds = %83, %42, %31, %19
  %85 = load i32, ptr %3, align 4
  ret i32 %85
}

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #1

declare i64 @s2n_send(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #2

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #3

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @flush(i32 noundef, ptr noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { 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 #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 = { nounwind willreturn memory(read) "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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(read) }

!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"}


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

@str_buffer = external hidden global [1024 x i8], align 16
@.str = external hidden unnamed_addr constant [18 x i8], align 1
@blocked = external hidden global i32, align 4
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [28 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @bench_handler(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = alloca [65536 x i8], align 16
  %4 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) @str_buffer, ptr noundef nonnull dereferenceable(1) @.str) #7
  %5 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) @str_buffer) #8
  %6 = tail call i64 @s2n_send(ptr noundef %0, ptr noundef nonnull @str_buffer, i64 noundef %5, ptr noundef nonnull @blocked) #7
  %7 = icmp sgt i64 %6, -1
  br i1 %7, label %8, label %30

8:                                                ; preds = %2
  %9 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) @str_buffer, ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %1) #7
  %10 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) @str_buffer) #8
  %11 = tail call i64 @s2n_send(ptr noundef %0, ptr noundef nonnull @str_buffer, i64 noundef %10, ptr noundef nonnull @blocked) #7
  %12 = icmp sgt i64 %11, -1
  br i1 %12, label %13, label %30

13:                                               ; preds = %8
  %14 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) @str_buffer, ptr noundef nonnull dereferenceable(1) @.str.2) #7
  %15 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) @str_buffer) #8
  %16 = tail call i64 @s2n_send(ptr noundef %0, ptr noundef nonnull @str_buffer, i64 noundef %15, ptr noundef nonnull @blocked) #7
  %17 = icmp sgt i64 %16, -1
  br i1 %17, label %18, label %30

18:                                               ; preds = %13
  %19 = load ptr, ptr @stdout, align 8, !tbaa !5
  %20 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef nonnull @.str.3, i32 noundef %1) #7
  call void @llvm.lifetime.start.p0(i64 65536, ptr nonnull %3) #7
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(65536) %3, i8 0, i64 65536, i1 false)
  br label %21

21:                                               ; preds = %22, %18
  %.017 = phi i32 [ %1, %18 ], [ %26, %22 ]
  %.not = icmp eq i32 %.017, 0
  br i1 %.not, label %27, label %22

22:                                               ; preds = %21
  %23 = call i32 @llvm.umin.i32(i32 %.017, i32 65536)
  %24 = call i32 @flush(i32 noundef %23, ptr noundef nonnull %3, ptr noundef %0, ptr noundef nonnull @blocked)
  %25 = icmp sgt i32 %24, -1
  %26 = sub i32 %.017, %23
  br i1 %25, label %21, label %.loopexit, !llvm.loop !9

27:                                               ; preds = %21
  %28 = load ptr, ptr @stdout, align 8, !tbaa !5
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef nonnull @.str.4) #7
  br label %.loopexit

.loopexit:                                        ; preds = %22, %27
  %.2 = phi i32 [ 0, %27 ], [ -1, %22 ]
  call void @llvm.lifetime.end.p0(i64 65536, ptr nonnull %3) #7
  br label %30

30:                                               ; preds = %13, %8, %2, %.loopexit
  %.3 = phi i32 [ %.2, %.loopexit ], [ -1, %2 ], [ -1, %8 ], [ -1, %13 ]
  ret i32 %.3
}

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

declare i64 @s2n_send(ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @flush(i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umin.i32(i32, i32) #6

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 = { nofree 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 #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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(read) }

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass