; LLVM IR from tangjz/acm-icpc :: 51nod (1185)

; 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
@a = external dso_local global i64, align 8
@b = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@_ZL3sei = external hidden constant [3 x i32], align 4
@.str.3 = external hidden unnamed_addr constant [2 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
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %6

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

10:                                               ; preds = %6
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @a, ptr noundef @b)
  %12 = load i64, ptr @a, align 8, !tbaa !9
  %13 = load i64, ptr @b, align 8, !tbaa !9
  %14 = icmp sgt i64 %12, %13
  br i1 %14, label %15, label %25

15:                                               ; preds = %10
  %16 = load i64, ptr @a, align 8, !tbaa !9
  %17 = load i64, ptr @b, align 8, !tbaa !9
  %18 = add nsw i64 %16, %17
  store i64 %18, ptr @a, align 8, !tbaa !9
  %19 = load i64, ptr @a, align 8, !tbaa !9
  %20 = load i64, ptr @b, align 8, !tbaa !9
  %21 = sub nsw i64 %19, %20
  store i64 %21, ptr @b, align 8, !tbaa !9
  %22 = load i64, ptr @a, align 8, !tbaa !9
  %23 = load i64, ptr @b, align 8, !tbaa !9
  %24 = sub nsw i64 %22, %23
  store i64 %24, ptr @a, align 8, !tbaa !9
  br label %25

25:                                               ; preds = %15, %10
  %26 = load i64, ptr @a, align 8, !tbaa !9
  %27 = load i64, ptr @b, align 8, !tbaa !9
  %28 = sub nsw i64 %27, %26
  store i64 %28, ptr @b, align 8, !tbaa !9
  %29 = load i64, ptr @a, align 8, !tbaa !9
  %30 = load i64, ptr @b, align 8, !tbaa !9
  %31 = icmp sle i64 %29, %30
  br i1 %31, label %37, label %32

32:                                               ; preds = %25
  %33 = load i64, ptr @a, align 8, !tbaa !9
  %34 = load i64, ptr @b, align 8, !tbaa !9
  %35 = shl i64 %34, 1
  %36 = icmp sge i64 %33, %35
  br i1 %36, label %37, label %39

37:                                               ; preds = %32, %25
  %38 = call i32 @puts(ptr noundef @.str.2)
  br label %6, !llvm.loop !11

39:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  %40 = load i64, ptr @b, align 8, !tbaa !9
  %41 = sdiv i64 %40, 1000000000
  %42 = trunc i64 %41 to i32
  store i32 %42, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %43 = load i64, ptr @b, align 8, !tbaa !9
  %44 = srem i64 %43, 1000000000
  %45 = trunc i64 %44 to i32
  store i32 %45, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %46 = load i32, ptr %3, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = load i32, ptr getelementptr inbounds ([3 x i32], ptr @_ZL3sei, i64 0, i64 2), align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = mul nsw i64 %47, %49
  %51 = sdiv i64 %50, 1000000000
  %52 = load i32, ptr %2, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = load i32, ptr getelementptr inbounds ([3 x i32], ptr @_ZL3sei, i64 0, i64 2), align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = mul nsw i64 %53, %55
  %57 = add nsw i64 %51, %56
  %58 = load i32, ptr %3, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = load i32, ptr getelementptr inbounds ([3 x i32], ptr @_ZL3sei, i64 0, i64 1), align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = mul nsw i64 %59, %61
  %63 = add nsw i64 %57, %62
  %64 = sdiv i64 %63, 1000000000
  %65 = load i32, ptr %2, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = load i32, ptr getelementptr inbounds ([3 x i32], ptr @_ZL3sei, i64 0, i64 1), align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = mul nsw i64 %66, %68
  %70 = add nsw i64 %64, %69
  %71 = load i32, ptr %3, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = load i32, ptr @_ZL3sei, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = mul nsw i64 %72, %74
  %76 = add nsw i64 %70, %75
  %77 = sdiv i64 %76, 1000000000
  %78 = load i32, ptr %2, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = load i32, ptr @_ZL3sei, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = mul nsw i64 %79, %81
  %83 = add nsw i64 %77, %82
  %84 = load i64, ptr @b, align 8, !tbaa !9
  %85 = add nsw i64 %83, %84
  store i64 %85, ptr %4, align 8, !tbaa !9
  %86 = load i64, ptr @a, align 8, !tbaa !9
  %87 = load i64, ptr %4, align 8, !tbaa !9
  %88 = icmp ne i64 %86, %87
  br i1 %88, label %89, label %90

89:                                               ; preds = %39
  br label %91

90:                                               ; preds = %39
  br label %91

91:                                               ; preds = %90, %89
  %92 = phi ptr [ @.str.2, %89 ], [ @.str.3, %90 ]
  %93 = getelementptr inbounds [2 x i8], ptr %92, i64 0, i64 0
  %94 = call i32 @puts(ptr noundef %93)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  br label %6, !llvm.loop !11

95:                                               ; preds = %6
  ret i32 0
}

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

declare i32 @puts(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

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


; 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
@a = external dso_local global i64, align 8
@b = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@_ZL3sei = external hidden local_unnamed_addr constant [3 x i32], align 4
@.str.3 = external hidden unnamed_addr constant [2 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
  %.not13 = icmp eq i32 %2, 0
  br i1 %.not13, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0
  %4 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL3sei, i64 8), align 4
  %5 = sext i32 %4 to i64
  %6 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL3sei, i64 4), align 4
  %7 = sext i32 %6 to i64
  %8 = load i32, ptr @_ZL3sei, align 4
  %9 = sext i32 %8 to i64
  br label %10

10:                                               ; preds = %.lr.ph, %.backedge
  %11 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @a, ptr noundef nonnull @b)
  %12 = load i64, ptr @a, align 8, !tbaa !9
  %13 = load i64, ptr @b, align 8, !tbaa !9
  %14 = icmp sgt i64 %12, %13
  br i1 %14, label %15, label %16

15:                                               ; preds = %10
  store i64 %13, ptr @a, align 8, !tbaa !9
  br label %16

16:                                               ; preds = %15, %10
  %17 = phi i64 [ %12, %15 ], [ %13, %10 ]
  %18 = phi i64 [ %13, %15 ], [ %12, %10 ]
  %19 = sub nsw i64 %17, %18
  store i64 %19, ptr @b, align 8, !tbaa !9
  %.not10 = icmp sgt i64 %18, %19
  %20 = shl i64 %19, 1
  %.not11 = icmp slt i64 %18, %20
  %or.cond = and i1 %.not10, %.not11
  br i1 %or.cond, label %24, label %.backedge

.backedge:                                        ; preds = %16, %24
  %.str.2.sink = phi ptr [ %.str.2..str.3, %24 ], [ @.str.2, %16 ]
  %21 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) %.str.2.sink)
  %22 = load i32, ptr @t, align 4, !tbaa !5
  %23 = add nsw i32 %22, -1
  store i32 %23, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %22, 0
  br i1 %.not, label %._crit_edge, label %10, !llvm.loop !11

24:                                               ; preds = %16
  %25 = sdiv i64 %19, 1000000000
  %26 = srem i64 %19, 1000000000
  %27 = mul nsw i64 %26, %5
  %28 = sdiv i64 %27, 1000000000
  %sext = shl i64 %25, 32
  %29 = ashr exact i64 %sext, 32
  %30 = mul nsw i64 %29, %5
  %31 = add nsw i64 %28, %30
  %32 = mul nsw i64 %26, %7
  %33 = add nsw i64 %31, %32
  %34 = sdiv i64 %33, 1000000000
  %35 = mul nsw i64 %29, %7
  %36 = mul nsw i64 %26, %9
  %37 = add nsw i64 %36, %35
  %38 = add nsw i64 %37, %34
  %39 = sdiv i64 %38, 1000000000
  %40 = mul nsw i64 %29, %9
  %41 = add i64 %40, %19
  %42 = add i64 %41, %39
  %.not12 = icmp eq i64 %18, %42
  %.str.2..str.3 = select i1 %.not12, ptr @.str.3, ptr @.str.2
  br label %.backedge

._crit_edge:                                      ; preds = %.backedge, %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 @puts(ptr nocapture noundef readonly) local_unnamed_addr #1

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

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


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