; LLVM IR from tangjz/acm-icpc :: codeforces/gym (101471A)

; 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.Point = type { x86_fp80, x86_fp80 }
%struct.Line = type { %struct.Point, %struct.Point }

@n = external dso_local global i32, align 4
@p = external dso_local global [201 x %struct.Point], align 16
@line = external dso_local global [201 x %struct.Line], align 16
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef x86_fp80 @_Z5solve4Line(ptr noundef byval(%struct.Line) align 16) #0

; 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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4Line4initERK5PointS2_(ptr noundef nonnull align 16 dereferenceable(64), ptr noundef nonnull align 16 dereferenceable(32), ptr noundef nonnull align 16 dereferenceable(32)) #3 align 2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #4 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %struct.Line, align 16
  %4 = alloca x86_fp80, align 16
  %5 = alloca x86_fp80, align 16
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %struct.Line, align 16
  store i32 0, ptr %1, align 4
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %11

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

15:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %37

16:                                               ; preds = %11
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [201 x %struct.Point], ptr @p, i64 0, i64 %18
  call void @_ZN5Point4readEv(ptr noundef nonnull align 16 dereferenceable(32) %19)
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %22, label %33

22:                                               ; preds = %16
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [201 x %struct.Line], ptr @line, i64 0, i64 %24
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = sub nsw i32 %26, 1
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [201 x %struct.Point], ptr @p, i64 0, i64 %28
  %30 = load i32, ptr %2, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [201 x %struct.Point], ptr @p, i64 0, i64 %31
  call void @_ZN4Line4initERK5PointS2_(ptr noundef nonnull align 16 dereferenceable(64) %25, ptr noundef nonnull align 16 dereferenceable(32) %29, ptr noundef nonnull align 16 dereferenceable(32) %32)
  br label %33

33:                                               ; preds = %22, %16
  br label %34

34:                                               ; preds = %33
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %2, align 4, !tbaa !5
  br label %11, !llvm.loop !9

37:                                               ; preds = %15
  %38 = load i32, ptr @n, align 4, !tbaa !5
  %39 = sub nsw i32 %38, 1
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [201 x %struct.Point], ptr @p, i64 0, i64 %40
  call void @_ZN4Line4initERK5PointS2_(ptr noundef nonnull align 16 dereferenceable(64) @line, ptr noundef nonnull align 16 dereferenceable(32) %41, ptr noundef nonnull align 16 dereferenceable(32) @p)
  call void @llvm.lifetime.start.p0(i64 64, ptr %3) #7
  call void @llvm.lifetime.start.p0(i64 16, ptr %4) #7
  store x86_fp80 0xK00000000000000000000, ptr %4, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %73, %37
  %43 = load i32, ptr %6, align 4, !tbaa !5
  %44 = load i32, ptr @n, align 4, !tbaa !5
  %45 = icmp slt i32 %43, %44
  br i1 %45, label %47, label %46

46:                                               ; preds = %42
  store i32 5, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  br label %76

47:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  %48 = load i32, ptr %6, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %8, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %69, %47
  %51 = load i32, ptr %8, align 4, !tbaa !5
  %52 = load i32, ptr @n, align 4, !tbaa !5
  %53 = icmp slt i32 %51, %52
  br i1 %53, label %55, label %54

54:                                               ; preds = %50
  store i32 8, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %72

55:                                               ; preds = %50
  %56 = load i32, ptr %6, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [201 x %struct.Point], ptr @p, i64 0, i64 %57
  %59 = load i32, ptr %8, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [201 x %struct.Point], ptr @p, i64 0, i64 %60
  call void @_ZN4Line4initERK5PointS2_(ptr noundef nonnull align 16 dereferenceable(64) %3, ptr noundef nonnull align 16 dereferenceable(32) %58, ptr noundef nonnull align 16 dereferenceable(32) %61)
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %9, ptr align 16 %3, i64 64, i1 false), !tbaa.struct !13
  %62 = call noundef x86_fp80 @_Z5solve4Line(ptr noundef byval(%struct.Line) align 16 %9)
  store x86_fp80 %62, ptr %5, align 16, !tbaa !11
  %63 = load x86_fp80, ptr %4, align 16, !tbaa !11
  %64 = load x86_fp80, ptr %5, align 16, !tbaa !11
  %65 = fcmp olt x86_fp80 %63, %64
  br i1 %65, label %66, label %68

66:                                               ; preds = %55
  %67 = load x86_fp80, ptr %5, align 16, !tbaa !11
  store x86_fp80 %67, ptr %4, align 16, !tbaa !11
  br label %68

68:                                               ; preds = %66, %55
  br label %69

69:                                               ; preds = %68
  %70 = load i32, ptr %8, align 4, !tbaa !5
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %8, align 4, !tbaa !5
  br label %50, !llvm.loop !14

72:                                               ; preds = %54
  br label %73

73:                                               ; preds = %72
  %74 = load i32, ptr %6, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %6, align 4, !tbaa !5
  br label %42, !llvm.loop !15

76:                                               ; preds = %46
  %77 = load x86_fp80, ptr %4, align 16, !tbaa !11
  call void @_Z7writeDBec(x86_fp80 noundef %77, i8 noundef signext 10)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 64, ptr %3) #7
  %78 = load i32, ptr %1, align 4
  ret i32 %78
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #5

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5Point4readEv(ptr noundef nonnull align 16 dereferenceable(32)) #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_Z7writeDBec(x86_fp80 noundef, i8 noundef signext) #6

attributes #0 = { mustprogress 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 = { mustprogress 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 = { mustprogress norecurse 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 = { "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 #6 = { inlinehint mustprogress 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 #7 = { 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++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"long double", !7, i64 0}
!13 = !{i64 0, i64 16, !11, i64 16, i64 16, !11, i64 32, i64 16, !11, i64 48, i64 16, !11}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}


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

%struct.Point = type { x86_fp80, x86_fp80 }
%struct.Line = type { %struct.Point, %struct.Point }

@n = external dso_local global i32, align 4
@p = external dso_local global [201 x %struct.Point], align 16
@line = external dso_local global [201 x %struct.Line], align 16
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef x86_fp80 @_Z5solve4Line(ptr noundef byval(%struct.Line) align 16) local_unnamed_addr #0

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4Line4initERK5PointS2_(ptr noundef nonnull align 16 dereferenceable(64), ptr noundef nonnull align 16 dereferenceable(32), ptr noundef nonnull align 16 dereferenceable(32)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca %struct.Line, align 16
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull @n)
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %5, label %._crit_edge

5:                                                ; preds = %0
  tail call void @_ZN5Point4readEv(ptr noundef nonnull align 16 dereferenceable(32) @p)
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  %6 = icmp sgt i32 %.pre, 1
  br i1 %6, label %.lr.ph.peel.next, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.peel.next, %5, %0
  %.lcssa = phi i32 [ %3, %0 ], [ %.pre, %5 ], [ %16, %.lr.ph.peel.next ]
  %7 = add nsw i32 %.lcssa, -1
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds [201 x %struct.Point], ptr @p, i64 0, i64 %8
  tail call void @_ZN4Line4initERK5PointS2_(ptr noundef nonnull align 16 dereferenceable(64) @line, ptr noundef nonnull align 16 dereferenceable(32) %9, ptr noundef nonnull align 16 dereferenceable(32) @p)
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %1) #6
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.lr.ph32, label %._crit_edge33

.lr.ph.peel.next:                                 ; preds = %5, %.lr.ph.peel.next
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph.peel.next ], [ 1, %5 ]
  %12 = getelementptr inbounds [201 x %struct.Point], ptr @p, i64 0, i64 %indvars.iv
  tail call void @_ZN5Point4readEv(ptr noundef nonnull align 16 dereferenceable(32) %12)
  %13 = getelementptr inbounds [201 x %struct.Line], ptr @line, i64 0, i64 %indvars.iv
  %14 = add nsw i64 %indvars.iv, -1
  %15 = getelementptr inbounds [201 x %struct.Point], ptr @p, i64 0, i64 %14
  tail call void @_ZN4Line4initERK5PointS2_(ptr noundef nonnull align 16 dereferenceable(64) %13, ptr noundef nonnull align 16 dereferenceable(32) %15, ptr noundef nonnull align 16 dereferenceable(32) %12)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %16 = load i32, ptr @n, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = icmp slt i64 %indvars.iv.next, %17
  br i1 %18, label %.lr.ph.peel.next, label %._crit_edge, !llvm.loop !9

.loopexit.loopexit:                               ; preds = %25
  %.pre46 = sext i32 %29 to i64
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %.lr.ph32
  %.pre-phi = phi i64 [ %.pre46, %.loopexit.loopexit ], [ %22, %.lr.ph32 ]
  %19 = phi i32 [ %29, %.loopexit.loopexit ], [ %21, %.lr.ph32 ]
  %.1.lcssa = phi x86_fp80 [ %.2, %.loopexit.loopexit ], [ %.02029, %.lr.ph32 ]
  %20 = icmp slt i64 %indvars.iv.next44, %.pre-phi
  %indvars.iv.next39 = add nuw nsw i64 %indvars.iv38, 1
  br i1 %20, label %.lr.ph32, label %._crit_edge33, !llvm.loop !12

._crit_edge33:                                    ; preds = %.loopexit, %._crit_edge
  %.020.lcssa = phi x86_fp80 [ 0xK00000000000000000000, %._crit_edge ], [ %.1.lcssa, %.loopexit ]
  call void @_Z7writeDBec(x86_fp80 noundef %.020.lcssa, i8 noundef signext 10)
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %1) #6
  ret i32 0

.lr.ph32:                                         ; preds = %._crit_edge, %.loopexit
  %21 = phi i32 [ %19, %.loopexit ], [ %10, %._crit_edge ]
  %indvars.iv43 = phi i64 [ %indvars.iv.next44, %.loopexit ], [ 0, %._crit_edge ]
  %indvars.iv38 = phi i64 [ %indvars.iv.next39, %.loopexit ], [ 1, %._crit_edge ]
  %.02029 = phi x86_fp80 [ %.1.lcssa, %.loopexit ], [ 0xK00000000000000000000, %._crit_edge ]
  %indvars.iv.next44 = add nuw nsw i64 %indvars.iv43, 1
  %22 = sext i32 %21 to i64
  %23 = icmp slt i64 %indvars.iv.next44, %22
  br i1 %23, label %.lr.ph27, label %.loopexit

.lr.ph27:                                         ; preds = %.lr.ph32
  %24 = getelementptr inbounds [201 x %struct.Point], ptr @p, i64 0, i64 %indvars.iv43
  br label %25

25:                                               ; preds = %.lr.ph27, %25
  %indvars.iv40 = phi i64 [ %indvars.iv38, %.lr.ph27 ], [ %indvars.iv.next41, %25 ]
  %.124 = phi x86_fp80 [ %.02029, %.lr.ph27 ], [ %.2, %25 ]
  %26 = getelementptr inbounds [201 x %struct.Point], ptr @p, i64 0, i64 %indvars.iv40
  call void @_ZN4Line4initERK5PointS2_(ptr noundef nonnull align 16 dereferenceable(64) %1, ptr noundef nonnull align 16 dereferenceable(32) %24, ptr noundef nonnull align 16 dereferenceable(32) %26)
  %27 = call noundef x86_fp80 @_Z5solve4Line(ptr noundef nonnull byval(%struct.Line) align 16 %1)
  %28 = fcmp olt x86_fp80 %.124, %27
  %.2 = select i1 %28, x86_fp80 %27, x86_fp80 %.124
  %indvars.iv.next41 = add nuw nsw i64 %indvars.iv40, 1
  %29 = load i32, ptr @n, align 4, !tbaa !5
  %30 = trunc nuw i64 %indvars.iv.next41 to i32
  %31 = icmp sgt i32 %29, %30
  br i1 %31, label %25, label %.loopexit.loopexit, !llvm.loop !13
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5Point4readEv(ptr noundef nonnull align 16 dereferenceable(32)) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_Z7writeDBec(x86_fp80 noundef, i8 noundef signext) local_unnamed_addr #5

attributes #0 = { mustprogress 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 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 = { mustprogress norecurse 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 = { 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 #5 = { inlinehint mustprogress 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 #6 = { 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++ TBAA"}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.peeled.count", i32 1}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}


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