; LLVM IR from ravireddy07/cpp-book :: src/Code-Chef (FLOW014)

; 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 [13 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.8 = 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 double, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca i32, align 4
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  store double 5.000000e+01, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store double 0x3FE6666666666666, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store double 5.600000e+03, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %5)
  br label %10

10:                                               ; preds = %79, %0
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = add nsw i32 %11, -1
  store i32 %12, ptr %5, align 4, !tbaa !9
  %13 = icmp ne i32 %11, 0
  br i1 %13, label %14, label %80

14:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %6, ptr noundef %7, ptr noundef %8)
  %16 = load double, ptr %6, align 8, !tbaa !5
  %17 = fcmp ogt double %16, 5.000000e+01
  br i1 %17, label %18, label %26

18:                                               ; preds = %14
  %19 = load double, ptr %7, align 8, !tbaa !5
  %20 = fcmp olt double %19, 0x3FE6666666666666
  br i1 %20, label %21, label %26

21:                                               ; preds = %18
  %22 = load double, ptr %8, align 8, !tbaa !5
  %23 = fcmp ogt double %22, 5.600000e+03
  br i1 %23, label %24, label %26

24:                                               ; preds = %21
  %25 = call i32 @puts(ptr noundef @.str.2)
  br label %79

26:                                               ; preds = %21, %18, %14
  %27 = load double, ptr %6, align 8, !tbaa !5
  %28 = fcmp ogt double %27, 5.000000e+01
  br i1 %28, label %29, label %34

29:                                               ; preds = %26
  %30 = load double, ptr %7, align 8, !tbaa !5
  %31 = fcmp olt double %30, 0x3FE6666666666666
  br i1 %31, label %32, label %34

32:                                               ; preds = %29
  %33 = call i32 @puts(ptr noundef @.str.3)
  br label %78

34:                                               ; preds = %29, %26
  %35 = load double, ptr %7, align 8, !tbaa !5
  %36 = fcmp olt double %35, 0x3FE6666666666666
  br i1 %36, label %37, label %42

37:                                               ; preds = %34
  %38 = load double, ptr %8, align 8, !tbaa !5
  %39 = fcmp ogt double %38, 5.600000e+03
  br i1 %39, label %40, label %42

40:                                               ; preds = %37
  %41 = call i32 @puts(ptr noundef @.str.4)
  br label %77

42:                                               ; preds = %37, %34
  %43 = load double, ptr %6, align 8, !tbaa !5
  %44 = fcmp ogt double %43, 5.000000e+01
  br i1 %44, label %45, label %50

45:                                               ; preds = %42
  %46 = load double, ptr %8, align 8, !tbaa !5
  %47 = fcmp ogt double %46, 5.600000e+03
  br i1 %47, label %48, label %50

48:                                               ; preds = %45
  %49 = call i32 @puts(ptr noundef @.str.5)
  br label %76

50:                                               ; preds = %45, %42
  %51 = load double, ptr %6, align 8, !tbaa !5
  %52 = fcmp ogt double %51, 5.000000e+01
  br i1 %52, label %59, label %53

53:                                               ; preds = %50
  %54 = load double, ptr %7, align 8, !tbaa !5
  %55 = fcmp olt double %54, 0x3FE6666666666666
  br i1 %55, label %59, label %56

56:                                               ; preds = %53
  %57 = load double, ptr %8, align 8, !tbaa !5
  %58 = fcmp ogt double %57, 5.600000e+03
  br i1 %58, label %59, label %61

59:                                               ; preds = %56, %53, %50
  %60 = call i32 @puts(ptr noundef @.str.6)
  br label %75

61:                                               ; preds = %56
  %62 = load double, ptr %6, align 8, !tbaa !5
  %63 = fcmp ogt double %62, 5.000000e+01
  br i1 %63, label %72, label %64

64:                                               ; preds = %61
  %65 = load double, ptr %7, align 8, !tbaa !5
  %66 = fcmp olt double %65, 0x3FE6666666666666
  br i1 %66, label %72, label %67

67:                                               ; preds = %64
  %68 = load double, ptr %8, align 8, !tbaa !5
  %69 = fcmp ogt double %68, 5.600000e+03
  br i1 %69, label %72, label %70

70:                                               ; preds = %67
  %71 = call i32 @puts(ptr noundef @.str.7)
  br label %74

72:                                               ; preds = %67, %64, %61
  %73 = call i32 @puts(ptr noundef @.str.8)
  br label %74

74:                                               ; preds = %72, %70
  br label %75

75:                                               ; preds = %74, %59
  br label %76

76:                                               ; preds = %75, %48
  br label %77

77:                                               ; preds = %76, %40
  br label %78

78:                                               ; preds = %77, %32
  br label %79

79:                                               ; preds = %78, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %10, !llvm.loop !11

80:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  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

declare i32 @puts(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 = { 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 = { 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 = !{!"double", !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"}


; 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 [13 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = 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 = alloca i32, align 4
  %2 = alloca double, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #3
  %5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %6 = load i32, ptr %1, align 4, !tbaa !5
  %7 = add nsw i32 %6, -1
  store i32 %7, ptr %1, align 4, !tbaa !5
  %.not18 = icmp eq i32 %6, 0
  br i1 %.not18, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %18
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %9 = load double, ptr %2, align 8, !tbaa !9
  %10 = fcmp ogt double %9, 5.000000e+01
  %11 = load double, ptr %3, align 8
  %12 = fcmp olt double %11, 0x3FE6666666666666
  %or.cond = select i1 %10, i1 %12, i1 false
  %13 = load double, ptr %4, align 8
  %14 = fcmp ogt double %13, 5.600000e+03
  %or.cond3 = select i1 %or.cond, i1 %14, i1 false
  %.str.2.mux = select i1 %or.cond3, ptr @.str.2, ptr @.str.3
  br i1 %or.cond, label %18, label %15

15:                                               ; preds = %.lr.ph
  %or.cond7 = select i1 %12, i1 %14, i1 false
  br i1 %or.cond7, label %18, label %16

16:                                               ; preds = %15
  %or.cond9 = select i1 %10, i1 %14, i1 false
  br i1 %or.cond9, label %18, label %17

17:                                               ; preds = %16
  %or.cond11 = select i1 %10, i1 true, i1 %12
  %or.cond13 = select i1 %or.cond11, i1 true, i1 %14
  %.str.6..str.7 = select i1 %or.cond13, ptr @.str.6, ptr @.str.7
  br label %18

18:                                               ; preds = %.lr.ph, %17, %16, %15
  %.str.3.sink = phi ptr [ %.str.2.mux, %.lr.ph ], [ @.str.4, %15 ], [ @.str.5, %16 ], [ %.str.6..str.7, %17 ]
  %19 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %.str.3.sink)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  %20 = load i32, ptr %1, align 4, !tbaa !5
  %21 = add nsw i32 %20, -1
  store i32 %21, ptr %1, align 4, !tbaa !5
  %.not = icmp eq i32 %20, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %18, %0
  call void @llvm.lifetime.end.p0(i64 4, 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: nofree nounwind
declare noundef i32 @puts(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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass