; LLVM IR from tangjz/acm-icpc :: self_training/2015-02-01 (F)

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

@A = external dso_local global %struct.Point, align 8
@B = external dso_local global %struct.Point, align 8
@C = external dso_local global %struct.Point, align 8
@h = external dso_local global i32, align 4
@d = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_Z4calcd(double noundef) #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 norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca double, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  store i32 0, ptr %1, align 4
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @h, ptr noundef @d, ptr noundef @m)
  %7 = load i32, ptr @h, align 4, !tbaa !5
  %8 = load i32, ptr @d, align 4, !tbaa !5
  %9 = icmp eq i32 %7, %8
  br i1 %9, label %10, label %26

10:                                               ; preds = %0
  %11 = load i32, ptr @d, align 4, !tbaa !5
  %12 = load i32, ptr @m, align 4, !tbaa !5
  %13 = icmp eq i32 %11, %12
  br i1 %13, label %14, label %26

14:                                               ; preds = %10
  %15 = call i32 @puts(ptr noundef @.str.1)
  %16 = load i32, ptr @h, align 4, !tbaa !5
  %17 = sitofp i32 %16 to double
  %18 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, double noundef 0.000000e+00, double noundef %17)
  %19 = load i32, ptr @h, align 4, !tbaa !5
  %20 = sub nsw i32 0, %19
  %21 = sitofp i32 %20 to double
  %22 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, double noundef %21, double noundef 0.000000e+00)
  %23 = load i32, ptr @h, align 4, !tbaa !5
  %24 = sitofp i32 %23 to double
  %25 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, double noundef %24, double noundef 0.000000e+00)
  br label %82

26:                                               ; preds = %10, %0
  %27 = load i32, ptr @h, align 4, !tbaa !5
  %28 = load i32, ptr @d, align 4, !tbaa !5
  %29 = icmp slt i32 %27, %28
  br i1 %29, label %30, label %79

30:                                               ; preds = %26
  %31 = load i32, ptr @d, align 4, !tbaa !5
  %32 = load i32, ptr @m, align 4, !tbaa !5
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %34, label %79

34:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  store double 0.000000e+00, ptr %2, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  store double 1.000000e+03, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  br label %35

35:                                               ; preds = %62, %34
  %36 = load double, ptr %3, align 8, !tbaa !9
  %37 = load double, ptr %2, align 8, !tbaa !9
  %38 = fsub double %36, %37
  %39 = fcmp oge double %38, 1.000000e-08
  br i1 %39, label %40, label %63

40:                                               ; preds = %35
  %41 = load double, ptr %2, align 8, !tbaa !9
  %42 = load double, ptr %3, align 8, !tbaa !9
  %43 = fadd double %41, %42
  %44 = fdiv double %43, 2.000000e+00
  store double %44, ptr %4, align 8, !tbaa !9
  %45 = call noundef double @_Z4calcd(double noundef %44)
  store double %45, ptr %5, align 8, !tbaa !9
  %46 = load double, ptr %5, align 8, !tbaa !9
  %47 = load i32, ptr @d, align 4, !tbaa !5
  %48 = sitofp i32 %47 to double
  %49 = fsub double %46, %48
  %50 = call double @llvm.fabs.f64(double %49)
  %51 = fcmp olt double %50, 1.000000e-08
  br i1 %51, label %52, label %53

52:                                               ; preds = %40
  br label %63

53:                                               ; preds = %40
  %54 = load double, ptr %5, align 8, !tbaa !9
  %55 = load i32, ptr @d, align 4, !tbaa !5
  %56 = sitofp i32 %55 to double
  %57 = fcmp ogt double %54, %56
  br i1 %57, label %58, label %60

58:                                               ; preds = %53
  %59 = load double, ptr %4, align 8, !tbaa !9
  store double %59, ptr %2, align 8, !tbaa !9
  br label %62

60:                                               ; preds = %53
  %61 = load double, ptr %4, align 8, !tbaa !9
  store double %61, ptr %3, align 8, !tbaa !9
  br label %62

62:                                               ; preds = %60, %58
  br label %35, !llvm.loop !11

63:                                               ; preds = %52, %35
  %64 = load double, ptr %2, align 8, !tbaa !9
  %65 = load double, ptr %3, align 8, !tbaa !9
  %66 = fadd double %64, %65
  %67 = fdiv double %66, 2.000000e+00
  %68 = call noundef double @_Z4calcd(double noundef %67)
  %69 = call i32 @puts(ptr noundef @.str.1)
  %70 = load double, ptr @A, align 8, !tbaa !13
  %71 = load double, ptr getelementptr inbounds (%struct.Point, ptr @A, i32 0, i32 1), align 8, !tbaa !15
  %72 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, double noundef %70, double noundef %71)
  %73 = load double, ptr @B, align 8, !tbaa !13
  %74 = load double, ptr getelementptr inbounds (%struct.Point, ptr @B, i32 0, i32 1), align 8, !tbaa !15
  %75 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, double noundef %73, double noundef %74)
  %76 = load double, ptr @C, align 8, !tbaa !13
  %77 = load double, ptr getelementptr inbounds (%struct.Point, ptr @C, i32 0, i32 1), align 8, !tbaa !15
  %78 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, double noundef %76, double noundef %77)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  br label %81

79:                                               ; preds = %30, %26
  %80 = call i32 @puts(ptr noundef @.str.3)
  br label %81

81:                                               ; preds = %79, %63
  br label %82

82:                                               ; preds = %81, %14
  ret i32 0
}

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

declare i32 @puts(ptr noundef) #3

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #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 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 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !10, i64 0}
!14 = !{!"_ZTS5Point", !10, i64 0, !10, i64 8}
!15 = !{!14, !10, i64 8}


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

@A = external dso_local local_unnamed_addr global %struct.Point, align 8
@B = external dso_local local_unnamed_addr global %struct.Point, align 8
@C = external dso_local local_unnamed_addr global %struct.Point, align 8
@h = external dso_local global i32, align 4
@d = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_Z4calcd(double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @h, ptr noundef nonnull @d, ptr noundef nonnull @m)
  %2 = load i32, ptr @h, align 4, !tbaa !5
  %3 = load i32, ptr @d, align 4, !tbaa !5
  %4 = icmp eq i32 %2, %3
  %5 = load i32, ptr @m, align 4
  %6 = icmp eq i32 %3, %5
  %or.cond = select i1 %4, i1 %6, i1 false
  br i1 %or.cond, label %7, label %19

7:                                                ; preds = %0
  %8 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.1)
  %9 = load i32, ptr @h, align 4, !tbaa !5
  %10 = sitofp i32 %9 to double
  %11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, double noundef 0.000000e+00, double noundef %10)
  %12 = load i32, ptr @h, align 4, !tbaa !5
  %13 = sub nsw i32 0, %12
  %14 = sitofp i32 %13 to double
  %15 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, double noundef %14, double noundef 0.000000e+00)
  %16 = load i32, ptr @h, align 4, !tbaa !5
  %17 = sitofp i32 %16 to double
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, double noundef %17, double noundef 0.000000e+00)
  br label %47

19:                                               ; preds = %0
  %20 = icmp slt i32 %2, %3
  %21 = icmp slt i32 %3, %5
  %or.cond16 = select i1 %20, i1 %21, i1 false
  br i1 %or.cond16, label %.preheader, label %45

.preheader:                                       ; preds = %19, %30
  %.018 = phi double [ %..0, %30 ], [ 0.000000e+00, %19 ]
  %.01017 = phi double [ %.010., %30 ], [ 1.000000e+03, %19 ]
  %22 = fadd double %.01017, %.018
  %23 = fmul double %22, 5.000000e-01
  %24 = tail call noundef double @_Z4calcd(double noundef %23)
  %25 = load i32, ptr @d, align 4, !tbaa !5
  %26 = sitofp i32 %25 to double
  %27 = fsub double %24, %26
  %28 = tail call double @llvm.fabs.f64(double %27)
  %29 = fcmp olt double %28, 1.000000e-08
  br i1 %29, label %split, label %30

30:                                               ; preds = %.preheader
  %31 = fcmp ogt double %24, %26
  %.010. = select i1 %31, double %.01017, double %23
  %..0 = select i1 %31, double %23, double %.018
  %32 = fsub double %.010., %..0
  %33 = fcmp ult double %32, 1.000000e-08
  br i1 %33, label %._crit_edge, label %.preheader, !llvm.loop !9

._crit_edge:                                      ; preds = %30
  %.pre = fadd double %.010., %..0
  %.pre19 = fmul double %.pre, 5.000000e-01
  br label %split

split:                                            ; preds = %.preheader, %._crit_edge
  %.pre-phi20 = phi double [ %.pre19, %._crit_edge ], [ %23, %.preheader ]
  %34 = tail call noundef double @_Z4calcd(double noundef %.pre-phi20)
  %35 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.1)
  %36 = load double, ptr @A, align 8, !tbaa !11
  %37 = load double, ptr getelementptr inbounds (i8, ptr @A, i64 8), align 8, !tbaa !14
  %38 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, double noundef %36, double noundef %37)
  %39 = load double, ptr @B, align 8, !tbaa !11
  %40 = load double, ptr getelementptr inbounds (i8, ptr @B, i64 8), align 8, !tbaa !14
  %41 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, double noundef %39, double noundef %40)
  %42 = load double, ptr @C, align 8, !tbaa !11
  %43 = load double, ptr getelementptr inbounds (i8, ptr @C, i64 8), align 8, !tbaa !14
  %44 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, double noundef %42, double noundef %43)
  br label %47

45:                                               ; preds = %19
  %46 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %47

47:                                               ; preds = %split, %45, %7
  ret i32 0
}

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

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #2

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #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 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 #2 = { 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 #3 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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, !13, i64 0}
!12 = !{!"_ZTS5Point", !13, i64 0, !13, i64 8}
!13 = !{!"double", !7, i64 0}
!14 = !{!12, !13, i64 8}


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