; LLVM IR from openanolis/openssl :: crypto/ec (ec_print)

; 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 = external hidden unnamed_addr constant [73 x i8], align 1
@HEX_DIGITS = external hidden global ptr, align 8

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

25:                                               ; preds = %4
  store ptr null, ptr %5, align 8
  store i32 1, ptr %16, align 4
  br label %70

26:                                               ; preds = %4
  %27 = load i64, ptr %12, align 8, !tbaa !11
  %28 = mul i64 %27, 2
  %29 = add i64 %28, 2
  %30 = call ptr @CRYPTO_malloc(i64 noundef %29, ptr noundef @.str, i32 noundef 30)
  store ptr %30, ptr %10, align 8, !tbaa !5
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = icmp eq ptr %31, null
  br i1 %32, label %33, label %35

33:                                               ; preds = %26
  %34 = load ptr, ptr %14, align 8, !tbaa !5
  call void @CRYPTO_free(ptr noundef %34, ptr noundef @.str, i32 noundef 32)
  store ptr null, ptr %5, align 8
  store i32 1, ptr %16, align 4
  br label %70

35:                                               ; preds = %26
  %36 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %36, ptr %11, align 8, !tbaa !5
  %37 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %37, ptr %15, align 8, !tbaa !5
  %38 = load i64, ptr %12, align 8, !tbaa !11
  store i64 %38, ptr %13, align 8, !tbaa !11
  br label %39

39:                                               ; preds = %63, %35
  %40 = load i64, ptr %13, align 8, !tbaa !11
  %41 = icmp ugt i64 %40, 0
  br i1 %41, label %42, label %66

42:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %43 = load ptr, ptr %15, align 8, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %43, i32 1
  store ptr %44, ptr %15, align 8, !tbaa !5
  %45 = load i8, ptr %43, align 1, !tbaa !13
  %46 = zext i8 %45 to i32
  store i32 %46, ptr %17, align 4, !tbaa !9
  %47 = load ptr, ptr @HEX_DIGITS, align 8, !tbaa !5
  %48 = load i32, ptr %17, align 4, !tbaa !9
  %49 = ashr i32 %48, 4
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds i8, ptr %47, i64 %50
  %52 = load i8, ptr %51, align 1, !tbaa !13
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = getelementptr inbounds i8, ptr %53, i32 1
  store ptr %54, ptr %11, align 8, !tbaa !5
  store i8 %52, ptr %53, align 1, !tbaa !13
  %55 = load ptr, ptr @HEX_DIGITS, align 8, !tbaa !5
  %56 = load i32, ptr %17, align 4, !tbaa !9
  %57 = and i32 %56, 15
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds i8, ptr %55, i64 %58
  %60 = load i8, ptr %59, align 1, !tbaa !13
  %61 = load ptr, ptr %11, align 8, !tbaa !5
  %62 = getelementptr inbounds i8, ptr %61, i32 1
  store ptr %62, ptr %11, align 8, !tbaa !5
  store i8 %60, ptr %61, align 1, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  br label %63

63:                                               ; preds = %42
  %64 = load i64, ptr %13, align 8, !tbaa !11
  %65 = add i64 %64, -1
  store i64 %65, ptr %13, align 8, !tbaa !11
  br label %39, !llvm.loop !14

66:                                               ; preds = %39
  %67 = load ptr, ptr %11, align 8, !tbaa !5
  store i8 0, ptr %67, align 1, !tbaa !13
  %68 = load ptr, ptr %14, align 8, !tbaa !5
  call void @CRYPTO_free(ptr noundef %68, ptr noundef @.str, i32 noundef 44)
  %69 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %69, ptr %5, align 8
  store i32 1, ptr %16, align 4
  br label %70

70:                                               ; preds = %66, %33, %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %71 = load ptr, ptr %5, align 8
  ret ptr %71
}

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

declare i64 @EC_POINT_point2buf(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) #2

declare ptr @CRYPTO_malloc(i64 noundef, ptr noundef, i32 noundef) #2

declare void @CRYPTO_free(ptr noundef, ptr noundef, i32 noundef) #2

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

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 = { "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}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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 = external hidden unnamed_addr constant [73 x i8], align 1
@HEX_DIGITS = external hidden local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local ptr @EC_POINT_point2hex(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  store ptr null, ptr %5, align 8, !tbaa !5
  %6 = call i64 @EC_POINT_point2buf(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef nonnull %5, ptr noundef %3) #3
  %7 = icmp eq i64 %6, 0
  br i1 %7, label %64, label %8

8:                                                ; preds = %4
  %9 = shl i64 %6, 1
  %10 = add i64 %9, 2
  %11 = call ptr @CRYPTO_malloc(i64 noundef %10, ptr noundef nonnull @.str, i32 noundef 30) #3
  %12 = icmp eq ptr %11, null
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  br i1 %12, label %31, label %.preheader.preheader

.preheader.preheader:                             ; preds = %8
  %xtraiter = and i64 %6, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader.prol.loopexit, label %.preheader.prol

.preheader.prol:                                  ; preds = %.preheader.preheader
  %14 = getelementptr inbounds i8, ptr %13, i64 1
  %15 = load i8, ptr %13, align 1, !tbaa !9
  %16 = zext i8 %15 to i32
  %17 = load ptr, ptr @HEX_DIGITS, align 8, !tbaa !5
  %18 = lshr i32 %16, 4
  %19 = zext nneg i32 %18 to i64
  %20 = getelementptr inbounds i8, ptr %17, i64 %19
  %21 = load i8, ptr %20, align 1, !tbaa !9
  %22 = getelementptr inbounds i8, ptr %11, i64 1
  store i8 %21, ptr %11, align 1, !tbaa !9
  %23 = load ptr, ptr @HEX_DIGITS, align 8, !tbaa !5
  %24 = and i32 %16, 15
  %25 = zext nneg i32 %24 to i64
  %26 = getelementptr inbounds i8, ptr %23, i64 %25
  %27 = load i8, ptr %26, align 1, !tbaa !9
  %28 = getelementptr inbounds i8, ptr %11, i64 2
  store i8 %27, ptr %22, align 1, !tbaa !9
  %29 = add nsw i64 %6, -1
  br label %.preheader.prol.loopexit

.preheader.prol.loopexit:                         ; preds = %.preheader.prol, %.preheader.preheader
  %.lcssa.unr = phi ptr [ poison, %.preheader.preheader ], [ %28, %.preheader.prol ]
  %.01825.unr = phi ptr [ %13, %.preheader.preheader ], [ %14, %.preheader.prol ]
  %.01924.unr = phi i64 [ %6, %.preheader.preheader ], [ %29, %.preheader.prol ]
  %.02023.unr = phi ptr [ %11, %.preheader.preheader ], [ %28, %.preheader.prol ]
  %30 = icmp eq i64 %6, 1
  br i1 %30, label %.unr-lcssa, label %.preheader

31:                                               ; preds = %8
  call void @CRYPTO_free(ptr noundef %13, ptr noundef nonnull @.str, i32 noundef 32) #3
  br label %64

.preheader:                                       ; preds = %.preheader.prol.loopexit, %.preheader
  %.01825 = phi ptr [ %47, %.preheader ], [ %.01825.unr, %.preheader.prol.loopexit ]
  %.01924 = phi i64 [ %62, %.preheader ], [ %.01924.unr, %.preheader.prol.loopexit ]
  %.02023 = phi ptr [ %61, %.preheader ], [ %.02023.unr, %.preheader.prol.loopexit ]
  %32 = getelementptr inbounds i8, ptr %.01825, i64 1
  %33 = load i8, ptr %.01825, align 1, !tbaa !9
  %34 = zext i8 %33 to i32
  %35 = load ptr, ptr @HEX_DIGITS, align 8, !tbaa !5
  %36 = lshr i32 %34, 4
  %37 = zext nneg i32 %36 to i64
  %38 = getelementptr inbounds i8, ptr %35, i64 %37
  %39 = load i8, ptr %38, align 1, !tbaa !9
  %40 = getelementptr inbounds i8, ptr %.02023, i64 1
  store i8 %39, ptr %.02023, align 1, !tbaa !9
  %41 = load ptr, ptr @HEX_DIGITS, align 8, !tbaa !5
  %42 = and i32 %34, 15
  %43 = zext nneg i32 %42 to i64
  %44 = getelementptr inbounds i8, ptr %41, i64 %43
  %45 = load i8, ptr %44, align 1, !tbaa !9
  %46 = getelementptr inbounds i8, ptr %.02023, i64 2
  store i8 %45, ptr %40, align 1, !tbaa !9
  %47 = getelementptr inbounds i8, ptr %.01825, i64 2
  %48 = load i8, ptr %32, align 1, !tbaa !9
  %49 = zext i8 %48 to i32
  %50 = load ptr, ptr @HEX_DIGITS, align 8, !tbaa !5
  %51 = lshr i32 %49, 4
  %52 = zext nneg i32 %51 to i64
  %53 = getelementptr inbounds i8, ptr %50, i64 %52
  %54 = load i8, ptr %53, align 1, !tbaa !9
  %55 = getelementptr inbounds i8, ptr %.02023, i64 3
  store i8 %54, ptr %46, align 1, !tbaa !9
  %56 = load ptr, ptr @HEX_DIGITS, align 8, !tbaa !5
  %57 = and i32 %49, 15
  %58 = zext nneg i32 %57 to i64
  %59 = getelementptr inbounds i8, ptr %56, i64 %58
  %60 = load i8, ptr %59, align 1, !tbaa !9
  %61 = getelementptr inbounds i8, ptr %.02023, i64 4
  store i8 %60, ptr %55, align 1, !tbaa !9
  %62 = add i64 %.01924, -2
  %.not.1 = icmp eq i64 %62, 0
  br i1 %.not.1, label %.unr-lcssa, label %.preheader, !llvm.loop !10

.unr-lcssa:                                       ; preds = %.preheader, %.preheader.prol.loopexit
  %.lcssa = phi ptr [ %.lcssa.unr, %.preheader.prol.loopexit ], [ %61, %.preheader ]
  store i8 0, ptr %.lcssa, align 1, !tbaa !9
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  call void @CRYPTO_free(ptr noundef %63, ptr noundef nonnull @.str, i32 noundef 44) #3
  br label %64

64:                                               ; preds = %4, %.unr-lcssa, %31
  %.0 = phi ptr [ null, %31 ], [ %11, %.unr-lcssa ], [ null, %4 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  ret ptr %.0
}

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

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

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

declare void @CRYPTO_free(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

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

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

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


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass