; LLVM IR from alexzheng42/sDMD :: src (ToolFunctions)

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

@datadir = external global [1024 x i8], align 16
@.str.20 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.33 = 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #1

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

declare i32 @fclose(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @CreateGELCoordinate(i32 noundef %0) #3 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca [50 x i8], align 16
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 1, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 50, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %10 = getelementptr inbounds [50 x i8], ptr %4, i64 0, i64 0
  %11 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %10, ptr noundef @.str.28, ptr noundef @datadir) #4
  %12 = getelementptr inbounds [50 x i8], ptr %4, i64 0, i64 0
  %13 = call noalias ptr @fopen(ptr noundef %12, ptr noundef @.str.20)
  store ptr %13, ptr %5, align 8, !tbaa !9
  %14 = load ptr, ptr %5, align 8, !tbaa !9
  %15 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef @.str.29) #4
  %16 = load ptr, ptr %5, align 8, !tbaa !9
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = mul nsw i32 %17, %18
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = mul nsw i32 %19, %20
  %22 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef @.str.30, i32 noundef %21) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %67, %1
  %24 = load i32, ptr %6, align 4, !tbaa !5
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = icmp slt i32 %24, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %23
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %70

28:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %63, %28
  %30 = load i32, ptr %8, align 4, !tbaa !5
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = icmp slt i32 %30, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %29
  store i32 5, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %66

34:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %59, %34
  %36 = load i32, ptr %9, align 4, !tbaa !5
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = icmp slt i32 %36, %37
  br i1 %38, label %40, label %39

39:                                               ; preds = %35
  store i32 8, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %62

40:                                               ; preds = %35
  %41 = load ptr, ptr %5, align 8, !tbaa !9
  %42 = load i32, ptr %3, align 4, !tbaa !5
  %43 = load i32, ptr %3, align 4, !tbaa !5
  %44 = load i32, ptr %9, align 4, !tbaa !5
  %45 = sitofp i32 %44 to double
  %46 = fadd double %45, 5.000000e-01
  %47 = fmul double %46, 8.000000e-01
  %48 = load i32, ptr %8, align 4, !tbaa !5
  %49 = sitofp i32 %48 to double
  %50 = fadd double %49, 5.000000e-01
  %51 = fmul double %50, 8.000000e-01
  %52 = load i32, ptr %6, align 4, !tbaa !5
  %53 = sitofp i32 %52 to double
  %54 = fadd double %53, 5.000000e-01
  %55 = fmul double %54, 8.000000e-01
  %56 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %41, ptr noundef @.str.31, i32 noundef %42, ptr noundef @.str.32, i32 noundef %43, double noundef %47, double noundef %51, double noundef %55) #4
  %57 = load i32, ptr %3, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %3, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %40
  %60 = load i32, ptr %9, align 4, !tbaa !5
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %9, align 4, !tbaa !5
  br label %35, !llvm.loop !11

62:                                               ; preds = %39
  br label %63

63:                                               ; preds = %62
  %64 = load i32, ptr %8, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %8, align 4, !tbaa !5
  br label %29, !llvm.loop !13

66:                                               ; preds = %33
  br label %67

67:                                               ; preds = %66
  %68 = load i32, ptr %6, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %6, align 4, !tbaa !5
  br label %23, !llvm.loop !14

70:                                               ; preds = %27
  %71 = load ptr, ptr %5, align 8, !tbaa !9
  %72 = load i32, ptr %2, align 4, !tbaa !5
  %73 = sitofp i32 %72 to double
  %74 = fmul double %73, 8.000000e-01
  %75 = load i32, ptr %2, align 4, !tbaa !5
  %76 = sitofp i32 %75 to double
  %77 = fmul double %76, 8.000000e-01
  %78 = load i32, ptr %2, align 4, !tbaa !5
  %79 = sitofp i32 %78 to double
  %80 = fmul double %79, 8.000000e-01
  %81 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %71, ptr noundef @.str.33, double noundef %74, double noundef %77, double noundef %80) #4
  %82 = load ptr, ptr %5, align 8, !tbaa !9
  %83 = call i32 @fclose(ptr noundef %82)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 50, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret void
}

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

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 = { "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 }

!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"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


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

@datadir = external global [1024 x i8], align 16
@.str.20 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.33 = 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

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

; Function Attrs: nofree nounwind uwtable
define dso_local void @CreateGELCoordinate(i32 noundef %0) local_unnamed_addr #2 {
  %2 = alloca [50 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 50, ptr nonnull %2) #3
  %3 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) @.str.28, ptr noundef nonnull @datadir) #3
  %4 = call noalias ptr @fopen(ptr noundef nonnull %2, ptr noundef nonnull @.str.20)
  %5 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %4, ptr noundef nonnull @.str.29) #3
  %6 = mul nsw i32 %0, %0
  %7 = mul nsw i32 %6, %0
  %8 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %4, ptr noundef nonnull @.str.30, i32 noundef %7) #3
  %9 = icmp sgt i32 %0, 0
  br i1 %9, label %.preheader30.us, label %._crit_edge

.preheader30.us:                                  ; preds = %1, %._crit_edge35.split.us.us
  %.02638.us = phi i32 [ %24, %._crit_edge35.split.us.us ], [ 0, %1 ]
  %.02737.us = phi i32 [ %21, %._crit_edge35.split.us.us ], [ 1, %1 ]
  %10 = uitofp nneg i32 %.02638.us to double
  %11 = fadd double %10, 5.000000e-01
  %12 = fmul double %11, 8.000000e-01
  br label %.preheader.us.us

.preheader.us.us:                                 ; preds = %._crit_edge.us.us, %.preheader30.us
  %.02534.us.us = phi i32 [ 0, %.preheader30.us ], [ %23, %._crit_edge.us.us ]
  %.133.us.us = phi i32 [ %.02737.us, %.preheader30.us ], [ %21, %._crit_edge.us.us ]
  %13 = uitofp nneg i32 %.02534.us.us to double
  %14 = fadd double %13, 5.000000e-01
  %15 = fmul double %14, 8.000000e-01
  br label %16

16:                                               ; preds = %16, %.preheader.us.us
  %.032.us.us = phi i32 [ 0, %.preheader.us.us ], [ %22, %16 ]
  %.231.us.us = phi i32 [ %.133.us.us, %.preheader.us.us ], [ %21, %16 ]
  %17 = uitofp nneg i32 %.032.us.us to double
  %18 = fadd double %17, 5.000000e-01
  %19 = fmul double %18, 8.000000e-01
  %20 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %4, ptr noundef nonnull @.str.31, i32 noundef %.231.us.us, ptr noundef nonnull @.str.32, i32 noundef %.231.us.us, double noundef %19, double noundef %15, double noundef %12) #3
  %21 = add nsw i32 %.231.us.us, 1
  %22 = add nuw nsw i32 %.032.us.us, 1
  %exitcond.not = icmp eq i32 %22, %0
  br i1 %exitcond.not, label %._crit_edge.us.us, label %16, !llvm.loop !5

._crit_edge.us.us:                                ; preds = %16
  %23 = add nuw nsw i32 %.02534.us.us, 1
  %exitcond39.not = icmp eq i32 %23, %0
  br i1 %exitcond39.not, label %._crit_edge35.split.us.us, label %.preheader.us.us, !llvm.loop !7

._crit_edge35.split.us.us:                        ; preds = %._crit_edge.us.us
  %24 = add nuw nsw i32 %.02638.us, 1
  %exitcond40.not = icmp eq i32 %24, %0
  br i1 %exitcond40.not, label %._crit_edge, label %.preheader30.us, !llvm.loop !8

._crit_edge:                                      ; preds = %._crit_edge35.split.us.us, %1
  %25 = sitofp i32 %0 to double
  %26 = fmul double %25, 8.000000e-01
  %27 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %4, ptr noundef nonnull @.str.33, double noundef %26, double noundef %26, double noundef %26) #3
  %28 = tail call i32 @fclose(ptr noundef %4)
  call void @llvm.lifetime.end.p0(i64 50, ptr nonnull %2) #3
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #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 = { nofree 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}
!8 = distinct !{!8, !6}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass