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

; 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 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [57 x i8], align 1
@__FUNCTION__.cms_envelop = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #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.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @cms_content_info_header_to_der(i32 noundef, i64 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @cms_content_info_to_der(i32 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @cms_enveloped_data_encrypt_to_der(ptr noundef, i64 noundef, i32 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @cms_envelop(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, i32 noundef %4, ptr noundef %5, i64 noundef %6, ptr noundef %7, i64 noundef %8, i32 noundef %9, ptr noundef %10, i64 noundef %11, ptr noundef %12, i64 noundef %13, ptr noundef %14, i64 noundef %15) #2 {
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca i64, align 8
  %22 = alloca i32, align 4
  %23 = alloca ptr, align 8
  %24 = alloca i64, align 8
  %25 = alloca ptr, align 8
  %26 = alloca i64, align 8
  %27 = alloca i32, align 4
  %28 = alloca ptr, align 8
  %29 = alloca i64, align 8
  %30 = alloca ptr, align 8
  %31 = alloca i64, align 8
  %32 = alloca ptr, align 8
  %33 = alloca i64, align 8
  %34 = alloca i32, align 4
  %35 = alloca i64, align 8
  %36 = alloca i32, align 4
  %37 = alloca [1 x i8], align 1
  store ptr %0, ptr %18, align 8, !tbaa !5
  store ptr %1, ptr %19, align 8, !tbaa !5
  store ptr %2, ptr %20, align 8, !tbaa !5
  store i64 %3, ptr %21, align 8, !tbaa !9
  store i32 %4, ptr %22, align 4, !tbaa !11
  store ptr %5, ptr %23, align 8, !tbaa !5
  store i64 %6, ptr %24, align 8, !tbaa !9
  store ptr %7, ptr %25, align 8, !tbaa !5
  store i64 %8, ptr %26, align 8, !tbaa !9
  store i32 %9, ptr %27, align 4, !tbaa !11
  store ptr %10, ptr %28, align 8, !tbaa !5
  store i64 %11, ptr %29, align 8, !tbaa !9
  store ptr %12, ptr %30, align 8, !tbaa !5
  store i64 %13, ptr %31, align 8, !tbaa !9
  store ptr %14, ptr %32, align 8, !tbaa !5
  store i64 %15, ptr %33, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %34) #3
  store i32 120, ptr %34, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %35) #3
  store i64 0, ptr %35, align 8, !tbaa !9
  %38 = load ptr, ptr %20, align 8, !tbaa !5
  %39 = load i64, ptr %21, align 8, !tbaa !9
  %40 = load i32, ptr %22, align 4, !tbaa !11
  %41 = load ptr, ptr %23, align 8, !tbaa !5
  %42 = load i64, ptr %24, align 8, !tbaa !9
  %43 = load ptr, ptr %25, align 8, !tbaa !5
  %44 = load i64, ptr %26, align 8, !tbaa !9
  %45 = load i32, ptr %27, align 4, !tbaa !11
  %46 = load ptr, ptr %28, align 8, !tbaa !5
  %47 = load i64, ptr %29, align 8, !tbaa !9
  %48 = load ptr, ptr %30, align 8, !tbaa !5
  %49 = load i64, ptr %31, align 8, !tbaa !9
  %50 = load ptr, ptr %32, align 8, !tbaa !5
  %51 = load i64, ptr %33, align 8, !tbaa !9
  %52 = call i32 @cms_enveloped_data_encrypt_to_der(ptr noundef %38, i64 noundef %39, i32 noundef %40, ptr noundef %41, i64 noundef %42, ptr noundef %43, i64 noundef %44, i32 noundef %45, ptr noundef %46, i64 noundef %47, ptr noundef %48, i64 noundef %49, ptr noundef %50, i64 noundef %51, ptr noundef null, ptr noundef %35)
  %53 = icmp ne i32 %52, 1
  br i1 %53, label %54, label %60

54:                                               ; preds = %16
  br label %55

55:                                               ; preds = %54
  %56 = load ptr, ptr @stderr, align 8, !tbaa !5
  %57 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %56, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 2228, ptr noundef @__FUNCTION__.cms_envelop) #3
  br label %58

58:                                               ; preds = %55
  br label %59

59:                                               ; preds = %58
  store i32 -1, ptr %17, align 4
  store i32 1, ptr %36, align 4
  br label %110

60:                                               ; preds = %16
  %61 = load ptr, ptr %19, align 8, !tbaa !5
  store i64 0, ptr %61, align 8, !tbaa !9
  %62 = load ptr, ptr %18, align 8, !tbaa !5
  %63 = icmp ne ptr %62, null
  br i1 %63, label %79, label %64

64:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 1, ptr %37) #3
  %65 = load i32, ptr %34, align 4, !tbaa !11
  %66 = getelementptr inbounds [1 x i8], ptr %37, i64 0, i64 0
  %67 = load i64, ptr %35, align 8, !tbaa !9
  %68 = load ptr, ptr %19, align 8, !tbaa !5
  %69 = call i32 @cms_content_info_to_der(i32 noundef %65, ptr noundef %66, i64 noundef %67, ptr noundef null, ptr noundef %68)
  %70 = icmp ne i32 %69, 1
  br i1 %70, label %71, label %77

71:                                               ; preds = %64
  br label %72

72:                                               ; preds = %71
  %73 = load ptr, ptr @stderr, align 8, !tbaa !5
  %74 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %73, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 2235, ptr noundef @__FUNCTION__.cms_envelop) #3
  br label %75

75:                                               ; preds = %72
  br label %76

76:                                               ; preds = %75
  store i32 -1, ptr %17, align 4
  store i32 1, ptr %36, align 4
  br label %78

77:                                               ; preds = %64
  store i32 1, ptr %17, align 4
  store i32 1, ptr %36, align 4
  br label %78

78:                                               ; preds = %77, %76
  call void @llvm.lifetime.end.p0(i64 1, ptr %37) #3
  br label %110

79:                                               ; preds = %60
  %80 = load i32, ptr %34, align 4, !tbaa !11
  %81 = load i64, ptr %35, align 8, !tbaa !9
  %82 = load ptr, ptr %19, align 8, !tbaa !5
  %83 = call i32 @cms_content_info_header_to_der(i32 noundef %80, i64 noundef %81, ptr noundef %18, ptr noundef %82)
  %84 = icmp ne i32 %83, 1
  br i1 %84, label %103, label %85

85:                                               ; preds = %79
  %86 = load ptr, ptr %20, align 8, !tbaa !5
  %87 = load i64, ptr %21, align 8, !tbaa !9
  %88 = load i32, ptr %22, align 4, !tbaa !11
  %89 = load ptr, ptr %23, align 8, !tbaa !5
  %90 = load i64, ptr %24, align 8, !tbaa !9
  %91 = load ptr, ptr %25, align 8, !tbaa !5
  %92 = load i64, ptr %26, align 8, !tbaa !9
  %93 = load i32, ptr %27, align 4, !tbaa !11
  %94 = load ptr, ptr %28, align 8, !tbaa !5
  %95 = load i64, ptr %29, align 8, !tbaa !9
  %96 = load ptr, ptr %30, align 8, !tbaa !5
  %97 = load i64, ptr %31, align 8, !tbaa !9
  %98 = load ptr, ptr %32, align 8, !tbaa !5
  %99 = load i64, ptr %33, align 8, !tbaa !9
  %100 = load ptr, ptr %19, align 8, !tbaa !5
  %101 = call i32 @cms_enveloped_data_encrypt_to_der(ptr noundef %86, i64 noundef %87, i32 noundef %88, ptr noundef %89, i64 noundef %90, ptr noundef %91, i64 noundef %92, i32 noundef %93, ptr noundef %94, i64 noundef %95, ptr noundef %96, i64 noundef %97, ptr noundef %98, i64 noundef %99, ptr noundef %18, ptr noundef %100)
  %102 = icmp ne i32 %101, 1
  br i1 %102, label %103, label %109

103:                                              ; preds = %85, %79
  br label %104

104:                                              ; preds = %103
  %105 = load ptr, ptr @stderr, align 8, !tbaa !5
  %106 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %105, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 2248, ptr noundef @__FUNCTION__.cms_envelop) #3
  br label %107

107:                                              ; preds = %104
  br label %108

108:                                              ; preds = %107
  store i32 -1, ptr %17, align 4
  store i32 1, ptr %36, align 4
  br label %110

109:                                              ; preds = %85
  store i32 1, ptr %17, align 4
  store i32 1, ptr %36, align 4
  br label %110

110:                                              ; preds = %109, %108, %78, %59
  call void @llvm.lifetime.end.p0(i64 8, ptr %35) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %34) #3
  %111 = load i32, ptr %17, align 4
  ret i32 %111
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { 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}


; 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 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [57 x i8], align 1
@__FUNCTION__.cms_envelop = external hidden unnamed_addr constant [12 x i8], align 1

; 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 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.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @cms_content_info_header_to_der(i32 noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @cms_content_info_to_der(i32 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @cms_enveloped_data_encrypt_to_der(ptr noundef, i64 noundef, i32 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @cms_envelop(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, i32 noundef %4, ptr noundef %5, i64 noundef %6, ptr noundef %7, i64 noundef %8, i32 noundef %9, ptr noundef %10, i64 noundef %11, ptr noundef %12, i64 noundef %13, ptr noundef %14, i64 noundef %15) local_unnamed_addr #2 {
  %17 = alloca ptr, align 8
  %18 = alloca i64, align 8
  %19 = alloca [1 x i8], align 1
  store ptr %0, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %18) #3
  store i64 0, ptr %18, align 8, !tbaa !9
  %20 = call i32 @cms_enveloped_data_encrypt_to_der(ptr noundef %2, i64 noundef %3, i32 noundef %4, ptr noundef %5, i64 noundef %6, ptr noundef %7, i64 noundef %8, i32 noundef %9, ptr noundef %10, i64 noundef %11, ptr noundef %12, i64 noundef %13, ptr noundef %14, i64 noundef %15, ptr noundef null, ptr noundef nonnull %18)
  %.not = icmp eq i32 %20, 1
  br i1 %.not, label %24, label %21

21:                                               ; preds = %16
  %22 = load ptr, ptr @stderr, align 8, !tbaa !5
  %23 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 2228, ptr noundef nonnull @__FUNCTION__.cms_envelop) #4
  br label %40

24:                                               ; preds = %16
  store i64 0, ptr %1, align 8, !tbaa !9
  %.not34 = icmp eq ptr %0, null
  br i1 %.not34, label %25, label %32

25:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %19) #3
  %26 = load i64, ptr %18, align 8, !tbaa !9
  %27 = call i32 @cms_content_info_to_der(i32 noundef 120, ptr noundef nonnull %19, i64 noundef %26, ptr noundef null, ptr noundef nonnull %1)
  %.not35 = icmp eq i32 %27, 1
  br i1 %.not35, label %31, label %28

28:                                               ; preds = %25
  %29 = load ptr, ptr @stderr, align 8, !tbaa !5
  %30 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %29, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 2235, ptr noundef nonnull @__FUNCTION__.cms_envelop) #4
  br label %31

31:                                               ; preds = %25, %28
  %.0 = phi i32 [ -1, %28 ], [ 1, %25 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %19) #3
  br label %40

32:                                               ; preds = %24
  %33 = load i64, ptr %18, align 8, !tbaa !9
  %34 = call i32 @cms_content_info_header_to_der(i32 noundef 120, i64 noundef %33, ptr noundef nonnull %17, ptr noundef nonnull %1)
  %.not36 = icmp eq i32 %34, 1
  br i1 %.not36, label %35, label %37

35:                                               ; preds = %32
  %36 = call i32 @cms_enveloped_data_encrypt_to_der(ptr noundef %2, i64 noundef %3, i32 noundef %4, ptr noundef %5, i64 noundef %6, ptr noundef %7, i64 noundef %8, i32 noundef %9, ptr noundef %10, i64 noundef %11, ptr noundef %12, i64 noundef %13, ptr noundef %14, i64 noundef %15, ptr noundef nonnull %17, ptr noundef nonnull %1)
  %.not37 = icmp eq i32 %36, 1
  br i1 %.not37, label %40, label %37

37:                                               ; preds = %32, %35
  %38 = load ptr, ptr @stderr, align 8, !tbaa !5
  %39 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %38, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 2248, ptr noundef nonnull @__FUNCTION__.cms_envelop) #4
  br label %40

40:                                               ; preds = %35, %37, %31, %21
  %.1 = phi i32 [ -1, %21 ], [ -1, %37 ], [ %.0, %31 ], [ 1, %35 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %18) #3
  ret i32 %.1
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { nounwind }
attributes #4 = { cold 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}


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