; 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_encrypt = 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_encrypted_data_encrypt_to_der(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_encrypt(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef %5, i64 noundef %6, i32 noundef %7, ptr noundef %8, i64 noundef %9, ptr noundef %10, i64 noundef %11, ptr noundef %12, i64 noundef %13) #2 {
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = alloca i64, align 8
  %21 = alloca ptr, align 8
  %22 = alloca i64, align 8
  %23 = alloca i32, align 4
  %24 = alloca ptr, align 8
  %25 = alloca i64, align 8
  %26 = alloca ptr, align 8
  %27 = alloca i64, align 8
  %28 = alloca ptr, align 8
  %29 = alloca i64, align 8
  %30 = alloca i32, align 4
  %31 = alloca i64, align 8
  %32 = alloca i32, align 4
  %33 = alloca [1 x i8], align 1
  store ptr %0, ptr %16, align 8, !tbaa !5
  store ptr %1, ptr %17, align 8, !tbaa !5
  store i32 %2, ptr %18, align 4, !tbaa !9
  store ptr %3, ptr %19, align 8, !tbaa !5
  store i64 %4, ptr %20, align 8, !tbaa !11
  store ptr %5, ptr %21, align 8, !tbaa !5
  store i64 %6, ptr %22, align 8, !tbaa !11
  store i32 %7, ptr %23, align 4, !tbaa !9
  store ptr %8, ptr %24, align 8, !tbaa !5
  store i64 %9, ptr %25, align 8, !tbaa !11
  store ptr %10, ptr %26, align 8, !tbaa !5
  store i64 %11, ptr %27, align 8, !tbaa !11
  store ptr %12, ptr %28, align 8, !tbaa !5
  store i64 %13, ptr %29, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %30) #3
  store i32 122, ptr %30, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %31) #3
  store i64 0, ptr %31, align 8, !tbaa !11
  %34 = load i32, ptr %18, align 4, !tbaa !9
  %35 = load ptr, ptr %19, align 8, !tbaa !5
  %36 = load i64, ptr %20, align 8, !tbaa !11
  %37 = load ptr, ptr %21, align 8, !tbaa !5
  %38 = load i64, ptr %22, align 8, !tbaa !11
  %39 = load i32, ptr %23, align 4, !tbaa !9
  %40 = load ptr, ptr %24, align 8, !tbaa !5
  %41 = load i64, ptr %25, align 8, !tbaa !11
  %42 = load ptr, ptr %26, align 8, !tbaa !5
  %43 = load i64, ptr %27, align 8, !tbaa !11
  %44 = load ptr, ptr %28, align 8, !tbaa !5
  %45 = load i64, ptr %29, align 8, !tbaa !11
  %46 = call i32 @cms_encrypted_data_encrypt_to_der(i32 noundef %34, ptr noundef %35, i64 noundef %36, ptr noundef %37, i64 noundef %38, i32 noundef %39, ptr noundef %40, i64 noundef %41, ptr noundef %42, i64 noundef %43, ptr noundef %44, i64 noundef %45, ptr noundef null, ptr noundef %31)
  %47 = icmp ne i32 %46, 1
  br i1 %47, label %48, label %54

48:                                               ; preds = %14
  br label %49

49:                                               ; preds = %48
  %50 = load ptr, ptr @stderr, align 8, !tbaa !5
  %51 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %50, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 2077, ptr noundef @__FUNCTION__.cms_encrypt) #3
  br label %52

52:                                               ; preds = %49
  br label %53

53:                                               ; preds = %52
  store i32 -1, ptr %15, align 4
  store i32 1, ptr %32, align 4
  br label %102

54:                                               ; preds = %14
  %55 = load ptr, ptr %17, align 8, !tbaa !5
  store i64 0, ptr %55, align 8, !tbaa !11
  %56 = load ptr, ptr %16, align 8, !tbaa !5
  %57 = icmp ne ptr %56, null
  br i1 %57, label %73, label %58

58:                                               ; preds = %54
  call void @llvm.lifetime.start.p0(i64 1, ptr %33) #3
  %59 = load i32, ptr %30, align 4, !tbaa !9
  %60 = getelementptr inbounds [1 x i8], ptr %33, i64 0, i64 0
  %61 = load i64, ptr %31, align 8, !tbaa !11
  %62 = load ptr, ptr %17, align 8, !tbaa !5
  %63 = call i32 @cms_content_info_to_der(i32 noundef %59, ptr noundef %60, i64 noundef %61, ptr noundef null, ptr noundef %62)
  %64 = icmp ne i32 %63, 1
  br i1 %64, label %65, label %71

65:                                               ; preds = %58
  br label %66

66:                                               ; preds = %65
  %67 = load ptr, ptr @stderr, align 8, !tbaa !5
  %68 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %67, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 2084, ptr noundef @__FUNCTION__.cms_encrypt) #3
  br label %69

69:                                               ; preds = %66
  br label %70

70:                                               ; preds = %69
  store i32 -1, ptr %15, align 4
  store i32 1, ptr %32, align 4
  br label %72

71:                                               ; preds = %58
  store i32 1, ptr %15, align 4
  store i32 1, ptr %32, align 4
  br label %72

72:                                               ; preds = %71, %70
  call void @llvm.lifetime.end.p0(i64 1, ptr %33) #3
  br label %102

73:                                               ; preds = %54
  %74 = load i32, ptr %30, align 4, !tbaa !9
  %75 = load i64, ptr %31, align 8, !tbaa !11
  %76 = load ptr, ptr %17, align 8, !tbaa !5
  %77 = call i32 @cms_content_info_header_to_der(i32 noundef %74, i64 noundef %75, ptr noundef %16, ptr noundef %76)
  %78 = icmp ne i32 %77, 1
  br i1 %78, label %95, label %79

79:                                               ; preds = %73
  %80 = load i32, ptr %18, align 4, !tbaa !9
  %81 = load ptr, ptr %19, align 8, !tbaa !5
  %82 = load i64, ptr %20, align 8, !tbaa !11
  %83 = load ptr, ptr %21, align 8, !tbaa !5
  %84 = load i64, ptr %22, align 8, !tbaa !11
  %85 = load i32, ptr %23, align 4, !tbaa !9
  %86 = load ptr, ptr %24, align 8, !tbaa !5
  %87 = load i64, ptr %25, align 8, !tbaa !11
  %88 = load ptr, ptr %26, align 8, !tbaa !5
  %89 = load i64, ptr %27, align 8, !tbaa !11
  %90 = load ptr, ptr %28, align 8, !tbaa !5
  %91 = load i64, ptr %29, align 8, !tbaa !11
  %92 = load ptr, ptr %17, align 8, !tbaa !5
  %93 = call i32 @cms_encrypted_data_encrypt_to_der(i32 noundef %80, ptr noundef %81, i64 noundef %82, ptr noundef %83, i64 noundef %84, i32 noundef %85, ptr noundef %86, i64 noundef %87, ptr noundef %88, i64 noundef %89, ptr noundef %90, i64 noundef %91, ptr noundef %16, ptr noundef %92)
  %94 = icmp ne i32 %93, 1
  br i1 %94, label %95, label %101

95:                                               ; preds = %79, %73
  br label %96

96:                                               ; preds = %95
  %97 = load ptr, ptr @stderr, align 8, !tbaa !5
  %98 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %97, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 2096, ptr noundef @__FUNCTION__.cms_encrypt) #3
  br label %99

99:                                               ; preds = %96
  br label %100

100:                                              ; preds = %99
  store i32 -1, ptr %15, align 4
  store i32 1, ptr %32, align 4
  br label %102

101:                                              ; preds = %79
  store i32 1, ptr %15, align 4
  store i32 1, ptr %32, align 4
  br label %102

102:                                              ; preds = %101, %100, %72, %53
  call void @llvm.lifetime.end.p0(i64 8, ptr %31) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #3
  %103 = load i32, ptr %15, align 4
  ret i32 %103
}

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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !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_encrypt = 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_encrypted_data_encrypt_to_der(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_encrypt(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef %5, i64 noundef %6, i32 noundef %7, ptr noundef %8, i64 noundef %9, ptr noundef %10, i64 noundef %11, ptr noundef %12, i64 noundef %13) local_unnamed_addr #2 {
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca [1 x i8], align 1
  store ptr %0, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %16) #3
  store i64 0, ptr %16, align 8, !tbaa !9
  %18 = call i32 @cms_encrypted_data_encrypt_to_der(i32 noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef %5, i64 noundef %6, i32 noundef %7, ptr noundef %8, i64 noundef %9, ptr noundef %10, i64 noundef %11, ptr noundef %12, i64 noundef %13, ptr noundef null, ptr noundef nonnull %16)
  %.not = icmp eq i32 %18, 1
  br i1 %.not, label %22, label %19

19:                                               ; preds = %14
  %20 = load ptr, ptr @stderr, align 8, !tbaa !5
  %21 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 2077, ptr noundef nonnull @__FUNCTION__.cms_encrypt) #4
  br label %38

22:                                               ; preds = %14
  store i64 0, ptr %1, align 8, !tbaa !9
  %.not30 = icmp eq ptr %0, null
  br i1 %.not30, label %23, label %30

23:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %17) #3
  %24 = load i64, ptr %16, align 8, !tbaa !9
  %25 = call i32 @cms_content_info_to_der(i32 noundef 122, ptr noundef nonnull %17, i64 noundef %24, ptr noundef null, ptr noundef nonnull %1)
  %.not31 = icmp eq i32 %25, 1
  br i1 %.not31, label %29, label %26

26:                                               ; preds = %23
  %27 = load ptr, ptr @stderr, align 8, !tbaa !5
  %28 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 2084, ptr noundef nonnull @__FUNCTION__.cms_encrypt) #4
  br label %29

29:                                               ; preds = %23, %26
  %.0 = phi i32 [ -1, %26 ], [ 1, %23 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %17) #3
  br label %38

30:                                               ; preds = %22
  %31 = load i64, ptr %16, align 8, !tbaa !9
  %32 = call i32 @cms_content_info_header_to_der(i32 noundef 122, i64 noundef %31, ptr noundef nonnull %15, ptr noundef nonnull %1)
  %.not32 = icmp eq i32 %32, 1
  br i1 %.not32, label %33, label %35

33:                                               ; preds = %30
  %34 = call i32 @cms_encrypted_data_encrypt_to_der(i32 noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef %5, i64 noundef %6, i32 noundef %7, ptr noundef %8, i64 noundef %9, ptr noundef %10, i64 noundef %11, ptr noundef %12, i64 noundef %13, ptr noundef nonnull %15, ptr noundef nonnull %1)
  %.not33 = icmp eq i32 %34, 1
  br i1 %.not33, label %38, label %35

35:                                               ; preds = %30, %33
  %36 = load ptr, ptr @stderr, align 8, !tbaa !5
  %37 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 2096, ptr noundef nonnull @__FUNCTION__.cms_encrypt) #4
  br label %38

38:                                               ; preds = %33, %35, %29, %19
  %.1 = phi i32 [ -1, %19 ], [ -1, %35 ], [ %.0, %29 ], [ 1, %33 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %16) #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