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

; 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 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = 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
  store i32 0, ptr %1, align 4
  br label %4

4:                                                ; preds = %60, %10, %0
  %5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  %6 = icmp eq i32 %5, 1
  br i1 %6, label %7, label %62

7:                                                ; preds = %4
  %8 = load i32, ptr @n, align 4, !tbaa !5
  %9 = icmp eq i32 %8, 1
  br i1 %9, label %10, label %12

10:                                               ; preds = %7
  %11 = call i32 @puts(ptr noundef @.str.1)
  br label %4, !llvm.loop !9

12:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 1, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 2, ptr %3, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %45, %12
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %15 = load i32, ptr @n, align 4, !tbaa !5
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = sdiv i32 %15, %16
  %18 = icmp sle i32 %14, %17
  br i1 %18, label %20, label %19

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

20:                                               ; preds = %13
  %21 = load i32, ptr @n, align 4, !tbaa !5
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = srem i32 %21, %22
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %44

25:                                               ; preds = %20
  br label %26

26:                                               ; preds = %37, %25
  %27 = load i32, ptr @n, align 4, !tbaa !5
  %28 = load i32, ptr %3, align 4, !tbaa !5
  %29 = srem i32 %27, %28
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %31, label %43

31:                                               ; preds = %26
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %36, label %34

34:                                               ; preds = %31
  %35 = call i32 @putchar(i32 noundef 42)
  br label %37

36:                                               ; preds = %31
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %36, %34
  %38 = load i32, ptr %3, align 4, !tbaa !5
  %39 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %38)
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = load i32, ptr @n, align 4, !tbaa !5
  %42 = sdiv i32 %41, %40
  store i32 %42, ptr @n, align 4, !tbaa !5
  br label %26, !llvm.loop !11

43:                                               ; preds = %26
  br label %44

44:                                               ; preds = %43, %20
  br label %45

45:                                               ; preds = %44
  %46 = load i32, ptr %3, align 4, !tbaa !5
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %3, align 4, !tbaa !5
  br label %13, !llvm.loop !12

48:                                               ; preds = %19
  %49 = load i32, ptr @n, align 4, !tbaa !5
  %50 = icmp sgt i32 %49, 1
  br i1 %50, label %51, label %60

51:                                               ; preds = %48
  %52 = load i32, ptr %2, align 4, !tbaa !5
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %56, label %54

54:                                               ; preds = %51
  %55 = call i32 @putchar(i32 noundef 42)
  br label %57

56:                                               ; preds = %51
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %57

57:                                               ; preds = %56, %54
  %58 = load i32, ptr @n, align 4, !tbaa !5
  %59 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %58)
  br label %60

60:                                               ; preds = %57, %48
  %61 = call i32 @putchar(i32 noundef 10)
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %4, !llvm.loop !9

62:                                               ; preds = %4
  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: inlinehint mustprogress uwtable
declare i32 @putchar(i32 noundef) #3

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

; 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 = { inlinehint 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 #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"

@n = 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 [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 @n)
  %2 = icmp eq i32 %1, 1
  br i1 %2, label %.lr.ph21, label %._crit_edge22

.lr.ph21:                                         ; preds = %0, %.backedge
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %4 = icmp eq i32 %3, 1
  br i1 %4, label %5, label %.preheader12

.preheader12:                                     ; preds = %.lr.ph21
  %.not14 = icmp slt i32 %3, 4
  br i1 %.not14, label %._crit_edge.thread, label %.lr.ph18

5:                                                ; preds = %.lr.ph21
  %6 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %.backedge

.backedge:                                        ; preds = %5, %34
  %7 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %8 = icmp eq i32 %7, 1
  br i1 %8, label %.lr.ph21, label %._crit_edge22, !llvm.loop !9

._crit_edge:                                      ; preds = %.loopexit
  %9 = icmp sgt i32 %.pr, 1
  br i1 %9, label %29, label %34

._crit_edge.thread:                               ; preds = %.preheader12
  %10 = icmp sgt i32 %3, 1
  br i1 %10, label %.thread, label %34

.lr.ph18:                                         ; preds = %.preheader12, %.loopexit
  %.pr24 = phi i32 [ %.pr, %.loopexit ], [ %3, %.preheader12 ]
  %.016 = phi i32 [ %27, %.loopexit ], [ 2, %.preheader12 ]
  %.0915 = phi i32 [ %.3, %.loopexit ], [ 1, %.preheader12 ]
  %11 = srem i32 %.pr24, %.016
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %.lr.ph18
  %.not11.peel = icmp eq i32 %.0915, 0
  br i1 %.not11.peel, label %13, label %15

13:                                               ; preds = %.lr.ph.preheader
  %14 = tail call i32 @putchar(i32 noundef 42)
  br label %15

15:                                               ; preds = %13, %.lr.ph.preheader
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %.016)
  %17 = load i32, ptr @n, align 4, !tbaa !5
  %18 = sdiv i32 %17, %.016
  store i32 %18, ptr @n, align 4, !tbaa !5
  %19 = srem i32 %18, %.016
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %.lr.ph.peel.next, label %.loopexit

.lr.ph.peel.next:                                 ; preds = %15, %.lr.ph.peel.next
  %21 = tail call i32 @putchar(i32 noundef 42)
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %.016)
  %23 = load i32, ptr @n, align 4, !tbaa !5
  %24 = sdiv i32 %23, %.016
  store i32 %24, ptr @n, align 4, !tbaa !5
  %25 = srem i32 %24, %.016
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %.lr.ph.peel.next, label %.loopexit, !llvm.loop !11

.loopexit:                                        ; preds = %.lr.ph.peel.next, %15, %.lr.ph18
  %.pr = phi i32 [ %.pr24, %.lr.ph18 ], [ %18, %15 ], [ %24, %.lr.ph.peel.next ]
  %.3 = phi i32 [ %.0915, %.lr.ph18 ], [ 0, %15 ], [ 0, %.lr.ph.peel.next ]
  %27 = add nuw nsw i32 %.016, 1
  %28 = sdiv i32 %.pr, %27
  %.not.not = icmp slt i32 %.016, %28
  br i1 %.not.not, label %.lr.ph18, label %._crit_edge, !llvm.loop !13

29:                                               ; preds = %._crit_edge
  %.not10 = icmp eq i32 %.3, 0
  br i1 %.not10, label %30, label %.thread

30:                                               ; preds = %29
  %31 = tail call i32 @putchar(i32 noundef 42)
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %.thread

.thread:                                          ; preds = %._crit_edge.thread, %29, %30
  %32 = phi i32 [ %.pr, %29 ], [ %.pre, %30 ], [ %3, %._crit_edge.thread ]
  %33 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %32)
  br label %34

34:                                               ; preds = %._crit_edge.thread, %.thread, %._crit_edge
  %35 = tail call i32 @putchar(i32 noundef 10)
  br label %.backedge

._crit_edge22:                                    ; 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

; Function Attrs: inlinehint mustprogress nofree nounwind uwtable
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @printf(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" }
attributes #2 = { inlinehint mustprogress nofree 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" }

!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}
!12 = !{!"llvm.loop.peeled.count", i32 1}
!13 = distinct !{!13, !10}


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