; LLVM IR from tangjz/acm-icpc :: zoj (3962)

; 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
@pw = external dso_local global [9 x i64], align 16
@f = external dso_local global [9 x i64], align 16
@g = external dso_local global [17 x i64], align 16
@_ZL2EC = external hidden constant [17 x i32], align 16
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1

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

6:                                                ; preds = %31, %0
  %7 = load i32, ptr %2, align 4, !tbaa !9
  %8 = icmp slt i32 %7, 9
  br i1 %8, label %10, label %9

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

10:                                               ; preds = %6
  %11 = load i32, ptr %2, align 4, !tbaa !9
  %12 = sub nsw i32 %11, 1
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [9 x i64], ptr @pw, i64 0, i64 %13
  %15 = load i64, ptr %14, align 8, !tbaa !5
  %16 = shl i64 %15, 4
  %17 = load i32, ptr %2, align 4, !tbaa !9
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [9 x i64], ptr @pw, i64 0, i64 %18
  store i64 %16, ptr %19, align 8, !tbaa !5
  %20 = load i32, ptr %2, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = load i32, ptr %2, align 4, !tbaa !9
  %23 = sub nsw i32 %22, 1
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [9 x i64], ptr @pw, i64 0, i64 %24
  %26 = load i64, ptr %25, align 8, !tbaa !5
  %27 = mul nsw i64 %21, %26
  %28 = load i32, ptr %2, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [9 x i64], ptr @f, i64 0, i64 %29
  store i64 %27, ptr %30, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %10
  %32 = load i32, ptr %2, align 4, !tbaa !9
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %2, align 4, !tbaa !9
  br label %6, !llvm.loop !11

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

35:                                               ; preds = %60, %34
  %36 = load i32, ptr %3, align 4, !tbaa !9
  %37 = icmp slt i32 %36, 16
  br i1 %37, label %39, label %38

38:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %63

39:                                               ; preds = %35
  %40 = load i32, ptr %3, align 4, !tbaa !9
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %42, label %48

42:                                               ; preds = %39
  %43 = load i32, ptr %3, align 4, !tbaa !9
  %44 = sub nsw i32 %43, 1
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [17 x i64], ptr @g, i64 0, i64 %45
  %47 = load i64, ptr %46, align 8, !tbaa !5
  br label %49

48:                                               ; preds = %39
  br label %49

49:                                               ; preds = %48, %42
  %50 = phi i64 [ %47, %42 ], [ 0, %48 ]
  %51 = load i32, ptr %3, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [17 x i32], ptr @_ZL2EC, i64 0, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = add nsw i64 %50, %55
  %57 = load i32, ptr %3, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [17 x i64], ptr @g, i64 0, i64 %58
  store i64 %56, ptr %59, align 8, !tbaa !5
  br label %60

60:                                               ; preds = %49
  %61 = load i32, ptr %3, align 4, !tbaa !9
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %3, align 4, !tbaa !9
  br label %35, !llvm.loop !13

63:                                               ; preds = %38
  %64 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @t)
  br label %65

65:                                               ; preds = %69, %63
  %66 = load i32, ptr @t, align 4, !tbaa !9
  %67 = add nsw i32 %66, -1
  store i32 %67, ptr @t, align 4, !tbaa !9
  %68 = icmp ne i32 %66, 0
  br i1 %68, label %69, label %81

69:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %70 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %4, ptr noundef %5)
  %71 = load i64, ptr %4, align 8, !tbaa !5
  %72 = load i64, ptr %5, align 8, !tbaa !5
  %73 = add nsw i64 %71, %72
  %74 = sub nsw i64 %73, 1
  %75 = call noundef i64 @_Z5solvex(i64 noundef %74)
  %76 = load i64, ptr %5, align 8, !tbaa !5
  %77 = sub nsw i64 %76, 1
  %78 = call noundef i64 @_Z5solvex(i64 noundef %77)
  %79 = sub nsw i64 %75, %78
  %80 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %79)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %65, !llvm.loop !14

81:                                               ; preds = %65
  ret i32 0
}

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

declare i32 @printf(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 = { "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 }

!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}


; 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
@pw = external dso_local local_unnamed_addr global [9 x i64], align 16
@f = external dso_local local_unnamed_addr global [9 x i64], align 16
@g = external dso_local local_unnamed_addr global [17 x i64], align 16
@_ZL2EC = external hidden local_unnamed_addr constant [17 x i32], align 16
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z5solvex(i64 noundef) local_unnamed_addr #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: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  store i64 1, ptr @pw, align 16, !tbaa !5
  store i64 16, ptr getelementptr inbounds (i8, ptr @pw, i64 8), align 8, !tbaa !5
  store i64 1, ptr getelementptr inbounds (i8, ptr @f, i64 8), align 8, !tbaa !5
  store i64 256, ptr getelementptr inbounds (i8, ptr @pw, i64 16), align 16, !tbaa !5
  store i64 32, ptr getelementptr inbounds (i8, ptr @f, i64 16), align 16, !tbaa !5
  store i64 4096, ptr getelementptr inbounds (i8, ptr @pw, i64 24), align 8, !tbaa !5
  store i64 768, ptr getelementptr inbounds (i8, ptr @f, i64 24), align 8, !tbaa !5
  store i64 65536, ptr getelementptr inbounds (i8, ptr @pw, i64 32), align 16, !tbaa !5
  store i64 16384, ptr getelementptr inbounds (i8, ptr @f, i64 32), align 16, !tbaa !5
  store i64 1048576, ptr getelementptr inbounds (i8, ptr @pw, i64 40), align 8, !tbaa !5
  store i64 327680, ptr getelementptr inbounds (i8, ptr @f, i64 40), align 8, !tbaa !5
  store i64 16777216, ptr getelementptr inbounds (i8, ptr @pw, i64 48), align 16, !tbaa !5
  store i64 6291456, ptr getelementptr inbounds (i8, ptr @f, i64 48), align 16, !tbaa !5
  store i64 268435456, ptr getelementptr inbounds (i8, ptr @pw, i64 56), align 8, !tbaa !5
  store i64 117440512, ptr getelementptr inbounds (i8, ptr @f, i64 56), align 8, !tbaa !5
  store i64 4294967296, ptr getelementptr inbounds (i8, ptr @pw, i64 64), align 16, !tbaa !5
  store i64 2147483648, ptr getelementptr inbounds (i8, ptr @f, i64 64), align 16, !tbaa !5
  %3 = load i32, ptr @_ZL2EC, align 16, !tbaa !9
  %4 = sext i32 %3 to i64
  store i64 %4, ptr @g, align 16, !tbaa !5
  %5 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL2EC, i64 4), align 4, !tbaa !9
  %6 = sext i32 %5 to i64
  %7 = add nsw i64 %4, %6
  store i64 %7, ptr getelementptr inbounds (i8, ptr @g, i64 8), align 8, !tbaa !5
  %8 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL2EC, i64 8), align 8, !tbaa !9
  %9 = sext i32 %8 to i64
  %10 = add nsw i64 %7, %9
  store i64 %10, ptr getelementptr inbounds (i8, ptr @g, i64 16), align 16, !tbaa !5
  %11 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL2EC, i64 12), align 4, !tbaa !9
  %12 = sext i32 %11 to i64
  %13 = add nsw i64 %10, %12
  store i64 %13, ptr getelementptr inbounds (i8, ptr @g, i64 24), align 8, !tbaa !5
  %14 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL2EC, i64 16), align 16, !tbaa !9
  %15 = sext i32 %14 to i64
  %16 = add nsw i64 %13, %15
  store i64 %16, ptr getelementptr inbounds (i8, ptr @g, i64 32), align 16, !tbaa !5
  %17 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL2EC, i64 20), align 4, !tbaa !9
  %18 = sext i32 %17 to i64
  %19 = add nsw i64 %16, %18
  store i64 %19, ptr getelementptr inbounds (i8, ptr @g, i64 40), align 8, !tbaa !5
  %20 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL2EC, i64 24), align 8, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = add nsw i64 %19, %21
  store i64 %22, ptr getelementptr inbounds (i8, ptr @g, i64 48), align 16, !tbaa !5
  %23 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL2EC, i64 28), align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = add nsw i64 %22, %24
  store i64 %25, ptr getelementptr inbounds (i8, ptr @g, i64 56), align 8, !tbaa !5
  %26 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL2EC, i64 32), align 16, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = add nsw i64 %25, %27
  store i64 %28, ptr getelementptr inbounds (i8, ptr @g, i64 64), align 16, !tbaa !5
  %29 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL2EC, i64 36), align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = add nsw i64 %28, %30
  store i64 %31, ptr getelementptr inbounds (i8, ptr @g, i64 72), align 8, !tbaa !5
  %32 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL2EC, i64 40), align 8, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = add nsw i64 %31, %33
  store i64 %34, ptr getelementptr inbounds (i8, ptr @g, i64 80), align 16, !tbaa !5
  %35 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL2EC, i64 44), align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = add nsw i64 %34, %36
  store i64 %37, ptr getelementptr inbounds (i8, ptr @g, i64 88), align 8, !tbaa !5
  %38 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL2EC, i64 48), align 16, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = add nsw i64 %37, %39
  store i64 %40, ptr getelementptr inbounds (i8, ptr @g, i64 96), align 16, !tbaa !5
  %41 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL2EC, i64 52), align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = add nsw i64 %40, %42
  store i64 %43, ptr getelementptr inbounds (i8, ptr @g, i64 104), align 8, !tbaa !5
  %44 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL2EC, i64 56), align 8, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = add nsw i64 %43, %45
  store i64 %46, ptr getelementptr inbounds (i8, ptr @g, i64 112), align 16, !tbaa !5
  %47 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL2EC, i64 60), align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = add nsw i64 %46, %48
  store i64 %49, ptr getelementptr inbounds (i8, ptr @g, i64 120), align 8, !tbaa !5
  %50 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @t)
  %51 = load i32, ptr @t, align 4, !tbaa !9
  %52 = add nsw i32 %51, -1
  store i32 %52, ptr @t, align 4, !tbaa !9
  %.not17 = icmp eq i32 %51, 0
  br i1 %.not17, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %.lr.ph
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  %53 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %54 = load i64, ptr %1, align 8, !tbaa !5
  %55 = load i64, ptr %2, align 8, !tbaa !5
  %56 = add i64 %54, -1
  %57 = add i64 %56, %55
  %58 = call noundef i64 @_Z5solvex(i64 noundef %57)
  %59 = load i64, ptr %2, align 8, !tbaa !5
  %60 = add nsw i64 %59, -1
  %61 = call noundef i64 @_Z5solvex(i64 noundef %60)
  %62 = sub nsw i64 %58, %61
  %63 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %62)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  %64 = load i32, ptr @t, align 4, !tbaa !9
  %65 = add nsw i32 %64, -1
  store i32 %65, ptr @t, align 4, !tbaa !9
  %.not = icmp eq i32 %64, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

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

; 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 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 = { 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" }
attributes #4 = { 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"}


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