; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ (2067)

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

@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [19 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca [36 x [36 x i64]], align 16
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 10368, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store i64 1, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds [36 x [36 x i64]], ptr %3, i64 0, i64 0
  %10 = getelementptr inbounds [36 x i64], ptr %9, i64 0, i64 0
  store i64 0, ptr %10, align 16, !tbaa !5
  %11 = getelementptr inbounds [36 x [36 x i64]], ptr %3, i64 0, i64 1
  %12 = getelementptr inbounds [36 x i64], ptr %11, i64 0, i64 1
  store i64 1, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %22, %0
  %14 = load i32, ptr %5, align 4, !tbaa !9
  %15 = icmp sle i32 %14, 35
  br i1 %15, label %17, label %16

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

17:                                               ; preds = %13
  %18 = getelementptr inbounds [36 x [36 x i64]], ptr %3, i64 0, i64 0
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [36 x i64], ptr %18, i64 0, i64 %20
  store i64 1, ptr %21, align 8, !tbaa !5
  br label %22

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

25:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 1, ptr %6, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %79, %25
  %27 = load i32, ptr %6, align 4, !tbaa !9
  %28 = icmp sle i32 %27, 35
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  store i32 5, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %82

30:                                               ; preds = %26
  %31 = load i32, ptr %6, align 4, !tbaa !9
  %32 = sub nsw i32 %31, 1
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [36 x [36 x i64]], ptr %3, i64 0, i64 %33
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [36 x i64], ptr %34, i64 0, i64 %36
  %38 = load i64, ptr %37, align 8, !tbaa !5
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [36 x [36 x i64]], ptr %3, i64 0, i64 %40
  %42 = load i32, ptr %6, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [36 x i64], ptr %41, i64 0, i64 %43
  store i64 %38, ptr %44, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %45 = load i32, ptr %6, align 4, !tbaa !9
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %8, align 4, !tbaa !9
  br label %47

47:                                               ; preds = %75, %30
  %48 = load i32, ptr %8, align 4, !tbaa !9
  %49 = icmp sle i32 %48, 35
  br i1 %49, label %51, label %50

50:                                               ; preds = %47
  store i32 8, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %78

51:                                               ; preds = %47
  %52 = load i32, ptr %6, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [36 x [36 x i64]], ptr %3, i64 0, i64 %53
  %55 = load i32, ptr %8, align 4, !tbaa !9
  %56 = sub nsw i32 %55, 1
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [36 x i64], ptr %54, i64 0, i64 %57
  %59 = load i64, ptr %58, align 8, !tbaa !5
  %60 = load i32, ptr %6, align 4, !tbaa !9
  %61 = sub nsw i32 %60, 1
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [36 x [36 x i64]], ptr %3, i64 0, i64 %62
  %64 = load i32, ptr %8, align 4, !tbaa !9
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [36 x i64], ptr %63, i64 0, i64 %65
  %67 = load i64, ptr %66, align 8, !tbaa !5
  %68 = add nsw i64 %59, %67
  %69 = load i32, ptr %6, align 4, !tbaa !9
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [36 x [36 x i64]], ptr %3, i64 0, i64 %70
  %72 = load i32, ptr %8, align 4, !tbaa !9
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [36 x i64], ptr %71, i64 0, i64 %73
  store i64 %68, ptr %74, align 8, !tbaa !5
  br label %75

75:                                               ; preds = %51
  %76 = load i32, ptr %8, align 4, !tbaa !9
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %8, align 4, !tbaa !9
  br label %47, !llvm.loop !13

78:                                               ; preds = %50
  br label %79

79:                                               ; preds = %78
  %80 = load i32, ptr %6, align 4, !tbaa !9
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %6, align 4, !tbaa !9
  br label %26, !llvm.loop !14

82:                                               ; preds = %29
  br label %83

83:                                               ; preds = %92, %82
  %84 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  %85 = xor i32 %84, -1
  %86 = icmp ne i32 %85, 0
  br i1 %86, label %87, label %90

87:                                               ; preds = %83
  %88 = load i64, ptr %2, align 8, !tbaa !5
  %89 = icmp ne i64 %88, -1
  br label %90

90:                                               ; preds = %87, %83
  %91 = phi i1 [ false, %83 ], [ %89, %87 ]
  br i1 %91, label %92, label %103

92:                                               ; preds = %90
  %93 = load i64, ptr %4, align 8, !tbaa !5
  %94 = add nsw i64 %93, 1
  store i64 %94, ptr %4, align 8, !tbaa !5
  %95 = load i64, ptr %2, align 8, !tbaa !5
  %96 = load i64, ptr %2, align 8, !tbaa !5
  %97 = getelementptr inbounds [36 x [36 x i64]], ptr %3, i64 0, i64 %96
  %98 = load i64, ptr %2, align 8, !tbaa !5
  %99 = getelementptr inbounds [36 x i64], ptr %97, i64 0, i64 %98
  %100 = load i64, ptr %99, align 8, !tbaa !5
  %101 = mul nsw i64 2, %100
  %102 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %93, i64 noundef %95, i64 noundef %101)
  br label %83, !llvm.loop !15

103:                                              ; preds = %90
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 10368, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  %104 = load i32, ptr %1, align 4
  ret i32 %104
}

; 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

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 }

!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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !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"

@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [19 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
.preheader24.preheader:
  %0 = alloca i64, align 8
  %1 = alloca [36 x [36 x i64]], align 16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %0) #3
  call void @llvm.lifetime.start.p0(i64 10368, ptr nonnull %1) #3
  store i64 0, ptr %1, align 16, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %1, i64 296
  store i64 1, ptr %2, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %1, i64 8
  store i64 1, ptr %3, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 16
  store i64 1, ptr %4, align 16, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 24
  store i64 1, ptr %5, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 32
  store i64 1, ptr %6, align 16, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %1, i64 40
  store i64 1, ptr %7, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %1, i64 48
  store i64 1, ptr %8, align 16, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %1, i64 56
  store i64 1, ptr %9, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %1, i64 64
  store i64 1, ptr %10, align 16, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %1, i64 72
  store i64 1, ptr %11, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %1, i64 80
  store i64 1, ptr %12, align 16, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %1, i64 88
  store i64 1, ptr %13, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %1, i64 96
  store i64 1, ptr %14, align 16, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %1, i64 104
  store i64 1, ptr %15, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %1, i64 112
  store i64 1, ptr %16, align 16, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %1, i64 120
  store i64 1, ptr %17, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %1, i64 128
  store i64 1, ptr %18, align 16, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %1, i64 136
  store i64 1, ptr %19, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %1, i64 144
  store i64 1, ptr %20, align 16, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %1, i64 152
  store i64 1, ptr %21, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %1, i64 160
  store i64 1, ptr %22, align 16, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %1, i64 168
  store i64 1, ptr %23, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %1, i64 176
  store i64 1, ptr %24, align 16, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %1, i64 184
  store i64 1, ptr %25, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %1, i64 192
  store i64 1, ptr %26, align 16, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %1, i64 200
  store i64 1, ptr %27, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %1, i64 208
  store i64 1, ptr %28, align 16, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %1, i64 216
  store i64 1, ptr %29, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %1, i64 224
  store i64 1, ptr %30, align 16, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %1, i64 232
  store i64 1, ptr %31, align 8, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %1, i64 240
  store i64 1, ptr %32, align 16, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %1, i64 248
  store i64 1, ptr %33, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %1, i64 256
  store i64 1, ptr %34, align 16, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %1, i64 264
  store i64 1, ptr %35, align 8, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %1, i64 272
  store i64 1, ptr %36, align 16, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %1, i64 280
  store i64 1, ptr %37, align 8, !tbaa !5
  %invariant.gep = getelementptr i8, ptr %1, i64 296
  br label %.preheader24

.loopexit:                                        ; preds = %.lr.ph, %.preheader24
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond37.not = icmp eq i64 %indvars.iv.next35, 36
  %indvar.next = add i64 %indvar, 1
  br i1 %exitcond37.not, label %.preheader, label %.preheader24, !llvm.loop !9

.preheader:                                       ; preds = %.loopexit
  %38 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %0)
  %39 = icmp ne i32 %38, -1
  %40 = load i64, ptr %0, align 8
  %41 = icmp ne i64 %40, -1
  %42 = select i1 %39, i1 %41, i1 false
  br i1 %42, label %.lr.ph29, label %._crit_edge

.preheader24:                                     ; preds = %.preheader24.preheader, %.loopexit
  %indvar = phi i64 [ 0, %.preheader24.preheader ], [ %indvar.next, %.loopexit ]
  %indvars.iv34 = phi i64 [ 1, %.preheader24.preheader ], [ %indvars.iv.next35, %.loopexit ]
  %indvars.iv = phi i64 [ 2, %.preheader24.preheader ], [ %indvars.iv.next, %.loopexit ]
  %43 = add nsw i64 %indvars.iv34, -1
  %44 = getelementptr inbounds [36 x [36 x i64]], ptr %1, i64 0, i64 %43, i64 %indvars.iv34
  %45 = load i64, ptr %44, align 8, !tbaa !5
  %46 = getelementptr inbounds [36 x [36 x i64]], ptr %1, i64 0, i64 %indvars.iv34, i64 %indvars.iv34
  store i64 %45, ptr %46, align 8, !tbaa !5
  %indvars.iv.next35 = add nuw nsw i64 %indvars.iv34, 1
  %47 = icmp ult i64 %indvars.iv34, 35
  br i1 %47, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %.preheader24
  %48 = mul nuw nsw i64 %indvar, 296
  %gep = getelementptr i8, ptr %invariant.gep, i64 %48
  %load_initial = load i64, ptr %gep, align 8
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %store_forwarded = phi i64 [ %load_initial, %.lr.ph.preheader ], [ %51, %.lr.ph ]
  %indvars.iv31 = phi i64 [ %indvars.iv, %.lr.ph.preheader ], [ %indvars.iv.next32, %.lr.ph ]
  %49 = getelementptr inbounds [36 x [36 x i64]], ptr %1, i64 0, i64 %43, i64 %indvars.iv31
  %50 = load i64, ptr %49, align 8, !tbaa !5
  %51 = add nsw i64 %50, %store_forwarded
  %52 = getelementptr inbounds [36 x [36 x i64]], ptr %1, i64 0, i64 %indvars.iv34, i64 %indvars.iv31
  store i64 %51, ptr %52, align 8, !tbaa !5
  %indvars.iv.next32 = add nuw nsw i64 %indvars.iv31, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next32, 36
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph, !llvm.loop !11

.lr.ph29:                                         ; preds = %.preheader, %.lr.ph29
  %53 = phi i64 [ %61, %.lr.ph29 ], [ %40, %.preheader ]
  %.02228 = phi i64 [ %54, %.lr.ph29 ], [ 1, %.preheader ]
  %54 = add nuw nsw i64 %.02228, 1
  %55 = getelementptr inbounds [36 x [36 x i64]], ptr %1, i64 0, i64 %53, i64 %53
  %56 = load i64, ptr %55, align 8, !tbaa !5
  %57 = shl nsw i64 %56, 1
  %58 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %.02228, i64 noundef %53, i64 noundef %57)
  %59 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %0)
  %60 = icmp ne i32 %59, -1
  %61 = load i64, ptr %0, align 8
  %62 = icmp ne i64 %61, -1
  %63 = select i1 %60, i1 %62, i1 false
  br i1 %63, label %.lr.ph29, label %._crit_edge, !llvm.loop !12

._crit_edge:                                      ; preds = %.lr.ph29, %.preheader
  call void @llvm.lifetime.end.p0(i64 10368, ptr nonnull %1) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %0) #3
  ret i32 0
}

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

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"long long", !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}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass