; LLVM IR from kazunetakahashi/atcoder :: 2019/0714_AGC035/C.ll (Z5solvev)

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

@N = external dso_local global i32, align 4
@.str.4 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [80 x i8], align 1
@__PRETTY_FUNCTION__._Z5solvev = external hidden unnamed_addr constant [13 x i8], align 1

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() #1 {
  %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 = load i32, ptr @N, align 4, !tbaa !5
  %7 = add nsw i32 %6, 1
  %8 = load i32, ptr @N, align 4, !tbaa !5
  %9 = add nsw i32 %8, 2
  call void @_Z8add_edgeii(i32 noundef %7, i32 noundef %9)
  %10 = load i32, ptr @N, align 4, !tbaa !5
  %11 = add nsw i32 %10, 2
  call void @_Z8add_edgeii(i32 noundef %11, i32 noundef 3)
  call void @_Z8add_edgeii(i32 noundef 3, i32 noundef 1)
  call void @_Z8add_edgeii(i32 noundef 1, i32 noundef 2)
  %12 = load i32, ptr @N, align 4, !tbaa !5
  %13 = add nsw i32 3, %12
  call void @_Z8add_edgeii(i32 noundef 2, i32 noundef %13)
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  store i32 4, ptr %1, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %34, %0
  %15 = load i32, ptr %1, align 4, !tbaa !5
  %16 = add nsw i32 %15, 1
  %17 = load i32, ptr @N, align 4, !tbaa !5
  %18 = icmp sle i32 %16, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  br label %37

20:                                               ; preds = %14
  %21 = load i32, ptr %1, align 4, !tbaa !5
  call void @_Z8add_edgeii(i32 noundef 1, i32 noundef %21)
  %22 = load i32, ptr %1, align 4, !tbaa !5
  %23 = load i32, ptr %1, align 4, !tbaa !5
  %24 = add nsw i32 %23, 1
  %25 = load i32, ptr @N, align 4, !tbaa !5
  %26 = add nsw i32 %24, %25
  call void @_Z8add_edgeii(i32 noundef %22, i32 noundef %26)
  %27 = load i32, ptr %1, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  call void @_Z8add_edgeii(i32 noundef 1, i32 noundef %28)
  %29 = load i32, ptr %1, align 4, !tbaa !5
  %30 = add nsw i32 %29, 1
  %31 = load i32, ptr %1, align 4, !tbaa !5
  %32 = load i32, ptr @N, align 4, !tbaa !5
  %33 = add nsw i32 %31, %32
  call void @_Z8add_edgeii(i32 noundef %30, i32 noundef %33)
  br label %34

34:                                               ; preds = %20
  %35 = load i32, ptr %1, align 4, !tbaa !5
  %36 = add nsw i32 %35, 2
  store i32 %36, ptr %1, align 4, !tbaa !5
  br label %14, !llvm.loop !9

37:                                               ; preds = %19
  %38 = load i32, ptr @N, align 4, !tbaa !5
  %39 = srem i32 %38, 2
  %40 = icmp eq i32 %39, 0
  br i1 %40, label %41, label %77

41:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 -1, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 30, ptr %3, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %56, %41
  %43 = load i32, ptr %3, align 4, !tbaa !5
  %44 = icmp sge i32 %43, 0
  br i1 %44, label %46, label %45

45:                                               ; preds = %42
  store i32 5, ptr %4, align 4
  br label %59

46:                                               ; preds = %42
  %47 = load i32, ptr @N, align 4, !tbaa !5
  %48 = load i32, ptr %3, align 4, !tbaa !5
  %49 = ashr i32 %47, %48
  %50 = and i32 %49, 1
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %52, label %55

52:                                               ; preds = %46
  %53 = load i32, ptr %3, align 4, !tbaa !5
  %54 = shl i32 1, %53
  store i32 %54, ptr %2, align 4, !tbaa !5
  store i32 5, ptr %4, align 4
  br label %59

55:                                               ; preds = %46
  br label %56

56:                                               ; preds = %55
  %57 = load i32, ptr %3, align 4, !tbaa !5
  %58 = add nsw i32 %57, -1
  store i32 %58, ptr %3, align 4, !tbaa !5
  br label %42, !llvm.loop !11

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

60:                                               ; preds = %59
  %61 = load i32, ptr %2, align 4, !tbaa !5
  %62 = icmp ne i32 %61, -1
  br i1 %62, label %63, label %64

63:                                               ; preds = %60
  br label %66

64:                                               ; preds = %60
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.5, i32 noundef 167, ptr noundef @__PRETTY_FUNCTION__._Z5solvev) #4
  unreachable

65:                                               ; No predecessors!
  br label %66

66:                                               ; preds = %65, %63
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %67 = load i32, ptr @N, align 4, !tbaa !5
  %68 = load i32, ptr %2, align 4, !tbaa !5
  %69 = sub nsw i32 %67, %68
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %5, align 4, !tbaa !5
  %71 = load i32, ptr @N, align 4, !tbaa !5
  %72 = load i32, ptr %2, align 4, !tbaa !5
  call void @_Z8add_edgeii(i32 noundef %71, i32 noundef %72)
  %73 = load i32, ptr %5, align 4, !tbaa !5
  %74 = load i32, ptr @N, align 4, !tbaa !5
  %75 = load i32, ptr @N, align 4, !tbaa !5
  %76 = add nsw i32 %74, %75
  call void @_Z8add_edgeii(i32 noundef %73, i32 noundef %76)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  br label %77

77:                                               ; preds = %66, %37
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { nounwind }
attributes #4 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !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"

@N = external dso_local local_unnamed_addr global i32, align 4
@.str.4 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [80 x i8], align 1
@__PRETTY_FUNCTION__._Z5solvev = external hidden unnamed_addr constant [13 x i8], align 1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() local_unnamed_addr #0 {
  %1 = load i32, ptr @N, align 4, !tbaa !5
  %2 = add nsw i32 %1, 1
  %3 = add nsw i32 %1, 2
  tail call void @_Z8add_edgeii(i32 noundef %2, i32 noundef %3)
  %4 = load i32, ptr @N, align 4, !tbaa !5
  %5 = add nsw i32 %4, 2
  tail call void @_Z8add_edgeii(i32 noundef %5, i32 noundef 3)
  tail call void @_Z8add_edgeii(i32 noundef 3, i32 noundef 1)
  tail call void @_Z8add_edgeii(i32 noundef 1, i32 noundef 2)
  %6 = load i32, ptr @N, align 4, !tbaa !5
  %7 = add nsw i32 %6, 3
  tail call void @_Z8add_edgeii(i32 noundef 2, i32 noundef %7)
  %8 = load i32, ptr @N, align 4, !tbaa !5
  %.not.not24 = icmp sgt i32 %8, 4
  br i1 %.not.not24, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  %.lcssa23 = phi i32 [ %8, %0 ], [ %18, %.lr.ph ]
  %9 = and i32 %.lcssa23, 1
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %.preheader.preheader, label %53

.preheader.preheader:                             ; preds = %._crit_edge
  %11 = and i32 %.lcssa23, 1073741824
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %.preheader.1, label %48

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.025 = phi i32 [ %17, %.lr.ph ], [ 4, %0 ]
  %12 = or disjoint i32 %.025, 1
  tail call void @_Z8add_edgeii(i32 noundef 1, i32 noundef %.025)
  %13 = load i32, ptr @N, align 4, !tbaa !5
  %14 = add nsw i32 %13, %12
  tail call void @_Z8add_edgeii(i32 noundef %.025, i32 noundef %14)
  tail call void @_Z8add_edgeii(i32 noundef 1, i32 noundef %12)
  %15 = load i32, ptr @N, align 4, !tbaa !5
  %16 = add nsw i32 %15, %.025
  tail call void @_Z8add_edgeii(i32 noundef %12, i32 noundef %16)
  %17 = add nuw nsw i32 %.025, 2
  %18 = load i32, ptr @N, align 4, !tbaa !5
  %.not.not = icmp slt i32 %17, %18
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !9

.preheader.1:                                     ; preds = %.preheader.preheader
  %19 = and i32 %.lcssa23, 536870912
  %.not.1 = icmp eq i32 %19, 0
  br i1 %.not.1, label %.preheader.2, label %48

.preheader.2:                                     ; preds = %.preheader.1
  %20 = and i32 %.lcssa23, 268435456
  %.not.2 = icmp eq i32 %20, 0
  br i1 %.not.2, label %.preheader.3, label %48

.preheader.3:                                     ; preds = %.preheader.2
  %21 = and i32 %.lcssa23, 134217728
  %.not.3 = icmp eq i32 %21, 0
  br i1 %.not.3, label %.preheader.4, label %48

.preheader.4:                                     ; preds = %.preheader.3
  %22 = and i32 %.lcssa23, 67108864
  %.not.4 = icmp eq i32 %22, 0
  br i1 %.not.4, label %.preheader.5, label %48

.preheader.5:                                     ; preds = %.preheader.4
  %23 = and i32 %.lcssa23, 33554432
  %.not.5 = icmp eq i32 %23, 0
  br i1 %.not.5, label %.preheader.6, label %48

.preheader.6:                                     ; preds = %.preheader.5
  %24 = and i32 %.lcssa23, 16777216
  %.not.6 = icmp eq i32 %24, 0
  br i1 %.not.6, label %.preheader.7, label %48

.preheader.7:                                     ; preds = %.preheader.6
  %25 = and i32 %.lcssa23, 8388608
  %.not.7 = icmp eq i32 %25, 0
  br i1 %.not.7, label %.preheader.8, label %48

.preheader.8:                                     ; preds = %.preheader.7
  %26 = and i32 %.lcssa23, 4194304
  %.not.8 = icmp eq i32 %26, 0
  br i1 %.not.8, label %.preheader.9, label %48

.preheader.9:                                     ; preds = %.preheader.8
  %27 = and i32 %.lcssa23, 2097152
  %.not.9 = icmp eq i32 %27, 0
  br i1 %.not.9, label %.preheader.10, label %48

.preheader.10:                                    ; preds = %.preheader.9
  %28 = and i32 %.lcssa23, 1048576
  %.not.10 = icmp eq i32 %28, 0
  br i1 %.not.10, label %.preheader.11, label %48

.preheader.11:                                    ; preds = %.preheader.10
  %29 = and i32 %.lcssa23, 524288
  %.not.11 = icmp eq i32 %29, 0
  br i1 %.not.11, label %.preheader.12, label %48

.preheader.12:                                    ; preds = %.preheader.11
  %30 = and i32 %.lcssa23, 262144
  %.not.12 = icmp eq i32 %30, 0
  br i1 %.not.12, label %.preheader.13, label %48

.preheader.13:                                    ; preds = %.preheader.12
  %31 = and i32 %.lcssa23, 131072
  %.not.13 = icmp eq i32 %31, 0
  br i1 %.not.13, label %.preheader.14, label %48

.preheader.14:                                    ; preds = %.preheader.13
  %32 = and i32 %.lcssa23, 65536
  %.not.14 = icmp eq i32 %32, 0
  br i1 %.not.14, label %.preheader.15, label %48

.preheader.15:                                    ; preds = %.preheader.14
  %33 = and i32 %.lcssa23, 32768
  %.not.15 = icmp eq i32 %33, 0
  br i1 %.not.15, label %.preheader.16, label %48

.preheader.16:                                    ; preds = %.preheader.15
  %34 = and i32 %.lcssa23, 16384
  %.not.16 = icmp eq i32 %34, 0
  br i1 %.not.16, label %.preheader.17, label %48

.preheader.17:                                    ; preds = %.preheader.16
  %35 = and i32 %.lcssa23, 8192
  %.not.17 = icmp eq i32 %35, 0
  br i1 %.not.17, label %.preheader.18, label %48

.preheader.18:                                    ; preds = %.preheader.17
  %36 = and i32 %.lcssa23, 4096
  %.not.18 = icmp eq i32 %36, 0
  br i1 %.not.18, label %.preheader.19, label %48

.preheader.19:                                    ; preds = %.preheader.18
  %37 = and i32 %.lcssa23, 2048
  %.not.19 = icmp eq i32 %37, 0
  br i1 %.not.19, label %.preheader.20, label %48

.preheader.20:                                    ; preds = %.preheader.19
  %38 = and i32 %.lcssa23, 1024
  %.not.20 = icmp eq i32 %38, 0
  br i1 %.not.20, label %.preheader.21, label %48

.preheader.21:                                    ; preds = %.preheader.20
  %39 = and i32 %.lcssa23, 512
  %.not.21 = icmp eq i32 %39, 0
  br i1 %.not.21, label %.preheader.22, label %48

.preheader.22:                                    ; preds = %.preheader.21
  %40 = and i32 %.lcssa23, 256
  %.not.22 = icmp eq i32 %40, 0
  br i1 %.not.22, label %.preheader.23, label %48

.preheader.23:                                    ; preds = %.preheader.22
  %41 = and i32 %.lcssa23, 128
  %.not.23 = icmp eq i32 %41, 0
  br i1 %.not.23, label %.preheader.24, label %48

.preheader.24:                                    ; preds = %.preheader.23
  %42 = and i32 %.lcssa23, 64
  %.not.24 = icmp eq i32 %42, 0
  br i1 %.not.24, label %.preheader.25, label %48

.preheader.25:                                    ; preds = %.preheader.24
  %43 = and i32 %.lcssa23, 32
  %.not.25 = icmp eq i32 %43, 0
  br i1 %.not.25, label %.preheader.26, label %48

.preheader.26:                                    ; preds = %.preheader.25
  %44 = and i32 %.lcssa23, 16
  %.not.26 = icmp eq i32 %44, 0
  br i1 %.not.26, label %.preheader.27, label %48

.preheader.27:                                    ; preds = %.preheader.26
  %45 = and i32 %.lcssa23, 8
  %.not.27 = icmp eq i32 %45, 0
  br i1 %.not.27, label %.preheader.28, label %48

.preheader.28:                                    ; preds = %.preheader.27
  %46 = and i32 %.lcssa23, 4
  %.not.28 = icmp eq i32 %46, 0
  br i1 %.not.28, label %.preheader.29, label %48

.preheader.29:                                    ; preds = %.preheader.28
  %47 = and i32 %.lcssa23, 2
  %.not.29 = icmp eq i32 %47, 0
  br i1 %.not.29, label %.preheader.30, label %48

.preheader.30:                                    ; preds = %.preheader.29
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.5, i32 noundef 167, ptr noundef nonnull @__PRETTY_FUNCTION__._Z5solvev) #2
  unreachable

48:                                               ; preds = %.preheader.29, %.preheader.28, %.preheader.27, %.preheader.26, %.preheader.25, %.preheader.24, %.preheader.23, %.preheader.22, %.preheader.21, %.preheader.20, %.preheader.19, %.preheader.18, %.preheader.17, %.preheader.16, %.preheader.15, %.preheader.14, %.preheader.13, %.preheader.12, %.preheader.11, %.preheader.10, %.preheader.9, %.preheader.8, %.preheader.7, %.preheader.6, %.preheader.5, %.preheader.4, %.preheader.3, %.preheader.2, %.preheader.1, %.preheader.preheader
  %.lcssa = phi i32 [ 1073741824, %.preheader.preheader ], [ 536870912, %.preheader.1 ], [ 268435456, %.preheader.2 ], [ 134217728, %.preheader.3 ], [ 67108864, %.preheader.4 ], [ 33554432, %.preheader.5 ], [ 16777216, %.preheader.6 ], [ 8388608, %.preheader.7 ], [ 4194304, %.preheader.8 ], [ 2097152, %.preheader.9 ], [ 1048576, %.preheader.10 ], [ 524288, %.preheader.11 ], [ 262144, %.preheader.12 ], [ 131072, %.preheader.13 ], [ 65536, %.preheader.14 ], [ 32768, %.preheader.15 ], [ 16384, %.preheader.16 ], [ 8192, %.preheader.17 ], [ 4096, %.preheader.18 ], [ 2048, %.preheader.19 ], [ 1024, %.preheader.20 ], [ 512, %.preheader.21 ], [ 256, %.preheader.22 ], [ 128, %.preheader.23 ], [ 64, %.preheader.24 ], [ 32, %.preheader.25 ], [ 16, %.preheader.26 ], [ 8, %.preheader.27 ], [ 4, %.preheader.28 ], [ 2, %.preheader.29 ]
  %49 = or disjoint i32 %.lcssa23, 1
  %50 = sub i32 %49, %.lcssa
  tail call void @_Z8add_edgeii(i32 noundef %.lcssa23, i32 noundef %.lcssa)
  %51 = load i32, ptr @N, align 4, !tbaa !5
  %52 = shl nsw i32 %51, 1
  tail call void @_Z8add_edgeii(i32 noundef %50, i32 noundef %52)
  br label %53

53:                                               ; preds = %48, %._crit_edge
  ret void
}

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

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 = { 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 #2 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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