; LLVM IR from tangjz/acm-icpc :: buaa/oj3rd (744)

; 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
@p = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@v = external dso_local global [7 x i32], align 16
@a = external dso_local global i32, align 4
@r = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [27 x i8], align 1

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %5

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

9:                                                ; preds = %5
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @p)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %20, %9
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = icmp slt i32 %12, 7
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %23

15:                                               ; preds = %11
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds i32, ptr @v, i64 %17
  %19 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %18)
  br label %20

20:                                               ; preds = %15
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %2, align 4, !tbaa !5
  br label %11, !llvm.loop !9

23:                                               ; preds = %14
  store i32 0, ptr @q, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %38, %23
  %25 = load i32, ptr %3, align 4, !tbaa !5
  %26 = icmp slt i32 %25, 7
  br i1 %26, label %28, label %27

27:                                               ; preds = %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %41

28:                                               ; preds = %24
  %29 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @a)
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [7 x i32], ptr @v, i64 0, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = load i32, ptr @a, align 4, !tbaa !5
  %35 = mul nsw i32 %33, %34
  %36 = load i32, ptr @q, align 4, !tbaa !5
  %37 = add nsw i32 %36, %35
  store i32 %37, ptr @q, align 4, !tbaa !5
  br label %38

38:                                               ; preds = %28
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %3, align 4, !tbaa !5
  br label %24, !llvm.loop !11

41:                                               ; preds = %27
  %42 = load i32, ptr @p, align 4, !tbaa !5
  %43 = load i32, ptr @q, align 4, !tbaa !5
  %44 = call noundef i32 @_Z3gcdii(i32 noundef %42, i32 noundef %43)
  store i32 %44, ptr @r, align 4, !tbaa !5
  %45 = load i32, ptr @r, align 4, !tbaa !5
  %46 = load i32, ptr @p, align 4, !tbaa !5
  %47 = sdiv i32 %46, %45
  store i32 %47, ptr @p, align 4, !tbaa !5
  %48 = load i32, ptr @r, align 4, !tbaa !5
  %49 = load i32, ptr @q, align 4, !tbaa !5
  %50 = sdiv i32 %49, %48
  store i32 %50, ptr @q, align 4, !tbaa !5
  %51 = load i32, ptr @q, align 4, !tbaa !5
  %52 = load i32, ptr @p, align 4, !tbaa !5
  %53 = sub nsw i32 %51, %52
  %54 = load i32, ptr @q, align 4, !tbaa !5
  %55 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %53, i32 noundef %54)
  %56 = load i32, ptr @q, align 4, !tbaa !5
  %57 = load i32, ptr @p, align 4, !tbaa !5
  %58 = shl i32 %57, 1
  %59 = icmp sge i32 %56, %58
  %60 = zext i1 %59 to i64
  %61 = select i1 %59, ptr @.str.2, ptr @.str.3
  %62 = call i32 @puts(ptr noundef %61)
  br label %5, !llvm.loop !12

63:                                               ; preds = %5
  ret i32 0
}

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

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

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

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

declare i32 @puts(ptr noundef) #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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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}
!12 = distinct !{!12, !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"

@t = external dso_local global i32, align 4
@p = external dso_local global i32, align 4
@q = external dso_local local_unnamed_addr global i32, align 4
@v = external dso_local global [7 x i32], align 16
@a = external dso_local global i32, align 4
@r = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [27 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z3gcdii(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 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
  %.not10 = icmp eq i32 %2, 0
  br i1 %.not10, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %.lr.ph
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @p)
  %5 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @v)
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @v, i64 4))
  %7 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @v, i64 8))
  %8 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @v, i64 12))
  %9 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @v, i64 16))
  %10 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @v, i64 20))
  %11 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @v, i64 24))
  store i32 0, ptr @q, align 4, !tbaa !5
  %12 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @a)
  %13 = load i32, ptr @v, align 16, !tbaa !5
  %14 = load i32, ptr @a, align 4, !tbaa !5
  %15 = mul nsw i32 %14, %13
  %16 = load i32, ptr @q, align 4, !tbaa !5
  %17 = add nsw i32 %16, %15
  store i32 %17, ptr @q, align 4, !tbaa !5
  %18 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @a)
  %19 = load i32, ptr getelementptr inbounds (i8, ptr @v, i64 4), align 4, !tbaa !5
  %20 = load i32, ptr @a, align 4, !tbaa !5
  %21 = mul nsw i32 %20, %19
  %22 = load i32, ptr @q, align 4, !tbaa !5
  %23 = add nsw i32 %22, %21
  store i32 %23, ptr @q, align 4, !tbaa !5
  %24 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @a)
  %25 = load i32, ptr getelementptr inbounds (i8, ptr @v, i64 8), align 8, !tbaa !5
  %26 = load i32, ptr @a, align 4, !tbaa !5
  %27 = mul nsw i32 %26, %25
  %28 = load i32, ptr @q, align 4, !tbaa !5
  %29 = add nsw i32 %28, %27
  store i32 %29, ptr @q, align 4, !tbaa !5
  %30 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @a)
  %31 = load i32, ptr getelementptr inbounds (i8, ptr @v, i64 12), align 4, !tbaa !5
  %32 = load i32, ptr @a, align 4, !tbaa !5
  %33 = mul nsw i32 %32, %31
  %34 = load i32, ptr @q, align 4, !tbaa !5
  %35 = add nsw i32 %34, %33
  store i32 %35, ptr @q, align 4, !tbaa !5
  %36 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @a)
  %37 = load i32, ptr getelementptr inbounds (i8, ptr @v, i64 16), align 16, !tbaa !5
  %38 = load i32, ptr @a, align 4, !tbaa !5
  %39 = mul nsw i32 %38, %37
  %40 = load i32, ptr @q, align 4, !tbaa !5
  %41 = add nsw i32 %40, %39
  store i32 %41, ptr @q, align 4, !tbaa !5
  %42 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @a)
  %43 = load i32, ptr getelementptr inbounds (i8, ptr @v, i64 20), align 4, !tbaa !5
  %44 = load i32, ptr @a, align 4, !tbaa !5
  %45 = mul nsw i32 %44, %43
  %46 = load i32, ptr @q, align 4, !tbaa !5
  %47 = add nsw i32 %46, %45
  store i32 %47, ptr @q, align 4, !tbaa !5
  %48 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @a)
  %49 = load i32, ptr getelementptr inbounds (i8, ptr @v, i64 24), align 8, !tbaa !5
  %50 = load i32, ptr @a, align 4, !tbaa !5
  %51 = mul nsw i32 %50, %49
  %52 = load i32, ptr @q, align 4, !tbaa !5
  %53 = add nsw i32 %52, %51
  store i32 %53, ptr @q, align 4, !tbaa !5
  %54 = load i32, ptr @p, align 4, !tbaa !5
  %55 = tail call noundef i32 @_Z3gcdii(i32 noundef %54, i32 noundef %53)
  store i32 %55, ptr @r, align 4, !tbaa !5
  %56 = load i32, ptr @p, align 4, !tbaa !5
  %57 = sdiv i32 %56, %55
  store i32 %57, ptr @p, align 4, !tbaa !5
  %58 = load i32, ptr @q, align 4, !tbaa !5
  %59 = sdiv i32 %58, %55
  store i32 %59, ptr @q, align 4, !tbaa !5
  %60 = sub nsw i32 %59, %57
  %61 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %60, i32 noundef %59)
  %62 = load i32, ptr @q, align 4, !tbaa !5
  %63 = load i32, ptr @p, align 4, !tbaa !5
  %64 = shl i32 %63, 1
  %.not7 = icmp slt i32 %62, %64
  %65 = select i1 %.not7, ptr @.str.3, ptr @.str.2
  %66 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) %65)
  %67 = load i32, ptr @t, align 4, !tbaa !5
  %68 = add nsw i32 %67, -1
  store i32 %68, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %67, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._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 #2

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

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) 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 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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