; LLVM IR from tangjz/acm-icpc :: self_training/2015-01-31 (H)

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

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@ans = external dso_local global double, align 8
@a = external dso_local global [10 x %struct.Point], align 16
@b = external dso_local global %struct.Point, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_Z3dis5Point4Line(double, double, ptr noundef byval(%struct.Line) align 8) #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 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 noundef double @_Z3mindd(double noundef, double noundef) #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca %struct.Point, align 8
  %5 = alloca %struct.Line, align 8
  %6 = alloca %struct.Point, align 8
  %7 = alloca %struct.Line, align 8
  store i32 0, ptr %1, align 4
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %9

9:                                                ; preds = %78, %0
  %10 = load i32, ptr @t, align 4, !tbaa !5
  %11 = add nsw i32 %10, -1
  store i32 %11, ptr @t, align 4, !tbaa !5
  %12 = icmp ne i32 %10, 0
  br i1 %12, label %13, label %81

13:                                               ; preds = %9
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %30, %13
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = load i32, ptr @n, align 4, !tbaa !5
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %20, label %19

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

20:                                               ; preds = %15
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [10 x %struct.Point], ptr @a, i64 0, i64 %22
  %24 = getelementptr inbounds %struct.Point, ptr %23, i32 0, i32 0
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [10 x %struct.Point], ptr @a, i64 0, i64 %26
  %28 = getelementptr inbounds %struct.Point, ptr %27, i32 0, i32 1
  %29 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %24, ptr noundef %28)
  br label %30

30:                                               ; preds = %20
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %2, align 4, !tbaa !5
  br label %15, !llvm.loop !9

33:                                               ; preds = %19
  %34 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @b, ptr noundef getelementptr inbounds (%struct.Point, ptr @b, i32 0, i32 1))
  store double 0x4C63E9E4E4C2F344, ptr @ans, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %57, %33
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = load i32, ptr @n, align 4, !tbaa !5
  %38 = icmp slt i32 %36, %37
  br i1 %38, label %40, label %39

39:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %60

40:                                               ; preds = %35
  %41 = load double, ptr @ans, align 8, !tbaa !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %4, ptr align 8 @b, i64 16, i1 false), !tbaa.struct !13
  %42 = getelementptr inbounds %struct.Line, ptr %5, i32 0, i32 0
  %43 = load i32, ptr %3, align 4, !tbaa !5
  %44 = sub nsw i32 %43, 1
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [10 x %struct.Point], ptr @a, i64 0, i64 %45
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %42, ptr align 16 %46, i64 16, i1 false), !tbaa.struct !13
  %47 = getelementptr inbounds %struct.Line, ptr %5, i32 0, i32 1
  %48 = load i32, ptr %3, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [10 x %struct.Point], ptr @a, i64 0, i64 %49
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %47, ptr align 16 %50, i64 16, i1 false), !tbaa.struct !13
  %51 = getelementptr inbounds { double, double }, ptr %4, i32 0, i32 0
  %52 = load double, ptr %51, align 8
  %53 = getelementptr inbounds { double, double }, ptr %4, i32 0, i32 1
  %54 = load double, ptr %53, align 8
  %55 = call noundef double @_Z3dis5Point4Line(double %52, double %54, ptr noundef byval(%struct.Line) align 8 %5)
  %56 = call noundef double @_Z3mindd(double noundef %41, double noundef %55)
  store double %56, ptr @ans, align 8, !tbaa !11
  br label %57

57:                                               ; preds = %40
  %58 = load i32, ptr %3, align 4, !tbaa !5
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %3, align 4, !tbaa !5
  br label %35, !llvm.loop !14

60:                                               ; preds = %39
  %61 = load i32, ptr @n, align 4, !tbaa !5
  %62 = icmp sgt i32 %61, 1
  br i1 %62, label %63, label %77

63:                                               ; preds = %60
  %64 = load double, ptr @ans, align 8, !tbaa !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 @b, i64 16, i1 false), !tbaa.struct !13
  %65 = getelementptr inbounds %struct.Line, ptr %7, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %65, ptr align 16 @a, i64 16, i1 false), !tbaa.struct !13
  %66 = getelementptr inbounds %struct.Line, ptr %7, i32 0, i32 1
  %67 = load i32, ptr @n, align 4, !tbaa !5
  %68 = sub nsw i32 %67, 1
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [10 x %struct.Point], ptr @a, i64 0, i64 %69
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %66, ptr align 16 %70, i64 16, i1 false), !tbaa.struct !13
  %71 = getelementptr inbounds { double, double }, ptr %6, i32 0, i32 0
  %72 = load double, ptr %71, align 8
  %73 = getelementptr inbounds { double, double }, ptr %6, i32 0, i32 1
  %74 = load double, ptr %73, align 8
  %75 = call noundef double @_Z3dis5Point4Line(double %72, double %74, ptr noundef byval(%struct.Line) align 8 %7)
  %76 = call noundef double @_Z3mindd(double noundef %64, double noundef %75)
  store double %76, ptr @ans, align 8, !tbaa !11
  br label %78

77:                                               ; preds = %60
  store double 0.000000e+00, ptr @ans, align 8, !tbaa !11
  br label %78

78:                                               ; preds = %77, %63
  %79 = load double, ptr @ans, align 8, !tbaa !11
  %80 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, double noundef %79)
  br label %9, !llvm.loop !15

81:                                               ; preds = %9
  ret i32 0
}

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

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

declare i32 @printf(ptr noundef, ...) #4

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 = { 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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{i64 0, i64 8, !11, i64 8, i64 8, !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 { double, double }
%struct.Line = type { %struct.Point, %struct.Point }

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@ans = external dso_local local_unnamed_addr global double, align 8
@a = external dso_local global [10 x %struct.Point], align 16
@b = external dso_local global %struct.Point, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_Z3dis5Point4Line(double, double, ptr noundef byval(%struct.Line) align 8) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_Z3mindd(double noundef, double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca %struct.Line, align 8
  %2 = alloca %struct.Line, align 8
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %4 = load i32, ptr @t, align 4, !tbaa !5
  %5 = add nsw i32 %4, -1
  store i32 %5, ptr @t, align 4, !tbaa !5
  %.not17 = icmp eq i32 %4, 0
  br i1 %.not17, label %._crit_edge20, label %.lr.ph19

.lr.ph19:                                         ; preds = %0
  %6 = getelementptr inbounds i8, ptr %1, i64 16
  %7 = getelementptr inbounds i8, ptr %2, i64 16
  br label %8

8:                                                ; preds = %.lr.ph19, %._crit_edge16.thread
  %9 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %8
  %12 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @b, ptr noundef nonnull getelementptr inbounds (i8, ptr @b, i64 8))
  store double 0x4C63E9E4E4C2F344, ptr @ans, align 8, !tbaa !9
  %13 = load i32, ptr @n, align 4, !tbaa !5
  %14 = icmp sgt i32 %13, 1
  br i1 %14, label %.lr.ph15, label %._crit_edge16.thread

.lr.ph:                                           ; preds = %8, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %8 ]
  %15 = getelementptr inbounds [10 x %struct.Point], ptr @a, i64 0, i64 %indvars.iv
  %16 = getelementptr inbounds i8, ptr %15, i64 8
  %17 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %15, ptr noundef nonnull %16)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %18 = load i32, ptr @n, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = icmp slt i64 %indvars.iv.next, %19
  br i1 %20, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge16:                                    ; preds = %.lr.ph15
  %21 = icmp sgt i32 %28, 1
  br i1 %21, label %31, label %._crit_edge16.thread

.lr.ph15:                                         ; preds = %._crit_edge, %.lr.ph15
  %22 = phi double [ %27, %.lr.ph15 ], [ 0x4C63E9E4E4C2F344, %._crit_edge ]
  %indvars.iv23 = phi i64 [ %indvars.iv.next24, %.lr.ph15 ], [ 1, %._crit_edge ]
  %.sroa.01.0.copyload = load double, ptr @b, align 8, !tbaa !9
  %.sroa.22.0.copyload = load double, ptr getelementptr inbounds (i8, ptr @b, i64 8), align 8, !tbaa !9
  %23 = add nsw i64 %indvars.iv23, -1
  %24 = getelementptr inbounds [10 x %struct.Point], ptr @a, i64 0, i64 %23
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 16 dereferenceable(16) %24, i64 16, i1 false), !tbaa.struct !13
  %25 = getelementptr inbounds [10 x %struct.Point], ptr @a, i64 0, i64 %indvars.iv23
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef nonnull align 16 dereferenceable(16) %25, i64 16, i1 false), !tbaa.struct !13
  %26 = tail call noundef double @_Z3dis5Point4Line(double %.sroa.01.0.copyload, double %.sroa.22.0.copyload, ptr noundef nonnull byval(%struct.Line) align 8 %1)
  %27 = tail call noundef double @_Z3mindd(double noundef %22, double noundef %26)
  store double %27, ptr @ans, align 8, !tbaa !9
  %indvars.iv.next24 = add nuw nsw i64 %indvars.iv23, 1
  %28 = load i32, ptr @n, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = icmp slt i64 %indvars.iv.next24, %29
  br i1 %30, label %.lr.ph15, label %._crit_edge16, !llvm.loop !14

31:                                               ; preds = %._crit_edge16
  %.sroa.0.0.copyload = load double, ptr @b, align 8, !tbaa !9
  %.sroa.2.0.copyload = load double, ptr getelementptr inbounds (i8, ptr @b, i64 8), align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 16 dereferenceable(16) @a, i64 16, i1 false), !tbaa.struct !13
  %32 = add nsw i32 %28, -1
  %33 = zext nneg i32 %32 to i64
  %34 = getelementptr inbounds [10 x %struct.Point], ptr @a, i64 0, i64 %33
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %7, ptr noundef nonnull align 16 dereferenceable(16) %34, i64 16, i1 false), !tbaa.struct !13
  %35 = tail call noundef double @_Z3dis5Point4Line(double %.sroa.0.0.copyload, double %.sroa.2.0.copyload, ptr noundef nonnull byval(%struct.Line) align 8 %2)
  %36 = tail call noundef double @_Z3mindd(double noundef %27, double noundef %35)
  br label %._crit_edge16.thread

._crit_edge16.thread:                             ; preds = %._crit_edge, %._crit_edge16, %31
  %storemerge = phi double [ %36, %31 ], [ 0.000000e+00, %._crit_edge16 ], [ 0.000000e+00, %._crit_edge ]
  store double %storemerge, ptr @ans, align 8, !tbaa !9
  %37 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, double noundef %storemerge)
  %38 = load i32, ptr @t, align 4, !tbaa !5
  %39 = add nsw i32 %38, -1
  store i32 %39, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %38, 0
  br i1 %.not, label %._crit_edge20, label %8, !llvm.loop !15

._crit_edge20:                                    ; preds = %._crit_edge16.thread, %0
  ret i32 0
}

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

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

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

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 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 = { 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }

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


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