; LLVM IR from guanzhi/GmSSL :: src (tls_trace)

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

@stderr = external global ptr, align 8
@.str.130 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.213 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.222 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.258 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.259 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.261 = external hidden unnamed_addr constant [2 x i8], align 1
@__FUNCTION__.tls_encrypted_record_print = external hidden unnamed_addr constant [27 x i8], align 1
@.str.270 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.271 = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @tls_record_type_name(i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @tls_protocol_name(i32 noundef) #0

; 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) #2

declare i32 @format_print(ptr noundef, i32 noundef, i32 noundef, ptr noundef, ...) #3

declare i32 @format_bytes(ptr noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, i64 noundef) #3

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

; Function Attrs: nounwind uwtable
define dso_local i32 @tls_encrypted_record_print(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, i32 noundef %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i64 %2, ptr %9, align 8, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !11
  store i32 %4, ptr %11, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %22

16:                                               ; preds = %5
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %22

19:                                               ; preds = %16
  %20 = load i64, ptr %9, align 8, !tbaa !9
  %21 = icmp ult i64 %20, 5
  br i1 %21, label %22, label %28

22:                                               ; preds = %19, %16, %5
  br label %23

23:                                               ; preds = %22
  %24 = load ptr, ptr @stderr, align 8, !tbaa !5
  %25 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef @.str.213, ptr noundef @.str.130, i32 noundef 1174, ptr noundef @__FUNCTION__.tls_encrypted_record_print) #4
  br label %26

26:                                               ; preds = %23
  br label %27

27:                                               ; preds = %26
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %104

28:                                               ; preds = %19
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %29, i64 1
  %31 = load i8, ptr %30, align 1, !tbaa !13
  %32 = zext i8 %31 to i16
  %33 = zext i16 %32 to i32
  %34 = shl i32 %33, 8
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %35, i64 2
  %37 = load i8, ptr %36, align 1, !tbaa !13
  %38 = zext i8 %37 to i32
  %39 = or i32 %34, %38
  store i32 %39, ptr %12, align 4, !tbaa !11
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = load i32, ptr %10, align 4, !tbaa !11
  %42 = load i32, ptr %11, align 4, !tbaa !11
  %43 = call i32 (ptr, i32, i32, ptr, ...) @format_print(ptr noundef %40, i32 noundef %41, i32 noundef %42, ptr noundef @.str.270)
  %44 = load i32, ptr %11, align 4, !tbaa !11
  %45 = add nsw i32 %44, 4
  store i32 %45, ptr %11, align 4, !tbaa !11
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = load i32, ptr %10, align 4, !tbaa !11
  %48 = load i32, ptr %11, align 4, !tbaa !11
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %49, i64 0
  %51 = load i8, ptr %50, align 1, !tbaa !13
  %52 = zext i8 %51 to i32
  %53 = call ptr @tls_record_type_name(i32 noundef %52)
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = getelementptr inbounds i8, ptr %54, i64 0
  %56 = load i8, ptr %55, align 1, !tbaa !13
  %57 = zext i8 %56 to i32
  %58 = call i32 (ptr, i32, i32, ptr, ...) @format_print(ptr noundef %46, i32 noundef %47, i32 noundef %48, ptr noundef @.str.258, ptr noundef %53, i32 noundef %57)
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = load i32, ptr %10, align 4, !tbaa !11
  %61 = load i32, ptr %11, align 4, !tbaa !11
  %62 = load i32, ptr %12, align 4, !tbaa !11
  %63 = call ptr @tls_protocol_name(i32 noundef %62)
  %64 = load i32, ptr %12, align 4, !tbaa !11
  %65 = ashr i32 %64, 8
  %66 = load i32, ptr %12, align 4, !tbaa !11
  %67 = and i32 %66, 255
  %68 = call i32 (ptr, i32, i32, ptr, ...) @format_print(ptr noundef %59, i32 noundef %60, i32 noundef %61, ptr noundef @.str.222, ptr noundef %63, i32 noundef %65, i32 noundef %67)
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = load i32, ptr %10, align 4, !tbaa !11
  %71 = load i32, ptr %11, align 4, !tbaa !11
  %72 = load ptr, ptr %8, align 8, !tbaa !5
  %73 = getelementptr inbounds i8, ptr %72, i64 3
  %74 = load i8, ptr %73, align 1, !tbaa !13
  %75 = zext i8 %74 to i16
  %76 = zext i16 %75 to i32
  %77 = shl i32 %76, 8
  %78 = load ptr, ptr %8, align 8, !tbaa !5
  %79 = getelementptr inbounds i8, ptr %78, i64 4
  %80 = load i8, ptr %79, align 1, !tbaa !13
  %81 = zext i8 %80 to i32
  %82 = or i32 %77, %81
  %83 = call i32 (ptr, i32, i32, ptr, ...) @format_print(ptr noundef %69, i32 noundef %70, i32 noundef %71, ptr noundef @.str.259, i32 noundef %82)
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  %85 = load i32, ptr %10, align 4, !tbaa !11
  %86 = load i32, ptr %11, align 4, !tbaa !11
  %87 = load ptr, ptr %8, align 8, !tbaa !5
  %88 = getelementptr inbounds i8, ptr %87, i64 5
  %89 = load ptr, ptr %8, align 8, !tbaa !5
  %90 = getelementptr inbounds i8, ptr %89, i64 3
  %91 = load i8, ptr %90, align 1, !tbaa !13
  %92 = zext i8 %91 to i16
  %93 = zext i16 %92 to i32
  %94 = shl i32 %93, 8
  %95 = load ptr, ptr %8, align 8, !tbaa !5
  %96 = getelementptr inbounds i8, ptr %95, i64 4
  %97 = load i8, ptr %96, align 1, !tbaa !13
  %98 = zext i8 %97 to i32
  %99 = or i32 %94, %98
  %100 = sext i32 %99 to i64
  %101 = call i32 @format_bytes(ptr noundef %84, i32 noundef %85, i32 noundef %86, ptr noundef @.str.271, ptr noundef %88, i64 noundef %100)
  %102 = load ptr, ptr %7, align 8, !tbaa !5
  %103 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %102, ptr noundef @.str.261) #4
  store i32 1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %104

104:                                              ; preds = %28, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  %105 = load i32, ptr %6, align 4
  ret i32 %105
}

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 = { nocallback nofree nosync 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 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str.130 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.213 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.222 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.258 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.259 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.261 = external hidden unnamed_addr constant [2 x i8], align 1
@__FUNCTION__.tls_encrypted_record_print = external hidden unnamed_addr constant [27 x i8], align 1
@.str.270 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.271 = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @tls_record_type_name(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @tls_protocol_name(i32 noundef) local_unnamed_addr #0

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

declare i32 @format_print(ptr noundef, i32 noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #2

declare i32 @format_bytes(ptr noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @tls_encrypted_record_print(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = icmp eq ptr %0, null
  %7 = icmp eq ptr %1, null
  %or.cond.not36 = or i1 %6, %7
  %8 = icmp ult i64 %2, 5
  %or.cond3 = or i1 %or.cond.not36, %8
  br i1 %or.cond3, label %9, label %12

9:                                                ; preds = %5
  %10 = load ptr, ptr @stderr, align 8, !tbaa !5
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef nonnull @.str.213, ptr noundef nonnull @.str.130, i32 noundef 1174, ptr noundef nonnull @__FUNCTION__.tls_encrypted_record_print) #3
  br label %49

12:                                               ; preds = %5
  %13 = getelementptr inbounds i8, ptr %1, i64 1
  %14 = load i8, ptr %13, align 1, !tbaa !9
  %15 = zext i8 %14 to i32
  %16 = shl nuw nsw i32 %15, 8
  %17 = getelementptr inbounds i8, ptr %1, i64 2
  %18 = load i8, ptr %17, align 1, !tbaa !9
  %19 = zext i8 %18 to i32
  %20 = or disjoint i32 %16, %19
  %21 = tail call i32 (ptr, i32, i32, ptr, ...) @format_print(ptr noundef nonnull %0, i32 noundef %3, i32 noundef %4, ptr noundef nonnull @.str.270) #4
  %22 = add nsw i32 %4, 4
  %23 = load i8, ptr %1, align 1, !tbaa !9
  %24 = zext i8 %23 to i32
  %25 = tail call ptr @tls_record_type_name(i32 noundef %24)
  %26 = load i8, ptr %1, align 1, !tbaa !9
  %27 = zext i8 %26 to i32
  %28 = tail call i32 (ptr, i32, i32, ptr, ...) @format_print(ptr noundef nonnull %0, i32 noundef %3, i32 noundef %22, ptr noundef nonnull @.str.258, ptr noundef %25, i32 noundef %27) #4
  %29 = tail call ptr @tls_protocol_name(i32 noundef %20)
  %30 = tail call i32 (ptr, i32, i32, ptr, ...) @format_print(ptr noundef nonnull %0, i32 noundef %3, i32 noundef %22, ptr noundef nonnull @.str.222, ptr noundef %29, i32 noundef %15, i32 noundef %19) #4
  %31 = getelementptr inbounds i8, ptr %1, i64 3
  %32 = load i8, ptr %31, align 1, !tbaa !9
  %33 = zext i8 %32 to i32
  %34 = shl nuw nsw i32 %33, 8
  %35 = getelementptr inbounds i8, ptr %1, i64 4
  %36 = load i8, ptr %35, align 1, !tbaa !9
  %37 = zext i8 %36 to i32
  %38 = or disjoint i32 %34, %37
  %39 = tail call i32 (ptr, i32, i32, ptr, ...) @format_print(ptr noundef nonnull %0, i32 noundef %3, i32 noundef %22, ptr noundef nonnull @.str.259, i32 noundef %38) #4
  %40 = getelementptr inbounds i8, ptr %1, i64 5
  %41 = load i8, ptr %31, align 1, !tbaa !9
  %42 = zext i8 %41 to i64
  %43 = shl nuw nsw i64 %42, 8
  %44 = load i8, ptr %35, align 1, !tbaa !9
  %45 = zext i8 %44 to i64
  %46 = or disjoint i64 %43, %45
  %47 = tail call i32 @format_bytes(ptr noundef nonnull %0, i32 noundef %3, i32 noundef %22, ptr noundef nonnull @.str.271, ptr noundef nonnull %40, i64 noundef %46) #4
  %48 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %0, ptr noundef nonnull @.str.261) #4
  br label %49

49:                                               ; preds = %12, %9
  %.0 = phi i32 [ -1, %9 ], [ 1, %12 ]
  ret i32 %.0
}

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 = { cold nounwind }
attributes #4 = { 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 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass