; LLVM IR from bitcoin-core/secp256k1 :: src (precompute_ecmult_gen)

; 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"

@__const.main.outfile = external hidden unnamed_addr constant [29 x i8], align 16
@.str = external hidden unnamed_addr constant [2 x i8], align 1
@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [76 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [216 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [90 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [7 x i8], align 1
@CONFIGS = external hidden constant [3 x [2 x i32]], align 16
@.str.13 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [119 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca [29 x i8], align 16
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 29, ptr %6) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %6, ptr align 16 @__const.main.outfile, i64 29, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !5
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = load ptr, ptr %5, align 8, !tbaa !9
  %13 = getelementptr inbounds [29 x i8], ptr %6, i64 0, i64 0
  %14 = call noalias ptr @fopen(ptr noundef %13, ptr noundef @.str)
  store ptr %14, ptr %7, align 8, !tbaa !9
  %15 = load ptr, ptr %7, align 8, !tbaa !9
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %21

17:                                               ; preds = %2
  %18 = load ptr, ptr @stderr, align 8, !tbaa !9
  %19 = getelementptr inbounds [29 x i8], ptr %6, i64 0, i64 0
  %20 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef @.str.1, ptr noundef %19) #5
  store i32 1, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %91

21:                                               ; preds = %2
  %22 = load ptr, ptr %7, align 8, !tbaa !9
  %23 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef @.str.2) #5
  %24 = load ptr, ptr %7, align 8, !tbaa !9
  %25 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef @.str.3) #5
  %26 = load ptr, ptr %7, align 8, !tbaa !9
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef @.str.4) #5
  %28 = load ptr, ptr %7, align 8, !tbaa !9
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef @.str.5) #5
  %30 = load ptr, ptr %7, align 8, !tbaa !9
  %31 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef @.str.6) #5
  %32 = load ptr, ptr %7, align 8, !tbaa !9
  %33 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef @.str.7) #5
  %34 = load ptr, ptr %7, align 8, !tbaa !9
  %35 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %34, ptr noundef @.str.8) #5
  %36 = load ptr, ptr %7, align 8, !tbaa !9
  %37 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef @.str.9) #5
  %38 = load ptr, ptr %7, align 8, !tbaa !9
  %39 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %38, ptr noundef @.str.10) #5
  %40 = load ptr, ptr %7, align 8, !tbaa !9
  %41 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %40, ptr noundef @.str.11) #5
  %42 = load ptr, ptr %7, align 8, !tbaa !9
  %43 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %42, ptr noundef @.str.12) #5
  store i64 0, ptr %8, align 8, !tbaa !11
  br label %44

44:                                               ; preds = %70, %21
  %45 = load i64, ptr %8, align 8, !tbaa !11
  %46 = icmp ult i64 %45, 3
  br i1 %46, label %47, label %73

47:                                               ; preds = %44
  %48 = load ptr, ptr %7, align 8, !tbaa !9
  %49 = load i64, ptr %8, align 8, !tbaa !11
  %50 = getelementptr inbounds [3 x [2 x i32]], ptr @CONFIGS, i64 0, i64 %49
  %51 = getelementptr inbounds [2 x i32], ptr %50, i64 0, i64 0
  %52 = load i32, ptr %51, align 8, !tbaa !5
  %53 = load i64, ptr %8, align 8, !tbaa !11
  %54 = getelementptr inbounds [3 x [2 x i32]], ptr @CONFIGS, i64 0, i64 %53
  %55 = getelementptr inbounds [2 x i32], ptr %54, i64 0, i64 1
  %56 = load i32, ptr %55, align 4, !tbaa !5
  call void @print_table(ptr noundef %48, i32 noundef %52, i32 noundef %56)
  %57 = load i64, ptr %8, align 8, !tbaa !11
  %58 = getelementptr inbounds [3 x [2 x i32]], ptr @CONFIGS, i64 0, i64 %57
  %59 = getelementptr inbounds [2 x i32], ptr %58, i64 0, i64 0
  %60 = load i32, ptr %59, align 8, !tbaa !5
  %61 = icmp eq i32 %60, 11
  br i1 %61, label %62, label %69

62:                                               ; preds = %47
  %63 = load i64, ptr %8, align 8, !tbaa !11
  %64 = getelementptr inbounds [3 x [2 x i32]], ptr @CONFIGS, i64 0, i64 %63
  %65 = getelementptr inbounds [2 x i32], ptr %64, i64 0, i64 1
  %66 = load i32, ptr %65, align 4, !tbaa !5
  %67 = icmp eq i32 %66, 6
  br i1 %67, label %68, label %69

68:                                               ; preds = %62
  store i32 1, ptr %9, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %68, %62, %47
  br label %70

70:                                               ; preds = %69
  %71 = load i64, ptr %8, align 8, !tbaa !11
  %72 = add i64 %71, 1
  store i64 %72, ptr %8, align 8, !tbaa !11
  br label %44, !llvm.loop !13

73:                                               ; preds = %44
  %74 = load i32, ptr %9, align 4, !tbaa !5
  %75 = icmp ne i32 %74, 0
  br i1 %75, label %78, label %76

76:                                               ; preds = %73
  %77 = load ptr, ptr %7, align 8, !tbaa !9
  call void @print_table(ptr noundef %77, i32 noundef 11, i32 noundef 6)
  br label %78

78:                                               ; preds = %76, %73
  %79 = load ptr, ptr %7, align 8, !tbaa !9
  %80 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %79, ptr noundef @.str.13) #5
  %81 = load ptr, ptr %7, align 8, !tbaa !9
  %82 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %81, ptr noundef @.str.14) #5
  %83 = load ptr, ptr %7, align 8, !tbaa !9
  %84 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %83, ptr noundef @.str.15) #5
  %85 = load ptr, ptr %7, align 8, !tbaa !9
  %86 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %85, ptr noundef @.str.16) #5
  %87 = load ptr, ptr %7, align 8, !tbaa !9
  %88 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %87, ptr noundef @.str.17) #5
  %89 = load ptr, ptr %7, align 8, !tbaa !9
  %90 = call i32 @fclose(ptr noundef %89)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %91

91:                                               ; preds = %78, %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 29, ptr %6) #5
  %92 = load i32, ptr %3, align 4
  ret i32 %92
}

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

; 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) #2

declare noalias ptr @fopen(ptr noundef, ptr noundef) #3

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

; Function Attrs: nounwind uwtable
declare hidden void @print_table(ptr noundef, i32 noundef, i32 noundef) #0

declare i32 @fclose(ptr noundef) #3

; 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 "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 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

@__const.main.outfile = external hidden unnamed_addr constant [29 x i8], align 16
@.str = external hidden unnamed_addr constant [2 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [76 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [216 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [90 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [7 x i8], align 1
@CONFIGS = external hidden local_unnamed_addr constant [3 x [2 x i32]], align 16
@.str.13 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [119 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = alloca [29 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 29, ptr nonnull %3) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(29) %3, ptr noundef nonnull align 16 dereferenceable(29) @__const.main.outfile, i64 29, i1 false)
  %4 = call noalias ptr @fopen(ptr noundef nonnull %3, ptr noundef nonnull @.str)
  %5 = icmp eq ptr %4, null
  br i1 %5, label %6, label %9

6:                                                ; preds = %2
  %7 = load ptr, ptr @stderr, align 8, !tbaa !5
  %8 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.1, ptr noundef nonnull %3) #5
  br label %41

9:                                                ; preds = %2
  %10 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.2) #4
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.3) #4
  %12 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.4) #4
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.5) #4
  %14 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.6) #4
  %15 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.7) #4
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.8) #4
  %17 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.9) #4
  %18 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.10) #4
  %19 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.11) #4
  %20 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.12) #4
  %21 = load i32, ptr @CONFIGS, align 16, !tbaa !9
  %22 = load i32, ptr getelementptr inbounds (i8, ptr @CONFIGS, i64 4), align 4, !tbaa !9
  tail call void @print_table(ptr noundef nonnull %4, i32 noundef %21, i32 noundef %22)
  %23 = icmp ne i32 %21, 11
  %24 = icmp ne i32 %22, 6
  %.not44 = or i1 %23, %24
  %25 = load i32, ptr getelementptr inbounds (i8, ptr @CONFIGS, i64 8), align 8, !tbaa !9
  %26 = load i32, ptr getelementptr inbounds (i8, ptr @CONFIGS, i64 12), align 4, !tbaa !9
  tail call void @print_table(ptr noundef nonnull %4, i32 noundef %25, i32 noundef %26)
  %27 = icmp ne i32 %25, 11
  %28 = icmp ne i32 %26, 6
  %.not42 = or i1 %27, %28
  %narrow.not39 = and i1 %.not42, %.not44
  %29 = load i32, ptr getelementptr inbounds (i8, ptr @CONFIGS, i64 16), align 16, !tbaa !9
  %30 = load i32, ptr getelementptr inbounds (i8, ptr @CONFIGS, i64 20), align 4, !tbaa !9
  tail call void @print_table(ptr noundef nonnull %4, i32 noundef %29, i32 noundef %30)
  %31 = icmp ne i32 %29, 11
  %32 = icmp ne i32 %30, 6
  %.not37 = or i1 %31, %32
  %narrow34.not = and i1 %.not37, %narrow.not39
  br i1 %narrow34.not, label %33, label %34

33:                                               ; preds = %9
  tail call void @print_table(ptr noundef nonnull %4, i32 noundef 11, i32 noundef 6)
  br label %34

34:                                               ; preds = %33, %9
  %35 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.13) #4
  %36 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.14) #4
  %37 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.15) #4
  %38 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.16) #4
  %39 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.17) #4
  %40 = tail call i32 @fclose(ptr noundef nonnull %4)
  br label %41

41:                                               ; preds = %34, %6
  %.030 = phi i32 [ 1, %6 ], [ 0, %34 ]
  call void @llvm.lifetime.end.p0(i64 29, ptr nonnull %3) #4
  ret i32 %.030
}

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

; Function Attrs: mustprogress 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) #2

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
declare hidden void @print_table(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #3

; 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


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