; LLVM IR from tangjz/acm-icpc :: TDL_training/2016-04-17 (A - Nanoassembly - dby)

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

@x = external dso_local global [100305 x double], align 16
@y = external dso_local global [100305 x double], align 16
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_Z5crossiii(i32 noundef, i32 noundef, i32 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 uwtable
declare dso_local void @_Z3refiii(i32 noundef, i32 noundef, i32 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 i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %9

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

13:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %25

14:                                               ; preds = %9
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [100305 x double], ptr @x, i64 0, i64 %16
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [100305 x double], ptr @y, i64 0, i64 %19
  %21 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %17, ptr noundef %20)
  br label %22

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

25:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %26 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %26, ptr %3, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %77, %25
  %28 = load i32, ptr %3, align 4, !tbaa !5
  %29 = load i32, ptr @n, align 4, !tbaa !5
  %30 = load i32, ptr @m, align 4, !tbaa !5
  %31 = shl i32 %30, 1
  %32 = add nsw i32 %29, %31
  %33 = icmp slt i32 %28, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %27
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %80

35:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %36 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %36, ptr %5, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %51, %35
  %38 = load i32, ptr %5, align 4, !tbaa !5
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = add nsw i32 %39, 2
  %41 = icmp slt i32 %38, %40
  br i1 %41, label %43, label %42

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

43:                                               ; preds = %37
  %44 = load i32, ptr %5, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [100305 x double], ptr @x, i64 0, i64 %45
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [100305 x double], ptr @y, i64 0, i64 %48
  %50 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %46, ptr noundef %49)
  br label %51

51:                                               ; preds = %43
  %52 = load i32, ptr %5, align 4, !tbaa !5
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %5, align 4, !tbaa !5
  br label %37, !llvm.loop !11

54:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %55

55:                                               ; preds = %73, %54
  %56 = load i32, ptr %6, align 4, !tbaa !5
  %57 = load i32, ptr @n, align 4, !tbaa !5
  %58 = icmp slt i32 %56, %57
  br i1 %58, label %60, label %59

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

60:                                               ; preds = %55
  %61 = load i32, ptr %3, align 4, !tbaa !5
  %62 = load i32, ptr %3, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  %64 = load i32, ptr %6, align 4, !tbaa !5
  %65 = call noundef double @_Z5crossiii(i32 noundef %61, i32 noundef %63, i32 noundef %64)
  %66 = fcmp olt double %65, 0xBD719799812DEA11
  br i1 %66, label %67, label %72

67:                                               ; preds = %60
  %68 = load i32, ptr %3, align 4, !tbaa !5
  %69 = load i32, ptr %3, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  %71 = load i32, ptr %6, align 4, !tbaa !5
  call void @_Z3refiii(i32 noundef %68, i32 noundef %70, i32 noundef %71)
  br label %72

72:                                               ; preds = %67, %60
  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 %55, !llvm.loop !12

76:                                               ; preds = %59
  br label %77

77:                                               ; preds = %76
  %78 = load i32, ptr %3, align 4, !tbaa !5
  %79 = add nsw i32 %78, 2
  store i32 %79, ptr %3, align 4, !tbaa !5
  br label %27, !llvm.loop !13

80:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %81

81:                                               ; preds = %96, %80
  %82 = load i32, ptr %7, align 4, !tbaa !5
  %83 = load i32, ptr @n, align 4, !tbaa !5
  %84 = icmp slt i32 %82, %83
  br i1 %84, label %86, label %85

85:                                               ; preds = %81
  store i32 14, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %99

86:                                               ; preds = %81
  %87 = load i32, ptr %7, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [100305 x double], ptr @x, i64 0, i64 %88
  %90 = load double, ptr %89, align 8, !tbaa !14
  %91 = load i32, ptr %7, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [100305 x double], ptr @y, i64 0, i64 %92
  %94 = load double, ptr %93, align 8, !tbaa !14
  %95 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, double noundef %90, double noundef %94)
  br label %96

96:                                               ; preds = %86
  %97 = load i32, ptr %7, align 4, !tbaa !5
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %7, align 4, !tbaa !5
  br label %81, !llvm.loop !16

99:                                               ; preds = %85
  ret i32 0
}

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

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { 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 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = !{!15, !15, i64 0}
!15 = !{!"double", !7, i64 0}
!16 = distinct !{!16, !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"

@x = external dso_local global [100305 x double], align 16
@y = external dso_local global [100305 x double], align 16
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_Z5crossiii(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3refiii(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

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

.preheader32:                                     ; preds = %.lr.ph, %0
  %4 = phi i32 [ %2, %0 ], [ %12, %.lr.ph ]
  %5 = load i32, ptr @m, align 4, !tbaa !5
  %6 = shl i32 %5, 1
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.preheader31.preheader, label %.preheader

.preheader31.preheader:                           ; preds = %.preheader32
  %8 = sext i32 %4 to i64
  br label %.preheader30

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %9 = getelementptr inbounds [100305 x double], ptr @x, i64 0, i64 %indvars.iv
  %10 = getelementptr inbounds [100305 x double], ptr @y, i64 0, i64 %indvars.iv
  %11 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %9, ptr noundef nonnull %10)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %12 = load i32, ptr @n, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = icmp slt i64 %indvars.iv.next, %13
  br i1 %14, label %.lr.ph, label %.preheader32, !llvm.loop !9

.loopexit:                                        ; preds = %36, %.preheader30
  %15 = phi i32 [ %29, %.preheader30 ], [ %38, %36 ]
  %16 = load i32, ptr @m, align 4, !tbaa !5
  %17 = shl i32 %16, 1
  %18 = add nsw i32 %17, %15
  %19 = sext i32 %18 to i64
  %20 = icmp slt i64 %indvars.iv.next43, %19
  br i1 %20, label %.preheader30, label %.preheader, !llvm.loop !11

.preheader:                                       ; preds = %.loopexit, %.preheader32
  %21 = phi i32 [ %4, %.preheader32 ], [ %15, %.loopexit ]
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %.lr.ph40, label %._crit_edge

.preheader30:                                     ; preds = %.loopexit, %.preheader31.preheader
  %indvars.iv42 = phi i64 [ %8, %.preheader31.preheader ], [ %indvars.iv.next43, %.loopexit ]
  %indvars47 = trunc i64 %indvars.iv42 to i32
  %indvars.iv.next43 = add nsw i64 %indvars.iv42, 2
  %23 = getelementptr inbounds [100305 x double], ptr @x, i64 0, i64 %indvars.iv42
  %24 = getelementptr inbounds [100305 x double], ptr @y, i64 0, i64 %indvars.iv42
  %25 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %23, ptr noundef nonnull %24)
  %indvars.iv.next45 = add nsw i64 %indvars.iv42, 1
  %26 = getelementptr inbounds [100305 x double], ptr @x, i64 0, i64 %indvars.iv.next45
  %27 = getelementptr inbounds [100305 x double], ptr @y, i64 0, i64 %indvars.iv.next45
  %28 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %26, ptr noundef nonnull %27)
  %29 = load i32, ptr @n, align 4, !tbaa !5
  %30 = icmp sgt i32 %29, 0
  br i1 %30, label %.lr.ph37, label %.loopexit

.lr.ph37:                                         ; preds = %.preheader30
  %31 = add nsw i32 %indvars47, 1
  br label %32

32:                                               ; preds = %.lr.ph37, %36
  %.02436 = phi i32 [ 0, %.lr.ph37 ], [ %37, %36 ]
  %33 = tail call noundef double @_Z5crossiii(i32 noundef %indvars47, i32 noundef %31, i32 noundef %.02436)
  %34 = fcmp olt double %33, 0xBD719799812DEA11
  br i1 %34, label %35, label %36

35:                                               ; preds = %32
  tail call void @_Z3refiii(i32 noundef %indvars47, i32 noundef %31, i32 noundef %.02436)
  br label %36

36:                                               ; preds = %32, %35
  %37 = add nuw nsw i32 %.02436, 1
  %38 = load i32, ptr @n, align 4, !tbaa !5
  %39 = icmp slt i32 %37, %38
  br i1 %39, label %32, label %.loopexit, !llvm.loop !12

._crit_edge:                                      ; preds = %.lr.ph40, %.preheader
  ret i32 0

.lr.ph40:                                         ; preds = %.preheader, %.lr.ph40
  %indvars.iv48 = phi i64 [ %indvars.iv.next49, %.lr.ph40 ], [ 0, %.preheader ]
  %40 = getelementptr inbounds [100305 x double], ptr @x, i64 0, i64 %indvars.iv48
  %41 = load double, ptr %40, align 8, !tbaa !13
  %42 = getelementptr inbounds [100305 x double], ptr @y, i64 0, i64 %indvars.iv48
  %43 = load double, ptr %42, align 8, !tbaa !13
  %44 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, double noundef %41, double noundef %43)
  %indvars.iv.next49 = add nuw nsw i64 %indvars.iv48, 1
  %45 = load i32, ptr @n, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = icmp slt i64 %indvars.iv.next49, %46
  br i1 %47, label %.lr.ph40, label %._crit_edge, !llvm.loop !15
}

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

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

attributes #0 = { 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 #1 = { 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 #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" }

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


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