; LLVM IR from clausecker/24puzzle :: statistics (write_stat_file)

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

%struct.stat_file = type { [256 x double], [256 x double], double, i32 }

@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [31 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 uwtable
define dso_local void @write_stat_file(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store double 0.000000e+00, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store i64 0, ptr %7, align 8, !tbaa !11
  store i64 0, ptr %6, align 8, !tbaa !11
  br label %8

8:                                                ; preds = %21, %2
  %9 = load i64, ptr %6, align 8, !tbaa !11
  %10 = icmp ult i64 %9, 256
  br i1 %10, label %11, label %24

11:                                               ; preds = %8
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.stat_file, ptr %12, i32 0, i32 1
  %14 = load i64, ptr %6, align 8, !tbaa !11
  %15 = getelementptr inbounds [256 x double], ptr %13, i64 0, i64 %14
  %16 = load double, ptr %15, align 8, !tbaa !9
  %17 = fcmp une double %16, 0.000000e+00
  br i1 %17, label %18, label %20

18:                                               ; preds = %11
  %19 = load i64, ptr %6, align 8, !tbaa !11
  store i64 %19, ptr %7, align 8, !tbaa !11
  br label %20

20:                                               ; preds = %18, %11
  br label %21

21:                                               ; preds = %20
  %22 = load i64, ptr %6, align 8, !tbaa !11
  %23 = add i64 %22, 1
  store i64 %23, ptr %6, align 8, !tbaa !11
  br label %8, !llvm.loop !13

24:                                               ; preds = %8
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.stat_file, ptr %25, i32 0, i32 1
  %27 = getelementptr inbounds [256 x double], ptr %26, i64 0, i64 0
  %28 = load double, ptr %27, align 8, !tbaa !9
  store double %28, ptr %5, align 8, !tbaa !9
  store i64 1, ptr %6, align 8, !tbaa !11
  br label %29

29:                                               ; preds = %43, %24
  %30 = load i64, ptr %6, align 8, !tbaa !11
  %31 = load i64, ptr %7, align 8, !tbaa !11
  %32 = icmp ule i64 %30, %31
  br i1 %32, label %33, label %46

33:                                               ; preds = %29
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.stat_file, ptr %34, i32 0, i32 1
  %36 = load i64, ptr %6, align 8, !tbaa !11
  %37 = getelementptr inbounds [256 x double], ptr %35, i64 0, i64 %36
  %38 = load double, ptr %37, align 8, !tbaa !9
  %39 = load double, ptr %5, align 8, !tbaa !9
  %40 = fcmp une double %38, %39
  br i1 %40, label %41, label %42

41:                                               ; preds = %33
  store double 0.000000e+00, ptr %5, align 8, !tbaa !9
  br label %42

42:                                               ; preds = %41, %33
  br label %43

43:                                               ; preds = %42
  %44 = load i64, ptr %6, align 8, !tbaa !11
  %45 = add i64 %44, 1
  store i64 %45, ptr %6, align 8, !tbaa !11
  br label %29, !llvm.loop !15

46:                                               ; preds = %29
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = load double, ptr %5, align 8, !tbaa !9
  %49 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %47, ptr noundef @.str.2, double noundef %48) #3
  store i64 0, ptr %6, align 8, !tbaa !11
  br label %50

50:                                               ; preds = %79, %46
  %51 = load i64, ptr %6, align 8, !tbaa !11
  %52 = load i64, ptr %7, align 8, !tbaa !11
  %53 = icmp ule i64 %51, %52
  br i1 %53, label %54, label %82

54:                                               ; preds = %50
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = load i64, ptr %6, align 8, !tbaa !11
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.stat_file, ptr %57, i32 0, i32 0
  %59 = load i64, ptr %6, align 8, !tbaa !11
  %60 = getelementptr inbounds [256 x double], ptr %58, i64 0, i64 %59
  %61 = load double, ptr %60, align 8, !tbaa !9
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.stat_file, ptr %62, i32 0, i32 1
  %64 = load i64, ptr %6, align 8, !tbaa !11
  %65 = getelementptr inbounds [256 x double], ptr %63, i64 0, i64 %64
  %66 = load double, ptr %65, align 8, !tbaa !9
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.stat_file, ptr %67, i32 0, i32 0
  %69 = load i64, ptr %6, align 8, !tbaa !11
  %70 = getelementptr inbounds [256 x double], ptr %68, i64 0, i64 %69
  %71 = load double, ptr %70, align 8, !tbaa !9
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.stat_file, ptr %72, i32 0, i32 1
  %74 = load i64, ptr %6, align 8, !tbaa !11
  %75 = getelementptr inbounds [256 x double], ptr %73, i64 0, i64 %74
  %76 = load double, ptr %75, align 8, !tbaa !9
  %77 = fdiv double %71, %76
  %78 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %55, ptr noundef @.str.3, i64 noundef %56, double noundef %61, double noundef %66, double noundef %77) #3
  br label %79

79:                                               ; preds = %54
  %80 = load i64, ptr %6, align 8, !tbaa !11
  %81 = add i64 %80, 1
  store i64 %81, ptr %6, align 8, !tbaa !11
  br label %50, !llvm.loop !16

82:                                               ; preds = %50
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


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

@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local void @write_stat_file(ptr nocapture noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 2048
  br label %4

4:                                                ; preds = %4, %2
  %.032 = phi i64 [ 0, %2 ], [ %.1.3, %4 ]
  %.02631 = phi i64 [ 0, %2 ], [ %20, %4 ]
  %5 = getelementptr inbounds [256 x double], ptr %3, i64 0, i64 %.02631
  %6 = load double, ptr %5, align 8, !tbaa !5
  %7 = fcmp une double %6, 0.000000e+00
  %.1 = select i1 %7, i64 %.02631, i64 %.032
  %8 = or disjoint i64 %.02631, 1
  %9 = getelementptr inbounds [256 x double], ptr %3, i64 0, i64 %8
  %10 = load double, ptr %9, align 8, !tbaa !5
  %11 = fcmp une double %10, 0.000000e+00
  %.1.1 = select i1 %11, i64 %8, i64 %.1
  %12 = or disjoint i64 %.02631, 2
  %13 = getelementptr inbounds [256 x double], ptr %3, i64 0, i64 %12
  %14 = load double, ptr %13, align 8, !tbaa !5
  %15 = fcmp une double %14, 0.000000e+00
  %.1.2 = select i1 %15, i64 %12, i64 %.1.1
  %16 = or disjoint i64 %.02631, 3
  %17 = getelementptr inbounds [256 x double], ptr %3, i64 0, i64 %16
  %18 = load double, ptr %17, align 8, !tbaa !5
  %19 = fcmp une double %18, 0.000000e+00
  %.1.3 = select i1 %19, i64 %16, i64 %.1.2
  %20 = add nuw nsw i64 %.02631, 4
  %exitcond.not.3 = icmp eq i64 %20, 256
  br i1 %exitcond.not.3, label %21, label %4, !llvm.loop !9

21:                                               ; preds = %4
  %22 = load double, ptr %3, align 8, !tbaa !5
  %.not33 = icmp eq i64 %.1.3, 0
  br i1 %.not33, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %21
  %23 = add i64 %.1.3, 1
  %umax = tail call i64 @llvm.umax.i64(i64 %23, i64 2)
  %24 = add i64 %umax, -1
  %25 = add i64 %umax, -2
  %xtraiter = and i64 %24, 3
  %26 = icmp ult i64 %25, 3
  br i1 %26, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %24, -4
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %.12735 = phi i64 [ 1, %.lr.ph.preheader.new ], [ %42, %.lr.ph ]
  %.02834 = phi double [ %22, %.lr.ph.preheader.new ], [ %.129.3, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %27 = getelementptr inbounds [256 x double], ptr %3, i64 0, i64 %.12735
  %28 = load double, ptr %27, align 8, !tbaa !5
  %29 = fcmp une double %28, %.02834
  %.129 = select i1 %29, double 0.000000e+00, double %.02834
  %30 = add nuw nsw i64 %.12735, 1
  %31 = getelementptr inbounds [256 x double], ptr %3, i64 0, i64 %30
  %32 = load double, ptr %31, align 8, !tbaa !5
  %33 = fcmp une double %32, %.129
  %.129.1 = select i1 %33, double 0.000000e+00, double %.129
  %34 = add nuw nsw i64 %.12735, 2
  %35 = getelementptr inbounds [256 x double], ptr %3, i64 0, i64 %34
  %36 = load double, ptr %35, align 8, !tbaa !5
  %37 = fcmp une double %36, %.129.1
  %.129.2 = select i1 %37, double 0.000000e+00, double %.129.1
  %38 = add nuw i64 %.12735, 3
  %39 = getelementptr inbounds [256 x double], ptr %3, i64 0, i64 %38
  %40 = load double, ptr %39, align 8, !tbaa !5
  %41 = fcmp une double %40, %.129.2
  %.129.3 = select i1 %41, double 0.000000e+00, double %.129.2
  %42 = add nuw i64 %.12735, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !11

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %.129.lcssa.ph = phi double [ poison, %.lr.ph.preheader ], [ %.129.3, %.lr.ph ]
  %.12735.unr = phi i64 [ 1, %.lr.ph.preheader ], [ %42, %.lr.ph ]
  %.02834.unr = phi double [ %22, %.lr.ph.preheader ], [ %.129.3, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil
  %.12735.epil = phi i64 [ %46, %.lr.ph.epil ], [ %.12735.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.02834.epil = phi double [ %.129.epil, %.lr.ph.epil ], [ %.02834.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %43 = getelementptr inbounds [256 x double], ptr %3, i64 0, i64 %.12735.epil
  %44 = load double, ptr %43, align 8, !tbaa !5
  %45 = fcmp une double %44, %.02834.epil
  %.129.epil = select i1 %45, double 0.000000e+00, double %.02834.epil
  %46 = add nuw i64 %.12735.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph.epil, !llvm.loop !12

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil, %21
  %.028.lcssa = phi double [ %22, %21 ], [ %.129.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %.129.epil, %.lr.ph.epil ]
  %47 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.2, double noundef %.028.lcssa) #3
  br label %48

48:                                               ; preds = %._crit_edge, %48
  %.236 = phi i64 [ 0, %._crit_edge ], [ %55, %48 ]
  %49 = getelementptr inbounds [256 x double], ptr %1, i64 0, i64 %.236
  %50 = load double, ptr %49, align 8, !tbaa !5
  %51 = getelementptr inbounds [256 x double], ptr %3, i64 0, i64 %.236
  %52 = load double, ptr %51, align 8, !tbaa !5
  %53 = fdiv double %50, %52
  %54 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.3, i64 noundef %.236, double noundef %50, double noundef %52, double noundef %53) #3
  %55 = add i64 %.236, 1
  %.not30 = icmp ugt i64 %55, %.1.3
  br i1 %.not30, label %56, label %48, !llvm.loop !14

56:                                               ; preds = %48
  ret void
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #2

attributes #0 = { 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 #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.unroll.disable"}
!14 = distinct !{!14, !10}


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