; LLVM IR from DionysiosB/CodeForces :: 0300-0399 (349A-CinemaLine)

; 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 [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 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 [3 x i64], align 16
  %4 = alloca i8, align 1
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  store i64 0, ptr %2, align 8, !tbaa !5
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  call void @llvm.lifetime.start.p0(i64 24, ptr %3) #4
  call void @llvm.memset.p0.i64(ptr align 16 %3, i8 0, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #4
  store i8 1, ptr %4, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !11
  br label %9

9:                                                ; preds = %66, %0
  %10 = load i32, ptr %5, align 4, !tbaa !11
  %11 = sext i32 %10 to i64
  %12 = load i64, ptr %2, align 8, !tbaa !5
  %13 = icmp slt i64 %11, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %9
  store i32 2, ptr %6, align 4
  br label %69

15:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !11
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %7)
  %17 = load i32, ptr %7, align 4, !tbaa !11
  %18 = icmp eq i32 %17, 25
  br i1 %18, label %19, label %23

19:                                               ; preds = %15
  %20 = getelementptr inbounds [3 x i64], ptr %3, i64 0, i64 0
  %21 = load i64, ptr %20, align 16, !tbaa !5
  %22 = add nsw i64 %21, 1
  store i64 %22, ptr %20, align 16, !tbaa !5
  br label %57

23:                                               ; preds = %15
  %24 = load i32, ptr %7, align 4, !tbaa !11
  %25 = icmp eq i32 %24, 50
  br i1 %25, label %26, label %33

26:                                               ; preds = %23
  %27 = getelementptr inbounds [3 x i64], ptr %3, i64 0, i64 0
  %28 = load i64, ptr %27, align 16, !tbaa !5
  %29 = add nsw i64 %28, -1
  store i64 %29, ptr %27, align 16, !tbaa !5
  %30 = getelementptr inbounds [3 x i64], ptr %3, i64 0, i64 1
  %31 = load i64, ptr %30, align 8, !tbaa !5
  %32 = add nsw i64 %31, 1
  store i64 %32, ptr %30, align 8, !tbaa !5
  br label %56

33:                                               ; preds = %23
  %34 = load i32, ptr %7, align 4, !tbaa !11
  %35 = icmp eq i32 %34, 100
  br i1 %35, label %36, label %55

36:                                               ; preds = %33
  %37 = getelementptr inbounds [3 x i64], ptr %3, i64 0, i64 2
  %38 = load i64, ptr %37, align 16, !tbaa !5
  %39 = add nsw i64 %38, 1
  store i64 %39, ptr %37, align 16, !tbaa !5
  %40 = getelementptr inbounds [3 x i64], ptr %3, i64 0, i64 1
  %41 = load i64, ptr %40, align 8, !tbaa !5
  %42 = icmp sgt i64 %41, 0
  br i1 %42, label %43, label %50

43:                                               ; preds = %36
  %44 = getelementptr inbounds [3 x i64], ptr %3, i64 0, i64 1
  %45 = load i64, ptr %44, align 8, !tbaa !5
  %46 = add nsw i64 %45, -1
  store i64 %46, ptr %44, align 8, !tbaa !5
  %47 = getelementptr inbounds [3 x i64], ptr %3, i64 0, i64 0
  %48 = load i64, ptr %47, align 16, !tbaa !5
  %49 = add nsw i64 %48, -1
  store i64 %49, ptr %47, align 16, !tbaa !5
  br label %54

50:                                               ; preds = %36
  %51 = getelementptr inbounds [3 x i64], ptr %3, i64 0, i64 0
  %52 = load i64, ptr %51, align 16, !tbaa !5
  %53 = sub nsw i64 %52, 3
  store i64 %53, ptr %51, align 16, !tbaa !5
  br label %54

54:                                               ; preds = %50, %43
  br label %55

55:                                               ; preds = %54, %33
  br label %56

56:                                               ; preds = %55, %26
  br label %57

57:                                               ; preds = %56, %19
  %58 = getelementptr inbounds [3 x i64], ptr %3, i64 0, i64 0
  %59 = load i64, ptr %58, align 16, !tbaa !5
  %60 = icmp slt i64 %59, 0
  br i1 %60, label %61, label %62

61:                                               ; preds = %57
  store i8 0, ptr %4, align 1, !tbaa !9
  store i32 2, ptr %6, align 4
  br label %63

62:                                               ; preds = %57
  store i32 0, ptr %6, align 4
  br label %63

63:                                               ; preds = %62, %61
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  %64 = load i32, ptr %6, align 4
  switch i32 %64, label %69 [
    i32 0, label %65
  ]

65:                                               ; preds = %63
  br label %66

66:                                               ; preds = %65
  %67 = load i32, ptr %5, align 4, !tbaa !11
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %5, align 4, !tbaa !11
  br label %9, !llvm.loop !13

69:                                               ; preds = %63, %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %70

70:                                               ; preds = %69
  %71 = load i8, ptr %4, align 1, !tbaa !9, !range !15, !noundef !16
  %72 = trunc i8 %71 to i1
  br i1 %72, label %73, label %75

73:                                               ; preds = %70
  %74 = call i32 @puts(ptr noundef @.str.2)
  br label %77

75:                                               ; preds = %70
  %76 = call i32 @puts(ptr noundef @.str.3)
  br label %77

77:                                               ; preds = %75, %73
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  %78 = load i32, ptr %1, align 4
  ret i32 %78
}

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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

declare i32 @puts(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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{i8 0, i8 2}
!16 = !{}


; 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 [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #3
  store i64 0, ptr %1, align 8, !tbaa !5
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %4 = load i64, ptr %1, align 8, !tbaa !5
  %.not28 = icmp sgt i64 %4, 0
  br i1 %.not28, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %0, %21
  %indvars.iv = phi i64 [ %indvars.iv.next, %21 ], [ 0, %0 ]
  %.sroa.12.030 = phi i64 [ %.sroa.12.125, %21 ], [ 0, %0 ]
  %.sroa.0.029 = phi i64 [ %.sroa.0.124, %21 ], [ 0, %0 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #3
  store i32 0, ptr %2, align 4, !tbaa !9
  %5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2)
  %6 = load i32, ptr %2, align 4, !tbaa !9
  switch i32 %6, label %.thread [
    i32 25, label %7
    i32 50, label %9
    i32 100, label %12
  ]

7:                                                ; preds = %.lr.ph
  %8 = add nuw nsw i64 %.sroa.0.029, 1
  br label %.thread

9:                                                ; preds = %.lr.ph
  %10 = add nsw i64 %.sroa.0.029, -1
  %11 = add nsw i64 %.sroa.12.030, 1
  br label %19

12:                                               ; preds = %.lr.ph
  %13 = icmp sgt i64 %.sroa.12.030, 0
  br i1 %13, label %14, label %17

14:                                               ; preds = %12
  %15 = add nsw i64 %.sroa.12.030, -1
  %16 = add nsw i64 %.sroa.0.029, -1
  br label %19

17:                                               ; preds = %12
  %18 = add nsw i64 %.sroa.0.029, -3
  br label %19

.thread:                                          ; preds = %7, %.lr.ph
  %.sroa.0.1.ph = phi i64 [ %.sroa.0.029, %.lr.ph ], [ %8, %7 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  br label %21

19:                                               ; preds = %9, %14, %17
  %.sroa.0.1 = phi i64 [ %10, %9 ], [ %16, %14 ], [ %18, %17 ]
  %.sroa.12.1 = phi i64 [ %11, %9 ], [ %15, %14 ], [ %.sroa.12.030, %17 ]
  %20 = icmp sgt i64 %.sroa.0.1, -1
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  br i1 %20, label %21, label %.critedge

21:                                               ; preds = %.thread, %19
  %.sroa.12.125 = phi i64 [ %.sroa.12.030, %.thread ], [ %.sroa.12.1, %19 ]
  %.sroa.0.124 = phi i64 [ %.sroa.0.1.ph, %.thread ], [ %.sroa.0.1, %19 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %22 = load i64, ptr %1, align 8, !tbaa !5
  %.not = icmp sgt i64 %22, %indvars.iv.next
  br i1 %.not, label %.lr.ph, label %.critedge, !llvm.loop !11

.critedge:                                        ; preds = %19, %21, %0
  %.str.3.sink = phi ptr [ @.str.2, %0 ], [ @.str.2, %21 ], [ @.str.3, %19 ]
  %23 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %.str.3.sink)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; 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 @puts(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", !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: BDCEPass,ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass