; LLVM IR from guanzhi/GmSSL :: tests (gf128test)

; 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.18 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [9 x i8], align 1
@__const.test_gf128_from_hex.tests = external hidden unnamed_addr constant [5 x ptr], align 16
@__FUNCTION__.test_gf128_from_hex = external hidden unnamed_addr constant [20 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

declare i32 @printf(ptr noundef, ...) #2

declare i32 @gf128_from_hex(ptr noundef, ptr noundef) #2

declare i32 @gf128_equ_hex(ptr noundef, ptr noundef) #2

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

; 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
define dso_local i32 @test_gf128_from_hex() #4 {
  %1 = alloca i32, align 4
  %2 = alloca [5 x ptr], align 16
  %3 = alloca [2 x i64], align 16
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 40, ptr %2) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %2, ptr align 16 @__const.test_gf128_from_hex.tests, i64 40, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %31, %0
  %7 = load i32, ptr %4, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %9 = icmp ult i64 %8, 5
  br i1 %9, label %10, label %34

10:                                               ; preds = %6
  %11 = getelementptr inbounds [2 x i64], ptr %3, i64 0, i64 0
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [5 x ptr], ptr %2, i64 0, i64 %13
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = call i32 @gf128_from_hex(ptr noundef %11, ptr noundef %15)
  %17 = getelementptr inbounds [2 x i64], ptr %3, i64 0, i64 0
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [5 x ptr], ptr %2, i64 0, i64 %19
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %22 = call i32 @gf128_equ_hex(ptr noundef %17, ptr noundef %21)
  %23 = icmp ne i32 %22, 1
  br i1 %23, label %24, label %30

24:                                               ; preds = %10
  br label %25

25:                                               ; preds = %24
  %26 = load ptr, ptr @stderr, align 8, !tbaa !9
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef @.str.18, ptr noundef @.str.19, i32 noundef 112, ptr noundef @__FUNCTION__.test_gf128_from_hex) #5
  br label %28

28:                                               ; preds = %25
  br label %29

29:                                               ; preds = %28
  store i32 -1, ptr %1, align 4
  store i32 1, ptr %5, align 4
  br label %36

30:                                               ; preds = %10
  br label %31

31:                                               ; preds = %30
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %4, align 4, !tbaa !5
  br label %6, !llvm.loop !11

34:                                               ; preds = %6
  %35 = call i32 (ptr, ...) @printf(ptr noundef @.str.20, ptr noundef @__FUNCTION__.test_gf128_from_hex)
  store i32 1, ptr %1, align 4
  store i32 1, ptr %5, align 4
  br label %36

36:                                               ; preds = %34, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr %2) #5
  %37 = load i32, ptr %1, align 4
  ret i32 %37
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree 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 "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 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 #5 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str.18 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [9 x i8], align 1
@__const.test_gf128_from_hex.tests = external hidden unnamed_addr constant [5 x ptr], align 16
@__FUNCTION__.test_gf128_from_hex = external hidden unnamed_addr constant [20 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 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

declare i32 @gf128_from_hex(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @gf128_equ_hex(ptr noundef, ptr noundef) local_unnamed_addr #2

; 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
define dso_local range(i32 -1, 2) i32 @test_gf128_from_hex() local_unnamed_addr #3 {
  %1 = alloca [2 x i64], align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #4
  %2 = load ptr, ptr @__const.test_gf128_from_hex.tests, align 16, !tbaa !5
  %3 = call i32 @gf128_from_hex(ptr noundef nonnull %1, ptr noundef %2) #4
  %4 = call i32 @gf128_equ_hex(ptr noundef nonnull %1, ptr noundef %2) #4
  %.not = icmp eq i32 %4, 1
  br i1 %.not, label %5, label %23

5:                                                ; preds = %0
  %6 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.test_gf128_from_hex.tests, i64 8), align 8, !tbaa !5
  %7 = call i32 @gf128_from_hex(ptr noundef nonnull %1, ptr noundef %6) #4
  %8 = call i32 @gf128_equ_hex(ptr noundef nonnull %1, ptr noundef %6) #4
  %.not.1 = icmp eq i32 %8, 1
  br i1 %.not.1, label %9, label %23

9:                                                ; preds = %5
  %10 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.test_gf128_from_hex.tests, i64 16), align 16, !tbaa !5
  %11 = call i32 @gf128_from_hex(ptr noundef nonnull %1, ptr noundef %10) #4
  %12 = call i32 @gf128_equ_hex(ptr noundef nonnull %1, ptr noundef %10) #4
  %.not.2 = icmp eq i32 %12, 1
  br i1 %.not.2, label %13, label %23

13:                                               ; preds = %9
  %14 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.test_gf128_from_hex.tests, i64 24), align 8, !tbaa !5
  %15 = call i32 @gf128_from_hex(ptr noundef nonnull %1, ptr noundef %14) #4
  %16 = call i32 @gf128_equ_hex(ptr noundef nonnull %1, ptr noundef %14) #4
  %.not.3 = icmp eq i32 %16, 1
  br i1 %.not.3, label %17, label %23

17:                                               ; preds = %13
  %18 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.test_gf128_from_hex.tests, i64 32), align 16, !tbaa !5
  %19 = call i32 @gf128_from_hex(ptr noundef nonnull %1, ptr noundef %18) #4
  %20 = call i32 @gf128_equ_hex(ptr noundef nonnull %1, ptr noundef %18) #4
  %.not.4 = icmp eq i32 %20, 1
  br i1 %.not.4, label %21, label %23

21:                                               ; preds = %17
  %22 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.20, ptr noundef nonnull @__FUNCTION__.test_gf128_from_hex)
  br label %26

23:                                               ; preds = %17, %13, %9, %5, %0
  %24 = load ptr, ptr @stderr, align 8, !tbaa !5
  %25 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef nonnull @.str.18, ptr noundef nonnull @.str.19, i32 noundef 112, ptr noundef nonnull @__FUNCTION__.test_gf128_from_hex) #5
  br label %26

26:                                               ; preds = %21, %23
  %.05 = phi i32 [ -1, %23 ], [ 1, %21 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #4
  ret i32 %.05
}

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 = { "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 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 #4 = { nounwind }
attributes #5 = { 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"}


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