; LLVM IR from DionysiosB/CodeForces :: 0001-0099 (12A-SuperAgent)

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

9:                                                ; preds = %32, %0
  %10 = load i32, ptr %4, align 4, !tbaa !5
  %11 = icmp slt i32 %10, 9
  br i1 %11, label %12, label %33

12:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #4
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %5)
  %14 = load i8, ptr %5, align 1, !tbaa !9
  %15 = sext i8 %14 to i32
  %16 = icmp eq i32 %15, 88
  br i1 %16, label %17, label %22

17:                                               ; preds = %12
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr %4, align 4, !tbaa !5
  %20 = sext i32 %18 to i64
  %21 = getelementptr inbounds [9 x i8], ptr %3, i64 0, i64 %20
  store i8 1, ptr %21, align 1, !tbaa !10
  br label %32

22:                                               ; preds = %12
  %23 = load i8, ptr %5, align 1, !tbaa !9
  %24 = sext i8 %23 to i32
  %25 = icmp eq i32 %24, 46
  br i1 %25, label %26, label %31

26:                                               ; preds = %22
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %4, align 4, !tbaa !5
  %29 = sext i32 %27 to i64
  %30 = getelementptr inbounds [9 x i8], ptr %3, i64 0, i64 %29
  store i8 0, ptr %30, align 1, !tbaa !10
  br label %31

31:                                               ; preds = %26, %22
  br label %32

32:                                               ; preds = %31, %17
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #4
  br label %9, !llvm.loop !12

33:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #4
  store i8 1, ptr %6, align 1, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %55, %33
  %35 = load i32, ptr %7, align 4, !tbaa !5
  %36 = icmp slt i32 %35, 9
  br i1 %36, label %38, label %37

37:                                               ; preds = %34
  store i32 4, ptr %8, align 4
  br label %58

38:                                               ; preds = %34
  %39 = load i32, ptr %7, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [9 x i8], ptr %3, i64 0, i64 %40
  %42 = load i8, ptr %41, align 1, !tbaa !10, !range !14, !noundef !15
  %43 = trunc i8 %42 to i1
  %44 = zext i1 %43 to i32
  %45 = load i32, ptr %7, align 4, !tbaa !5
  %46 = sub nsw i32 8, %45
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [9 x i8], ptr %3, i64 0, i64 %47
  %49 = load i8, ptr %48, align 1, !tbaa !10, !range !14, !noundef !15
  %50 = trunc i8 %49 to i1
  %51 = zext i1 %50 to i32
  %52 = icmp ne i32 %44, %51
  br i1 %52, label %53, label %54

53:                                               ; preds = %38
  store i8 0, ptr %6, align 1, !tbaa !10
  store i32 4, ptr %8, align 4
  br label %58

54:                                               ; preds = %38
  br label %55

55:                                               ; preds = %54
  %56 = load i32, ptr %7, align 4, !tbaa !5
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %7, align 4, !tbaa !5
  br label %34, !llvm.loop !16

58:                                               ; preds = %53, %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %59

59:                                               ; preds = %58
  %60 = load i8, ptr %6, align 1, !tbaa !10, !range !14, !noundef !15
  %61 = trunc i8 %60 to i1
  br i1 %61, label %62, label %64

62:                                               ; preds = %59
  %63 = call i32 @puts(ptr noundef @.str.1)
  br label %66

64:                                               ; preds = %59
  %65 = call i32 @puts(ptr noundef @.str.2)
  br label %66

66:                                               ; preds = %64, %62
  store i32 0, ptr %1, align 4
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 9, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  %67 = load i32, ptr %1, align 4
  ret i32 %67
}

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

declare i32 @__isoc99_scanf(ptr noundef, ...) #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) #3

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


; 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 [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = 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 [9 x i8], align 1
  %2 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 9, ptr nonnull %1) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(9) %1, i8 0, i64 9, i1 false)
  br label %3

3:                                                ; preds = %0, %10
  %.01012 = phi i32 [ 0, %0 ], [ %.1, %10 ]
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %2) #4
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %2)
  %5 = load i8, ptr %2, align 1, !tbaa !5
  switch i8 %5, label %10 [
    i8 88, label %.sink.split
    i8 46, label %6
  ]

6:                                                ; preds = %3
  br label %.sink.split

.sink.split:                                      ; preds = %3, %6
  %.sink = phi i8 [ 0, %6 ], [ 1, %3 ]
  %7 = add nsw i32 %.01012, 1
  %8 = sext i32 %.01012 to i64
  %9 = getelementptr inbounds [9 x i8], ptr %1, i64 0, i64 %8
  store i8 %.sink, ptr %9, align 1, !tbaa !8
  br label %10

10:                                               ; preds = %.sink.split, %3
  %.1 = phi i32 [ %.01012, %3 ], [ %7, %.sink.split ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %2) #4
  %11 = icmp slt i32 %.1, 9
  br i1 %11, label %3, label %.preheader.preheader, !llvm.loop !10

.preheader.preheader:                             ; preds = %10
  %12 = load i8, ptr %1, align 1, !tbaa !8, !range !12, !noundef !13
  %13 = getelementptr inbounds i8, ptr %1, i64 8
  %14 = load i8, ptr %13, align 1, !tbaa !8, !range !12, !noundef !13
  %.not = icmp eq i8 %12, %14
  br i1 %.not, label %.preheader.1, label %27

.preheader.1:                                     ; preds = %.preheader.preheader
  %15 = getelementptr inbounds i8, ptr %1, i64 1
  %16 = load i8, ptr %15, align 1, !tbaa !8, !range !12, !noundef !13
  %17 = getelementptr inbounds i8, ptr %1, i64 7
  %18 = load i8, ptr %17, align 1, !tbaa !8, !range !12, !noundef !13
  %.not.1 = icmp eq i8 %16, %18
  br i1 %.not.1, label %.preheader.2, label %27

.preheader.2:                                     ; preds = %.preheader.1
  %19 = getelementptr inbounds i8, ptr %1, i64 2
  %20 = load i8, ptr %19, align 1, !tbaa !8, !range !12, !noundef !13
  %21 = getelementptr inbounds i8, ptr %1, i64 6
  %22 = load i8, ptr %21, align 1, !tbaa !8, !range !12, !noundef !13
  %.not.2 = icmp eq i8 %20, %22
  br i1 %.not.2, label %.preheader.3, label %27

.preheader.3:                                     ; preds = %.preheader.2
  %23 = getelementptr inbounds i8, ptr %1, i64 3
  %24 = load i8, ptr %23, align 1, !tbaa !8, !range !12, !noundef !13
  %25 = getelementptr inbounds i8, ptr %1, i64 5
  %26 = load i8, ptr %25, align 1, !tbaa !8, !range !12, !noundef !13
  %.not.3 = icmp eq i8 %24, %26
  br i1 %.not.3, label %.critedge, label %27

27:                                               ; preds = %.preheader.3, %.preheader.2, %.preheader.1, %.preheader.preheader
  br label %.critedge

.critedge:                                        ; preds = %.preheader.3, %27
  %.str.2.sink = phi ptr [ @.str.2, %27 ], [ @.str.1, %.preheader.3 ]
  %28 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %.str.2.sink)
  call void @llvm.lifetime.end.p0(i64 9, ptr nonnull %1) #4
  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: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

; 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 #3

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


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass