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

; 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 [62 x i8], align 1
@__FUNCTION__.sm9_z256_fp12_from_hex = external hidden unnamed_addr constant [23 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @sm9_z256_fp4_from_hex(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @sm9_z256_fp12_from_hex(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds [2 x [2 x [4 x i64]]], ptr %6, i64 2
  %8 = getelementptr inbounds [2 x [2 x [4 x i64]]], ptr %7, i64 0, i64 0
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = call i32 @sm9_z256_fp4_from_hex(ptr noundef %8, ptr noundef %9)
  %11 = icmp ne i32 %10, 1
  br i1 %11, label %40, label %12

12:                                               ; preds = %2
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %13, i64 259
  %15 = load i8, ptr %14, align 1, !tbaa !9
  %16 = sext i8 %15 to i32
  %17 = icmp ne i32 %16, 10
  br i1 %17, label %40, label %18

18:                                               ; preds = %12
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds [2 x [2 x [4 x i64]]], ptr %19, i64 1
  %21 = getelementptr inbounds [2 x [2 x [4 x i64]]], ptr %20, i64 0, i64 0
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %22, i64 260
  %24 = call i32 @sm9_z256_fp4_from_hex(ptr noundef %21, ptr noundef %23)
  %25 = icmp ne i32 %24, 1
  br i1 %25, label %40, label %26

26:                                               ; preds = %18
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %27, i64 259
  %29 = load i8, ptr %28, align 1, !tbaa !9
  %30 = sext i8 %29 to i32
  %31 = icmp ne i32 %30, 10
  br i1 %31, label %40, label %32

32:                                               ; preds = %26
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds [2 x [2 x [4 x i64]]], ptr %33, i64 0
  %35 = getelementptr inbounds [2 x [2 x [4 x i64]]], ptr %34, i64 0, i64 0
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %36, i64 520
  %38 = call i32 @sm9_z256_fp4_from_hex(ptr noundef %35, ptr noundef %37)
  %39 = icmp ne i32 %38, 1
  br i1 %39, label %40, label %45

40:                                               ; preds = %32, %26, %18, %12, %2
  br label %41

41:                                               ; preds = %40
  %42 = load ptr, ptr @stderr, align 8, !tbaa !5
  %43 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %42, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1346, ptr noundef @__FUNCTION__.sm9_z256_fp12_from_hex) #2
  br label %44

44:                                               ; preds = %41
  store i32 -1, ptr %3, align 4
  br label %46

45:                                               ; preds = %32
  store i32 1, ptr %3, align 4
  br label %46

46:                                               ; preds = %45, %44
  %47 = load i32, ptr %3, align 4
  ret i32 %47
}

attributes #0 = { 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 #1 = { 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 #2 = { 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}


; 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 [62 x i8], align 1
@__FUNCTION__.sm9_z256_fp12_from_hex = external hidden unnamed_addr constant [23 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @sm9_z256_fp4_from_hex(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @sm9_z256_fp12_from_hex(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 256
  %4 = tail call i32 @sm9_z256_fp4_from_hex(ptr noundef nonnull %3, ptr noundef %1)
  %.not = icmp eq i32 %4, 1
  br i1 %.not, label %5, label %17

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %1, i64 259
  %7 = load i8, ptr %6, align 1, !tbaa !5
  %.not8 = icmp eq i8 %7, 10
  br i1 %.not8, label %8, label %17

8:                                                ; preds = %5
  %9 = getelementptr inbounds i8, ptr %0, i64 128
  %10 = getelementptr inbounds i8, ptr %1, i64 260
  %11 = tail call i32 @sm9_z256_fp4_from_hex(ptr noundef nonnull %9, ptr noundef nonnull %10)
  %.not9 = icmp eq i32 %11, 1
  br i1 %.not9, label %12, label %17

12:                                               ; preds = %8
  %13 = load i8, ptr %6, align 1, !tbaa !5
  %.not10 = icmp eq i8 %13, 10
  br i1 %.not10, label %14, label %17

14:                                               ; preds = %12
  %15 = getelementptr inbounds i8, ptr %1, i64 520
  %16 = tail call i32 @sm9_z256_fp4_from_hex(ptr noundef %0, ptr noundef nonnull %15)
  %.not11 = icmp eq i32 %16, 1
  br i1 %.not11, label %20, label %17

17:                                               ; preds = %2, %5, %8, %12, %14
  %18 = load ptr, ptr @stderr, align 8, !tbaa !8
  %19 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1346, ptr noundef nonnull @__FUNCTION__.sm9_z256_fp12_from_hex) #2
  br label %20

20:                                               ; preds = %14, %17
  %.0 = phi i32 [ -1, %17 ], [ 1, %14 ]
  ret i32 %.0
}

attributes #0 = { 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 #1 = { 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 #2 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}


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