; LLVM IR from osmart/hole2 :: src/retired_routines (surface)

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

@in_dots_total = external dso_local global i32, align 4
@max_dots = external dso_local global i32, align 4
@stderr = external global ptr, align 8
@dots = external dso_local global [30000 x [7 x double]], align 16
@in_dots = external dso_local global [30000 x [7 x double]], align 16
@.str.64 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.65 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.66 = external hidden unnamed_addr constant [27 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: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

; 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
declare dso_local i32 @vec_compare(i32 noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @cull_coords() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !5
  %5 = load ptr, ptr @stderr, align 8, !tbaa !9
  %6 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %5, ptr noundef @.str.64) #3
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %99, %0
  %8 = load i32, ptr %1, align 4, !tbaa !5
  %9 = load i32, ptr @in_dots_total, align 4, !tbaa !5
  %10 = icmp slt i32 %8, %9
  br i1 %10, label %11, label %102

11:                                               ; preds = %7
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %23, %11
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = load i32, ptr @max_dots, align 4, !tbaa !5
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %16, label %26

16:                                               ; preds = %12
  %17 = load i32, ptr %1, align 4, !tbaa !5
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = call i32 @vec_compare(i32 noundef %17, i32 noundef %18)
  %20 = icmp eq i32 %19, 1
  br i1 %20, label %21, label %22

21:                                               ; preds = %16
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %26

22:                                               ; preds = %16
  br label %23

23:                                               ; preds = %22
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %2, align 4, !tbaa !5
  br label %12, !llvm.loop !11

26:                                               ; preds = %21, %12
  %27 = load i32, ptr %3, align 4, !tbaa !5
  %28 = icmp ne i32 %27, 1
  br i1 %28, label %29, label %95

29:                                               ; preds = %26
  %30 = load i32, ptr %1, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [30000 x [7 x double]], ptr @in_dots, i64 0, i64 %31
  %33 = getelementptr inbounds [7 x double], ptr %32, i64 0, i64 0
  %34 = load double, ptr %33, align 8, !tbaa !13
  %35 = load i32, ptr @max_dots, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [30000 x [7 x double]], ptr @dots, i64 0, i64 %36
  %38 = getelementptr inbounds [7 x double], ptr %37, i64 0, i64 0
  store double %34, ptr %38, align 8, !tbaa !13
  %39 = load i32, ptr %1, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [30000 x [7 x double]], ptr @in_dots, i64 0, i64 %40
  %42 = getelementptr inbounds [7 x double], ptr %41, i64 0, i64 1
  %43 = load double, ptr %42, align 8, !tbaa !13
  %44 = load i32, ptr @max_dots, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [30000 x [7 x double]], ptr @dots, i64 0, i64 %45
  %47 = getelementptr inbounds [7 x double], ptr %46, i64 0, i64 1
  store double %43, ptr %47, align 8, !tbaa !13
  %48 = load i32, ptr %1, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [30000 x [7 x double]], ptr @in_dots, i64 0, i64 %49
  %51 = getelementptr inbounds [7 x double], ptr %50, i64 0, i64 2
  %52 = load double, ptr %51, align 8, !tbaa !13
  %53 = load i32, ptr @max_dots, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [30000 x [7 x double]], ptr @dots, i64 0, i64 %54
  %56 = getelementptr inbounds [7 x double], ptr %55, i64 0, i64 2
  store double %52, ptr %56, align 8, !tbaa !13
  %57 = load i32, ptr %1, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [30000 x [7 x double]], ptr @in_dots, i64 0, i64 %58
  %60 = getelementptr inbounds [7 x double], ptr %59, i64 0, i64 3
  %61 = load double, ptr %60, align 8, !tbaa !13
  %62 = load i32, ptr @max_dots, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [30000 x [7 x double]], ptr @dots, i64 0, i64 %63
  %65 = getelementptr inbounds [7 x double], ptr %64, i64 0, i64 3
  store double %61, ptr %65, align 8, !tbaa !13
  %66 = load i32, ptr %1, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [30000 x [7 x double]], ptr @in_dots, i64 0, i64 %67
  %69 = getelementptr inbounds [7 x double], ptr %68, i64 0, i64 4
  %70 = load double, ptr %69, align 8, !tbaa !13
  %71 = load i32, ptr @max_dots, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [30000 x [7 x double]], ptr @dots, i64 0, i64 %72
  %74 = getelementptr inbounds [7 x double], ptr %73, i64 0, i64 4
  store double %70, ptr %74, align 8, !tbaa !13
  %75 = load i32, ptr %1, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [30000 x [7 x double]], ptr @in_dots, i64 0, i64 %76
  %78 = getelementptr inbounds [7 x double], ptr %77, i64 0, i64 5
  %79 = load double, ptr %78, align 8, !tbaa !13
  %80 = load i32, ptr @max_dots, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [30000 x [7 x double]], ptr @dots, i64 0, i64 %81
  %83 = getelementptr inbounds [7 x double], ptr %82, i64 0, i64 5
  store double %79, ptr %83, align 8, !tbaa !13
  %84 = load i32, ptr %1, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [30000 x [7 x double]], ptr @in_dots, i64 0, i64 %85
  %87 = getelementptr inbounds [7 x double], ptr %86, i64 0, i64 6
  %88 = load double, ptr %87, align 8, !tbaa !13
  %89 = load i32, ptr @max_dots, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [30000 x [7 x double]], ptr @dots, i64 0, i64 %90
  %92 = getelementptr inbounds [7 x double], ptr %91, i64 0, i64 6
  store double %88, ptr %92, align 8, !tbaa !13
  %93 = load i32, ptr @max_dots, align 4, !tbaa !5
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr @max_dots, align 4, !tbaa !5
  br label %98

95:                                               ; preds = %26
  %96 = load i32, ptr %4, align 4, !tbaa !5
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %4, align 4, !tbaa !5
  br label %98

98:                                               ; preds = %95, %29
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %99

99:                                               ; preds = %98
  %100 = load i32, ptr %1, align 4, !tbaa !5
  %101 = add nsw i32 %100, 1
  store i32 %101, ptr %1, align 4, !tbaa !5
  br label %7, !llvm.loop !15

102:                                              ; preds = %7
  %103 = load ptr, ptr @stderr, align 8, !tbaa !9
  %104 = load i32, ptr %4, align 4, !tbaa !5
  %105 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %103, ptr noundef @.str.65, i32 noundef %104) #3
  %106 = load ptr, ptr @stderr, align 8, !tbaa !9
  %107 = load i32, ptr @max_dots, align 4, !tbaa !5
  %108 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %106, ptr noundef @.str.66, i32 noundef %107) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  ret void
}

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 = { 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 = !{!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 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !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"

@in_dots_total = external dso_local local_unnamed_addr global i32, align 4
@max_dots = external dso_local local_unnamed_addr global i32, align 4
@stderr = external local_unnamed_addr global ptr, align 8
@dots = external dso_local local_unnamed_addr global [30000 x [7 x double]], align 16
@in_dots = external dso_local local_unnamed_addr global [30000 x [7 x double]], align 16
@.str.64 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.65 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.66 = external hidden unnamed_addr constant [27 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 @vec_compare(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @cull_coords() local_unnamed_addr #1 {
  %1 = load ptr, ptr @stderr, align 8, !tbaa !5
  %2 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %1, ptr noundef nonnull @.str.64) #2
  %3 = load i32, ptr @in_dots_total, align 4, !tbaa !9
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.preheader, label %._crit_edge

.preheader:                                       ; preds = %0, %31
  %indvars.iv = phi i64 [ %indvars.iv.next, %31 ], [ 0, %0 ]
  %.022 = phi i32 [ %.1, %31 ], [ 0, %0 ]
  %5 = load i32, ptr @max_dots, align 4, !tbaa !9
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph.preheader, label %.critedge

.lr.ph.preheader:                                 ; preds = %.preheader
  %7 = trunc nuw nsw i64 %indvars.iv to i32
  br label %.lr.ph

8:                                                ; preds = %.lr.ph
  %9 = add nuw nsw i32 %.01820, 1
  %10 = load i32, ptr @max_dots, align 4, !tbaa !9
  %11 = icmp slt i32 %9, %10
  br i1 %11, label %.lr.ph, label %.critedge, !llvm.loop !11

.lr.ph:                                           ; preds = %.lr.ph.preheader, %8
  %.01820 = phi i32 [ %9, %8 ], [ 0, %.lr.ph.preheader ]
  %12 = tail call i32 @vec_compare(i32 noundef %7, i32 noundef %.01820)
  %13 = icmp eq i32 %12, 1
  br i1 %13, label %29, label %8

.critedge:                                        ; preds = %8, %.preheader
  %14 = phi i32 [ %5, %.preheader ], [ %10, %8 ]
  %15 = getelementptr inbounds [30000 x [7 x double]], ptr @in_dots, i64 0, i64 %indvars.iv
  %16 = sext i32 %14 to i64
  %17 = getelementptr inbounds [30000 x [7 x double]], ptr @dots, i64 0, i64 %16
  %18 = load <2 x double>, ptr %15, align 8, !tbaa !13
  store <2 x double> %18, ptr %17, align 8, !tbaa !13
  %19 = getelementptr inbounds i8, ptr %15, i64 16
  %20 = getelementptr inbounds [30000 x [7 x double]], ptr @dots, i64 0, i64 %16, i64 2
  %21 = load <2 x double>, ptr %19, align 8, !tbaa !13
  store <2 x double> %21, ptr %20, align 8, !tbaa !13
  %22 = getelementptr inbounds i8, ptr %15, i64 32
  %23 = getelementptr inbounds [30000 x [7 x double]], ptr @dots, i64 0, i64 %16, i64 4
  %24 = load <2 x double>, ptr %22, align 8, !tbaa !13
  store <2 x double> %24, ptr %23, align 8, !tbaa !13
  %25 = getelementptr inbounds i8, ptr %15, i64 48
  %26 = load double, ptr %25, align 8, !tbaa !13
  %27 = getelementptr inbounds [30000 x [7 x double]], ptr @dots, i64 0, i64 %16, i64 6
  store double %26, ptr %27, align 8, !tbaa !13
  %28 = add nsw i32 %14, 1
  store i32 %28, ptr @max_dots, align 4, !tbaa !9
  br label %31

29:                                               ; preds = %.lr.ph
  %30 = add nsw i32 %.022, 1
  br label %31

31:                                               ; preds = %29, %.critedge
  %.1 = phi i32 [ %.022, %.critedge ], [ %30, %29 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %32 = load i32, ptr @in_dots_total, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = icmp slt i64 %indvars.iv.next, %33
  br i1 %34, label %.preheader, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %31, %0
  %.0.lcssa = phi i32 [ 0, %0 ], [ %.1, %31 ]
  %35 = load ptr, ptr @stderr, align 8, !tbaa !5
  %36 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %35, ptr noundef nonnull @.str.65, i32 noundef %.0.lcssa) #2
  %37 = load ptr, ptr @stderr, align 8, !tbaa !5
  %38 = load i32, ptr @max_dots, align 4, !tbaa !9
  %39 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %37, ptr noundef nonnull @.str.66, i32 noundef %38) #2
  ret void
}

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 = !{!"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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !12}


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