; LLVM IR from hanzohasashi33/Competetive_programming :: CodeChef/Easy (Chef_And_Feedback)

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

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca [4 x i8], align 1
  %6 = alloca [4 x 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) #6
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  br label %10

10:                                               ; preds = %105, %0
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %13, label %108

13:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  %14 = call noalias ptr @malloc(i64 noundef 100000) #7
  store ptr %14, ptr %4, align 8, !tbaa !9
  %15 = load ptr, ptr %4, align 8, !tbaa !9
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %15)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %5, ptr align 1 @__const.main.ptn1, i64 4, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %6, ptr align 1 @__const.main.ptn2, i64 4, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %54, %13
  %18 = load i32, ptr %7, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = load ptr, ptr %4, align 8, !tbaa !9
  %21 = call i64 @strlen(ptr noundef %20) #8
  %22 = icmp ult i64 %19, %21
  br i1 %22, label %23, label %57

23:                                               ; preds = %17
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %24

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

27:                                               ; preds = %24
  %28 = load ptr, ptr %4, align 8, !tbaa !9
  %29 = load i32, ptr %7, align 4, !tbaa !5
  %30 = load i32, ptr %8, align 4, !tbaa !5
  %31 = add nsw i32 %29, %30
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds i8, ptr %28, i64 %32
  %34 = load i8, ptr %33, align 1, !tbaa !11
  %35 = sext i8 %34 to i32
  %36 = load i32, ptr %8, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [4 x i8], ptr %5, i64 0, i64 %37
  %39 = load i8, ptr %38, align 1, !tbaa !11
  %40 = sext i8 %39 to i32
  %41 = icmp ne i32 %35, %40
  br i1 %41, label %42, label %43

42:                                               ; preds = %27
  br label %47

43:                                               ; preds = %27
  br label %44

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

47:                                               ; preds = %42, %24
  %48 = load i32, ptr %8, align 4, !tbaa !5
  %49 = icmp eq i32 %48, 3
  br i1 %49, label %50, label %53

50:                                               ; preds = %47
  %51 = load i32, ptr %3, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %3, align 4, !tbaa !5
  br label %57

53:                                               ; preds = %47
  br label %54

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

57:                                               ; preds = %50, %17
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %95, %57
  %59 = load i32, ptr %7, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = load ptr, ptr %4, align 8, !tbaa !9
  %62 = call i64 @strlen(ptr noundef %61) #8
  %63 = icmp ult i64 %60, %62
  br i1 %63, label %64, label %98

64:                                               ; preds = %58
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %65

65:                                               ; preds = %85, %64
  %66 = load i32, ptr %8, align 4, !tbaa !5
  %67 = icmp slt i32 %66, 3
  br i1 %67, label %68, label %88

68:                                               ; preds = %65
  %69 = load ptr, ptr %4, align 8, !tbaa !9
  %70 = load i32, ptr %7, align 4, !tbaa !5
  %71 = load i32, ptr %8, align 4, !tbaa !5
  %72 = add nsw i32 %70, %71
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds i8, ptr %69, i64 %73
  %75 = load i8, ptr %74, align 1, !tbaa !11
  %76 = sext i8 %75 to i32
  %77 = load i32, ptr %8, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [4 x i8], ptr %6, i64 0, i64 %78
  %80 = load i8, ptr %79, align 1, !tbaa !11
  %81 = sext i8 %80 to i32
  %82 = icmp ne i32 %76, %81
  br i1 %82, label %83, label %84

83:                                               ; preds = %68
  br label %88

84:                                               ; preds = %68
  br label %85

85:                                               ; preds = %84
  %86 = load i32, ptr %8, align 4, !tbaa !5
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %8, align 4, !tbaa !5
  br label %65, !llvm.loop !15

88:                                               ; preds = %83, %65
  %89 = load i32, ptr %8, align 4, !tbaa !5
  %90 = icmp eq i32 %89, 3
  br i1 %90, label %91, label %94

91:                                               ; preds = %88
  %92 = load i32, ptr %3, align 4, !tbaa !5
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr %3, align 4, !tbaa !5
  br label %98

94:                                               ; preds = %88
  br label %95

95:                                               ; preds = %94
  %96 = load i32, ptr %7, align 4, !tbaa !5
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %7, align 4, !tbaa !5
  br label %58, !llvm.loop !16

98:                                               ; preds = %91, %58
  %99 = load i32, ptr %3, align 4, !tbaa !5
  %100 = icmp sgt i32 %99, 0
  br i1 %100, label %101, label %103

101:                                              ; preds = %98
  %102 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %105

103:                                              ; preds = %98
  %104 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  br label %105

105:                                              ; preds = %103, %101
  %106 = load i32, ptr %2, align 4, !tbaa !5
  %107 = add nsw i32 %106, -1
  store i32 %107, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %10, !llvm.loop !17

108:                                              ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  ret i32 0
}

; 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: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #5

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

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

attributes #0 = { 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 = { 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 = { nounwind allocsize(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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nounwind willreturn memory(read) "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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { nounwind willreturn memory(read) }

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}
!16 = distinct !{!16, !13}
!17 = distinct !{!17, !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 [3 x i8], align 1
@__const.main.ptn1 = external hidden unnamed_addr constant [4 x i8], align 1
@__const.main.ptn2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1

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

.lr.ph.preheader:                                 ; preds = %0
  %.pre = load i8, ptr @__const.main.ptn1, align 1
  %4 = load i8, ptr getelementptr inbounds (i8, ptr @__const.main.ptn1, i64 1), align 1
  %5 = load i8, ptr getelementptr inbounds (i8, ptr @__const.main.ptn1, i64 2), align 1
  %.pre58 = load i8, ptr @__const.main.ptn2, align 1
  %6 = load i8, ptr getelementptr inbounds (i8, ptr @__const.main.ptn2, i64 1), align 1
  %7 = load i8, ptr getelementptr inbounds (i8, ptr @__const.main.ptn2, i64 2), align 1
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.thread29
  %8 = call noalias dereferenceable_or_null(100000) ptr @malloc(i64 noundef 100000) #6
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef %8)
  %10 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %8) #7
  %.not63 = icmp eq i64 %10, 0
  br i1 %.not63, label %._crit_edge43.thread, label %.preheader31.preheader

.preheader31.preheader:                           ; preds = %.lr.ph
  %invariant.gep = getelementptr i8, ptr %8, i64 2
  br label %.preheader31

.preheader31:                                     ; preds = %.preheader31.preheader, %.thread
  %indvars.iv = phi i64 [ 0, %.preheader31.preheader ], [ %14, %.thread ]
  %11 = phi i1 [ true, %.preheader31.preheader ], [ %20, %.thread ]
  %12 = getelementptr inbounds i8, ptr %8, i64 %indvars.iv
  %13 = load i8, ptr %12, align 1, !tbaa !9
  %.not = icmp eq i8 %13, %.pre
  %14 = add nuw i64 %indvars.iv, 1
  br i1 %.not, label %15, label %.thread

15:                                               ; preds = %.preheader31
  %16 = getelementptr inbounds i8, ptr %8, i64 %14
  %17 = load i8, ptr %16, align 1, !tbaa !9
  %.not.1 = icmp eq i8 %17, %4
  br i1 %.not.1, label %18, label %.thread

18:                                               ; preds = %15
  %gep = getelementptr i8, ptr %invariant.gep, i64 %indvars.iv
  %19 = load i8, ptr %gep, align 1, !tbaa !9
  %.not.2 = icmp eq i8 %19, %5
  br i1 %.not.2, label %.preheader.preheader, label %.thread

.thread:                                          ; preds = %.preheader31, %15, %18
  %20 = icmp ugt i64 %10, %14
  %exitcond.not = icmp eq i64 %14, %10
  br i1 %exitcond.not, label %.preheader.preheader, label %.preheader31, !llvm.loop !10

.preheader.preheader:                             ; preds = %.thread, %18
  %.lcssa70 = phi i1 [ %11, %18 ], [ %20, %.thread ]
  %invariant.gep74 = getelementptr i8, ptr %8, i64 2
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %.thread28
  %indvars.iv54 = phi i64 [ 0, %.preheader.preheader ], [ %23, %.thread28 ]
  %21 = getelementptr inbounds i8, ptr %8, i64 %indvars.iv54
  %22 = load i8, ptr %21, align 1, !tbaa !9
  %.not27 = icmp eq i8 %22, %.pre58
  %23 = add nuw i64 %indvars.iv54, 1
  br i1 %.not27, label %24, label %.thread28

24:                                               ; preds = %.preheader
  %25 = getelementptr inbounds i8, ptr %8, i64 %23
  %26 = load i8, ptr %25, align 1, !tbaa !9
  %.not27.1 = icmp eq i8 %26, %6
  br i1 %.not27.1, label %27, label %.thread28

27:                                               ; preds = %24
  %gep75 = getelementptr i8, ptr %invariant.gep74, i64 %indvars.iv54
  %28 = load i8, ptr %gep75, align 1, !tbaa !9
  %.not27.2 = icmp eq i8 %28, %7
  br i1 %.not27.2, label %.thread29, label %.thread28

.thread28:                                        ; preds = %.preheader, %24, %27
  %exitcond57.not = icmp eq i64 %23, %10
  br i1 %exitcond57.not, label %._crit_edge43, label %.preheader, !llvm.loop !12

._crit_edge43:                                    ; preds = %.thread28
  br i1 %.lcssa70, label %.thread29, label %._crit_edge43.thread

._crit_edge43.thread:                             ; preds = %.lr.ph, %._crit_edge43
  br label %.thread29

.thread29:                                        ; preds = %27, %._crit_edge43, %._crit_edge43.thread
  %.str.3.sink = phi ptr [ @.str.3, %._crit_edge43.thread ], [ @.str.2, %._crit_edge43 ], [ @.str.2, %27 ]
  %29 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.3.sink)
  %30 = load i32, ptr %1, align 4, !tbaa !5
  %31 = add nsw i32 %30, -1
  store i32 %31, ptr %1, align 4, !tbaa !5
  %32 = icmp sgt i32 %30, 1
  br i1 %32, label %.lr.ph, label %._crit_edge45, !llvm.loop !13

._crit_edge45:                                    ; preds = %.thread29, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  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 nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @printf(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

attributes #0 = { 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" }
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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }
attributes #7 = { nounwind willreturn memory(read) }

!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/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass