; LLVM IR from tangjz/acm-icpc :: TDL_training/2015-11-29 (L - Turtle - tjz)

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

@t = external dso_local global i32, align 4
@x = external dso_local global i32, align 4
@y = external dso_local global i32, align 4
@o = external dso_local global i32, align 4
@xmin = external dso_local global i32, align 4
@xmax = external dso_local global i32, align 4
@ymin = external dso_local global i32, align 4
@ymax = external dso_local global i32, align 4
@str = external dso_local global [510 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@_ZL2dx = external hidden constant [4 x i32], align 16
@_ZL2dy = external hidden constant [4 x i32], align 16
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

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

4:                                                ; preds = %87, %0
  %5 = load i32, ptr @t, align 4, !tbaa !5
  %6 = add nsw i32 %5, -1
  store i32 %6, ptr @t, align 4, !tbaa !5
  %7 = icmp ne i32 %5, 0
  br i1 %7, label %8, label %96

8:                                                ; preds = %4
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @str)
  store i32 0, ptr @ymax, align 4, !tbaa !5
  store i32 0, ptr @ymin, align 4, !tbaa !5
  store i32 0, ptr @xmax, align 4, !tbaa !5
  store i32 0, ptr @xmin, align 4, !tbaa !5
  store i32 0, ptr @o, align 4, !tbaa !5
  store i32 0, ptr @y, align 4, !tbaa !5
  store i32 0, ptr @x, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %84, %8
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [510 x i8], ptr @str, i64 0, i64 %12
  %14 = load i8, ptr %13, align 1, !tbaa !9
  %15 = icmp ne i8 %14, 0
  br i1 %15, label %17, label %16

16:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  br label %87

17:                                               ; preds = %10
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [510 x i8], ptr @str, i64 0, i64 %19
  %21 = load i8, ptr %20, align 1, !tbaa !9
  %22 = sext i8 %21 to i32
  switch i32 %22, label %57 [
    i32 70, label %23
    i32 66, label %36
    i32 76, label %49
    i32 82, label %53
  ]

23:                                               ; preds = %17
  %24 = load i32, ptr @o, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [4 x i32], ptr @_ZL2dx, i64 0, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = load i32, ptr @x, align 4, !tbaa !5
  %29 = add nsw i32 %28, %27
  store i32 %29, ptr @x, align 4, !tbaa !5
  %30 = load i32, ptr @o, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [4 x i32], ptr @_ZL2dy, i64 0, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = load i32, ptr @y, align 4, !tbaa !5
  %35 = add nsw i32 %34, %33
  store i32 %35, ptr @y, align 4, !tbaa !5
  br label %57

36:                                               ; preds = %17
  %37 = load i32, ptr @o, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [4 x i32], ptr @_ZL2dx, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = load i32, ptr @x, align 4, !tbaa !5
  %42 = sub nsw i32 %41, %40
  store i32 %42, ptr @x, align 4, !tbaa !5
  %43 = load i32, ptr @o, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [4 x i32], ptr @_ZL2dy, i64 0, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = load i32, ptr @y, align 4, !tbaa !5
  %48 = sub nsw i32 %47, %46
  store i32 %48, ptr @y, align 4, !tbaa !5
  br label %57

49:                                               ; preds = %17
  %50 = load i32, ptr @o, align 4, !tbaa !5
  %51 = add nsw i32 %50, 3
  %52 = and i32 %51, 3
  store i32 %52, ptr @o, align 4, !tbaa !5
  br label %57

53:                                               ; preds = %17
  %54 = load i32, ptr @o, align 4, !tbaa !5
  %55 = add nsw i32 %54, 1
  %56 = and i32 %55, 3
  store i32 %56, ptr @o, align 4, !tbaa !5
  br label %57

57:                                               ; preds = %53, %49, %36, %23, %17
  %58 = load i32, ptr @x, align 4, !tbaa !5
  %59 = load i32, ptr @xmin, align 4, !tbaa !5
  %60 = icmp slt i32 %58, %59
  br i1 %60, label %61, label %63

61:                                               ; preds = %57
  %62 = load i32, ptr @x, align 4, !tbaa !5
  store i32 %62, ptr @xmin, align 4, !tbaa !5
  br label %70

63:                                               ; preds = %57
  %64 = load i32, ptr @xmax, align 4, !tbaa !5
  %65 = load i32, ptr @x, align 4, !tbaa !5
  %66 = icmp slt i32 %64, %65
  br i1 %66, label %67, label %69

67:                                               ; preds = %63
  %68 = load i32, ptr @x, align 4, !tbaa !5
  store i32 %68, ptr @xmax, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %67, %63
  br label %70

70:                                               ; preds = %69, %61
  %71 = load i32, ptr @y, align 4, !tbaa !5
  %72 = load i32, ptr @ymin, align 4, !tbaa !5
  %73 = icmp slt i32 %71, %72
  br i1 %73, label %74, label %76

74:                                               ; preds = %70
  %75 = load i32, ptr @y, align 4, !tbaa !5
  store i32 %75, ptr @ymin, align 4, !tbaa !5
  br label %83

76:                                               ; preds = %70
  %77 = load i32, ptr @ymax, align 4, !tbaa !5
  %78 = load i32, ptr @y, align 4, !tbaa !5
  %79 = icmp slt i32 %77, %78
  br i1 %79, label %80, label %82

80:                                               ; preds = %76
  %81 = load i32, ptr @y, align 4, !tbaa !5
  store i32 %81, ptr @ymax, align 4, !tbaa !5
  br label %82

82:                                               ; preds = %80, %76
  br label %83

83:                                               ; preds = %82, %74
  br label %84

84:                                               ; preds = %83
  %85 = load i32, ptr %2, align 4, !tbaa !5
  %86 = add nsw i32 %85, 1
  store i32 %86, ptr %2, align 4, !tbaa !5
  br label %10, !llvm.loop !10

87:                                               ; preds = %16
  %88 = load i32, ptr @xmax, align 4, !tbaa !5
  %89 = load i32, ptr @xmin, align 4, !tbaa !5
  %90 = sub nsw i32 %88, %89
  %91 = load i32, ptr @ymax, align 4, !tbaa !5
  %92 = load i32, ptr @ymin, align 4, !tbaa !5
  %93 = sub nsw i32 %91, %92
  %94 = mul nsw i32 %90, %93
  %95 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %94)
  br label %4, !llvm.loop !12

96:                                               ; preds = %4
  ret i32 0
}

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

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

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

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

attributes #0 = { 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 #1 = { "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 willreturn memory(argmem: readwrite) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}


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

@t = external dso_local global i32, align 4
@x = external dso_local local_unnamed_addr global i32, align 4
@y = external dso_local local_unnamed_addr global i32, align 4
@o = external dso_local local_unnamed_addr global i32, align 4
@xmin = external dso_local local_unnamed_addr global i32, align 4
@xmax = external dso_local local_unnamed_addr global i32, align 4
@ymin = external dso_local local_unnamed_addr global i32, align 4
@ymax = external dso_local local_unnamed_addr global i32, align 4
@str = external dso_local global [510 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@_ZL2dx = external hidden local_unnamed_addr constant [4 x i32], align 16
@_ZL2dy = external hidden local_unnamed_addr constant [4 x i32], align 16
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

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

.lr.ph12:                                         ; preds = %0, %._crit_edge
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @str)
  store i32 0, ptr @ymax, align 4, !tbaa !5
  store i32 0, ptr @ymin, align 4, !tbaa !5
  store i32 0, ptr @xmax, align 4, !tbaa !5
  store i32 0, ptr @xmin, align 4, !tbaa !5
  store i32 0, ptr @o, align 4, !tbaa !5
  store i32 0, ptr @y, align 4, !tbaa !5
  store i32 0, ptr @x, align 4, !tbaa !5
  %5 = load i8, ptr @str, align 16, !tbaa !9
  %.not78 = icmp eq i8 %5, 0
  br i1 %.not78, label %._crit_edge, label %.lr.ph

._crit_edge.loopexit:                             ; preds = %59
  %6 = sub nsw i32 %54, %55
  %7 = sub nsw i32 %60, %61
  %8 = mul nsw i32 %7, %6
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.lr.ph12
  %9 = phi i32 [ %8, %._crit_edge.loopexit ], [ 0, %.lr.ph12 ]
  %10 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %9)
  %11 = load i32, ptr @t, align 4, !tbaa !5
  %12 = add nsw i32 %11, -1
  store i32 %12, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %._crit_edge13, label %.lr.ph12, !llvm.loop !10

.lr.ph:                                           ; preds = %.lr.ph12, %59
  %indvars.iv = phi i64 [ %indvars.iv.next, %59 ], [ 0, %.lr.ph12 ]
  %13 = phi i8 [ %63, %59 ], [ %5, %.lr.ph12 ]
  %14 = phi i32 [ %49, %59 ], [ 0, %.lr.ph12 ]
  %15 = phi i32 [ %48, %59 ], [ 0, %.lr.ph12 ]
  %16 = phi i32 [ %47, %59 ], [ 0, %.lr.ph12 ]
  %17 = phi i32 [ %55, %59 ], [ 0, %.lr.ph12 ]
  %18 = phi i32 [ %54, %59 ], [ 0, %.lr.ph12 ]
  %19 = phi i32 [ %61, %59 ], [ 0, %.lr.ph12 ]
  %20 = phi i32 [ %60, %59 ], [ 0, %.lr.ph12 ]
  %21 = sext i8 %13 to i32
  %22 = add nsw i32 %21, -66
  %23 = tail call i32 @llvm.fshl.i32(i32 %22, i32 %22, i32 31)
  switch i32 %23, label %46 [
    i32 2, label %24
    i32 0, label %32
    i32 5, label %40
    i32 8, label %43
  ]

24:                                               ; preds = %.lr.ph
  %25 = zext nneg i32 %14 to i64
  %26 = getelementptr inbounds [4 x i32], ptr @_ZL2dx, i64 0, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = add nsw i32 %15, %27
  store i32 %28, ptr @x, align 4, !tbaa !5
  %29 = getelementptr inbounds [4 x i32], ptr @_ZL2dy, i64 0, i64 %25
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = add nsw i32 %16, %30
  store i32 %31, ptr @y, align 4, !tbaa !5
  br label %46

32:                                               ; preds = %.lr.ph
  %33 = zext nneg i32 %14 to i64
  %34 = getelementptr inbounds [4 x i32], ptr @_ZL2dx, i64 0, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = sub nsw i32 %15, %35
  store i32 %36, ptr @x, align 4, !tbaa !5
  %37 = getelementptr inbounds [4 x i32], ptr @_ZL2dy, i64 0, i64 %33
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = sub nsw i32 %16, %38
  store i32 %39, ptr @y, align 4, !tbaa !5
  br label %46

40:                                               ; preds = %.lr.ph
  %41 = add nuw nsw i32 %14, 3
  %42 = and i32 %41, 3
  store i32 %42, ptr @o, align 4, !tbaa !5
  br label %46

43:                                               ; preds = %.lr.ph
  %44 = add nuw nsw i32 %14, 1
  %45 = and i32 %44, 3
  store i32 %45, ptr @o, align 4, !tbaa !5
  br label %46

46:                                               ; preds = %43, %40, %32, %24, %.lr.ph
  %47 = phi i32 [ %16, %43 ], [ %16, %40 ], [ %39, %32 ], [ %31, %24 ], [ %16, %.lr.ph ]
  %48 = phi i32 [ %15, %43 ], [ %15, %40 ], [ %36, %32 ], [ %28, %24 ], [ %15, %.lr.ph ]
  %49 = phi i32 [ %45, %43 ], [ %42, %40 ], [ %14, %32 ], [ %14, %24 ], [ %14, %.lr.ph ]
  %50 = icmp slt i32 %48, %17
  br i1 %50, label %.sink.split, label %51

51:                                               ; preds = %46
  %52 = icmp slt i32 %18, %48
  br i1 %52, label %.sink.split, label %53

.sink.split:                                      ; preds = %51, %46
  %xmax.sink = phi ptr [ @xmin, %46 ], [ @xmax, %51 ]
  %.ph = phi i32 [ %18, %46 ], [ %48, %51 ]
  %.ph17 = phi i32 [ %48, %46 ], [ %17, %51 ]
  store i32 %48, ptr %xmax.sink, align 4, !tbaa !5
  br label %53

53:                                               ; preds = %.sink.split, %51
  %54 = phi i32 [ %18, %51 ], [ %.ph, %.sink.split ]
  %55 = phi i32 [ %17, %51 ], [ %.ph17, %.sink.split ]
  %56 = icmp slt i32 %47, %19
  br i1 %56, label %.sink.split18, label %57

57:                                               ; preds = %53
  %58 = icmp slt i32 %20, %47
  br i1 %58, label %.sink.split18, label %59

.sink.split18:                                    ; preds = %57, %53
  %ymin.sink = phi ptr [ @ymin, %53 ], [ @ymax, %57 ]
  %.ph19 = phi i32 [ %20, %53 ], [ %47, %57 ]
  %.ph20 = phi i32 [ %47, %53 ], [ %19, %57 ]
  store i32 %47, ptr %ymin.sink, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %.sink.split18, %57
  %60 = phi i32 [ %20, %57 ], [ %.ph19, %.sink.split18 ]
  %61 = phi i32 [ %19, %57 ], [ %.ph20, %.sink.split18 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %62 = getelementptr inbounds [510 x i8], ptr @str, i64 0, i64 %indvars.iv.next
  %63 = load i8, ptr %62, align 1, !tbaa !9
  %.not7 = icmp eq i8 %63, 0
  br i1 %.not7, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !12

._crit_edge13:                                    ; preds = %._crit_edge, %0
  ret i32 0
}

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

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

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

attributes #0 = { mustprogress nofree norecurse 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) }

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


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