; LLVM IR from kazunetakahashi/atcoder :: 2018/0901_ARC102 (D)

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

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@L = external dso_local global i64, align 8
@N = external dso_local global i32, align 4
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str.2 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [80 x i8], align 1
@__PRETTY_FUNCTION__.main = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5flushv() #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 @_Z8add_edgeiii(i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %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 noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @L)
  store i32 0, ptr @N, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  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 = icmp slt i32 %10, 200
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  store i32 2, ptr %3, align 4
  br label %25

13:                                               ; preds = %9
  %14 = load i64, ptr @L, align 8, !tbaa !9
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = zext i32 %15 to i64
  %17 = ashr i64 %14, %16
  %18 = icmp eq i64 %17, 0
  br i1 %18, label %19, label %21

19:                                               ; preds = %13
  %20 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %20, ptr @N, align 4, !tbaa !5
  store i32 2, ptr %3, align 4
  br label %25

21:                                               ; preds = %13
  br label %22

22:                                               ; preds = %21
  %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 !11

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

26:                                               ; preds = %25
  %27 = load i32, ptr @N, align 4, !tbaa !5
  %28 = icmp slt i32 0, %27
  br i1 %28, label %29, label %32

29:                                               ; preds = %26
  %30 = load i32, ptr @N, align 4, !tbaa !5
  %31 = icmp sle i32 %30, 20
  br label %32

32:                                               ; preds = %29, %26
  %33 = phi i1 [ false, %26 ], [ %31, %29 ]
  br i1 %33, label %34, label %35

34:                                               ; preds = %32
  br label %37

35:                                               ; preds = %32
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.3, i32 noundef 81, ptr noundef @__PRETTY_FUNCTION__.main) #5
  unreachable

36:                                               ; No predecessors!
  br label %37

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

38:                                               ; preds = %54, %37
  %39 = load i32, ptr %5, align 4, !tbaa !5
  %40 = load i32, ptr @N, align 4, !tbaa !5
  %41 = sub nsw i32 %40, 1
  %42 = icmp slt i32 %39, %41
  br i1 %42, label %44, label %43

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

44:                                               ; preds = %38
  %45 = load i32, ptr %5, align 4, !tbaa !5
  %46 = load i32, ptr %5, align 4, !tbaa !5
  %47 = add nsw i32 %46, 1
  call void @_Z8add_edgeiii(i32 noundef %45, i32 noundef %47, i32 noundef 0)
  %48 = load i32, ptr %5, align 4, !tbaa !5
  %49 = load i32, ptr %5, align 4, !tbaa !5
  %50 = add nsw i32 %49, 1
  %51 = load i32, ptr %4, align 4, !tbaa !5
  call void @_Z8add_edgeiii(i32 noundef %48, i32 noundef %50, i32 noundef %51)
  %52 = load i32, ptr %4, align 4, !tbaa !5
  %53 = mul nsw i32 %52, 2
  store i32 %53, ptr %4, align 4, !tbaa !5
  br label %54

54:                                               ; preds = %44
  %55 = load i32, ptr %5, align 4, !tbaa !5
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %5, align 4, !tbaa !5
  br label %38, !llvm.loop !13

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

58:                                               ; preds = %87, %57
  %59 = load i32, ptr %6, align 4, !tbaa !5
  %60 = load i32, ptr @N, align 4, !tbaa !5
  %61 = sub nsw i32 %60, 1
  %62 = icmp slt i32 %59, %61
  br i1 %62, label %64, label %63

63:                                               ; preds = %58
  store i32 8, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %90

64:                                               ; preds = %58
  %65 = load i64, ptr @L, align 8, !tbaa !9
  %66 = load i32, ptr %6, align 4, !tbaa !5
  %67 = zext i32 %66 to i64
  %68 = ashr i64 %65, %67
  %69 = and i64 %68, 1
  %70 = icmp ne i64 %69, 0
  br i1 %70, label %71, label %86

71:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %72 = load i64, ptr @L, align 8, !tbaa !9
  %73 = load i32, ptr @N, align 4, !tbaa !5
  %74 = shl i32 1, %73
  %75 = sub nsw i32 %74, 1
  %76 = load i32, ptr %6, align 4, !tbaa !5
  %77 = add nsw i32 %76, 1
  %78 = shl i32 %75, %77
  %79 = sext i32 %78 to i64
  %80 = and i64 %72, %79
  %81 = trunc i64 %80 to i32
  store i32 %81, ptr %7, align 4, !tbaa !5
  %82 = load i32, ptr %6, align 4, !tbaa !5
  %83 = load i32, ptr @N, align 4, !tbaa !5
  %84 = sub nsw i32 %83, 1
  %85 = load i32, ptr %7, align 4, !tbaa !5
  call void @_Z8add_edgeiii(i32 noundef %82, i32 noundef %84, i32 noundef %85)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %86

86:                                               ; preds = %71, %64
  br label %87

87:                                               ; preds = %86
  %88 = load i32, ptr %6, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %6, align 4, !tbaa !5
  br label %58, !llvm.loop !14

90:                                               ; preds = %63
  call void @_Z5flushv()
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %91 = load i32, ptr %1, align 4
  ret i32 %91
}

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #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 = { 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 = { noreturn 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 = { nounwind }
attributes #5 = { noreturn 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 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


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

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@L = external dso_local global i64, align 8
@N = external dso_local local_unnamed_addr global i32, align 4
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str.2 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [80 x i8], align 1
@__PRETTY_FUNCTION__.main = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5flushv() local_unnamed_addr #0

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @L)
  store i32 0, ptr @N, align 4, !tbaa !5
  %2 = load i64, ptr @L, align 8, !tbaa !9
  br label %3

3:                                                ; preds = %18, %0
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next.4, %18 ]
  %4 = ashr i64 %2, %indvars.iv
  %5 = icmp eq i64 %4, 0
  br i1 %5, label %.loopexit, label %6

6:                                                ; preds = %3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %7 = ashr i64 %2, %indvars.iv.next
  %8 = icmp eq i64 %7, 0
  br i1 %8, label %.loopexit, label %9

9:                                                ; preds = %6
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %10 = ashr i64 %2, %indvars.iv.next.1
  %11 = icmp eq i64 %10, 0
  br i1 %11, label %.loopexit, label %12

12:                                               ; preds = %9
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
  %13 = ashr i64 %2, %indvars.iv.next.2
  %14 = icmp eq i64 %13, 0
  br i1 %14, label %.loopexit, label %15

15:                                               ; preds = %12
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %16 = ashr i64 %2, %indvars.iv.next.3
  %17 = icmp eq i64 %16, 0
  br i1 %17, label %.loopexit, label %18

18:                                               ; preds = %15
  %indvars.iv.next.4 = add nuw nsw i64 %indvars.iv, 5
  %exitcond.not.4 = icmp eq i64 %indvars.iv.next.4, 200
  br i1 %exitcond.not.4, label %.loopexit.thread, label %3, !llvm.loop !11

.loopexit:                                        ; preds = %15, %12, %9, %6, %3
  %indvars.iv.lcssa = phi i64 [ %indvars.iv, %3 ], [ %indvars.iv.next, %6 ], [ %indvars.iv.next.1, %9 ], [ %indvars.iv.next.2, %12 ], [ %indvars.iv.next.3, %15 ]
  %19 = trunc nuw nsw i64 %indvars.iv.lcssa to i32
  store i32 %19, ptr @N, align 4, !tbaa !5
  %20 = add i32 %19, -1
  %21 = icmp ult i32 %20, 20
  br i1 %21, label %.preheader23, label %.loopexit.thread

.preheader23:                                     ; preds = %.loopexit
  %22 = icmp ugt i64 %indvars.iv.lcssa, 1
  br i1 %22, label %.lr.ph, label %._crit_edge

.loopexit.thread:                                 ; preds = %18, %.loopexit
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, i32 noundef 81, ptr noundef nonnull @__PRETTY_FUNCTION__.main) #3
  unreachable

.preheader:                                       ; preds = %.lr.ph
  %23 = icmp sgt i32 %26, 1
  br i1 %23, label %.lr.ph29.preheader, label %._crit_edge

.lr.ph29.preheader:                               ; preds = %.preheader
  %.pre35 = load i64, ptr @L, align 8, !tbaa !9
  br label %.lr.ph29

.lr.ph:                                           ; preds = %.preheader23, %.lr.ph
  %.02027 = phi i32 [ %24, %.lr.ph ], [ 0, %.preheader23 ]
  %.02126 = phi i32 [ %25, %.lr.ph ], [ 1, %.preheader23 ]
  %24 = add nuw nsw i32 %.02027, 1
  tail call void @_Z8add_edgeiii(i32 noundef %.02027, i32 noundef %24, i32 noundef 0)
  tail call void @_Z8add_edgeiii(i32 noundef %.02027, i32 noundef %24, i32 noundef %.02126)
  %25 = shl nsw i32 %.02126, 1
  %26 = load i32, ptr @N, align 4, !tbaa !5
  %27 = add nsw i32 %26, -1
  %28 = icmp slt i32 %24, %27
  br i1 %28, label %.lr.ph, label %.preheader, !llvm.loop !13

._crit_edge:                                      ; preds = %42, %.preheader23, %.preheader
  tail call void @_Z5flushv()
  ret i32 0

.lr.ph29:                                         ; preds = %.lr.ph29.preheader, %42
  %29 = phi i32 [ %26, %.lr.ph29.preheader ], [ %43, %42 ]
  %30 = phi i64 [ %.pre35, %.lr.ph29.preheader ], [ %44, %42 ]
  %indvars.iv32 = phi i64 [ 0, %.lr.ph29.preheader ], [ %indvars.iv.next33.pre-phi, %42 ]
  %31 = phi i32 [ %27, %.lr.ph29.preheader ], [ %45, %42 ]
  %32 = shl nuw i64 1, %indvars.iv32
  %33 = and i64 %30, %32
  %.not = icmp eq i64 %33, 0
  br i1 %.not, label %.lr.ph29._crit_edge, label %34

.lr.ph29._crit_edge:                              ; preds = %.lr.ph29
  %.pre37 = add nuw nsw i64 %indvars.iv32, 1
  br label %42

34:                                               ; preds = %.lr.ph29
  %notmask = shl nsw i32 -1, %29
  %35 = xor i32 %notmask, -1
  %36 = add nuw nsw i64 %indvars.iv32, 1
  %37 = trunc nuw nsw i64 %36 to i32
  %38 = shl i32 %35, %37
  %39 = trunc i64 %30 to i32
  %40 = and i32 %38, %39
  %41 = trunc nuw nsw i64 %indvars.iv32 to i32
  tail call void @_Z8add_edgeiii(i32 noundef %41, i32 noundef %31, i32 noundef %40)
  %.pre = load i64, ptr @L, align 8, !tbaa !9
  %.pre36 = load i32, ptr @N, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %.lr.ph29._crit_edge, %34
  %indvars.iv.next33.pre-phi = phi i64 [ %.pre37, %.lr.ph29._crit_edge ], [ %36, %34 ]
  %43 = phi i32 [ %29, %.lr.ph29._crit_edge ], [ %.pre36, %34 ]
  %44 = phi i64 [ %30, %.lr.ph29._crit_edge ], [ %.pre, %34 ]
  %45 = add nsw i32 %43, -1
  %46 = sext i32 %45 to i64
  %47 = icmp slt i64 %indvars.iv.next33.pre-phi, %46
  br i1 %47, label %.lr.ph29, label %._crit_edge, !llvm.loop !14
}

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

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


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