; LLVM IR from upupming/algorithm :: AdvancedLevel_C++/1011. World Cup Betting (20) (main)

; 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"

@__const.main.c = external hidden unnamed_addr constant [4 x i8], align 1
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca [4 x i8], align 1
  %3 = alloca double, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca double, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %2, ptr align 1 @__const.main.c, i64 4, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  store double 1.000000e+00, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %41, %0
  %11 = load i32, ptr %4, align 4, !tbaa !9
  %12 = icmp slt i32 %11, 3
  br i1 %12, label %14, label %13

13:                                               ; preds = %10
  store i32 2, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %44

14:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store double 0.000000e+00, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %15

15:                                               ; preds = %28, %14
  %16 = load i32, ptr %8, align 4, !tbaa !9
  %17 = icmp slt i32 %16, 3
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %31

19:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %9)
  %21 = load double, ptr %6, align 8, !tbaa !5
  %22 = load double, ptr %9, align 8, !tbaa !5
  %23 = fcmp ole double %21, %22
  br i1 %23, label %24, label %27

24:                                               ; preds = %19
  %25 = load double, ptr %9, align 8, !tbaa !5
  store double %25, ptr %6, align 8, !tbaa !5
  %26 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %26, ptr %7, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %24, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %28

28:                                               ; preds = %27
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %8, align 4, !tbaa !9
  br label %15, !llvm.loop !11

31:                                               ; preds = %18
  %32 = load double, ptr %6, align 8, !tbaa !5
  %33 = load double, ptr %3, align 8, !tbaa !5
  %34 = fmul double %33, %32
  store double %34, ptr %3, align 8, !tbaa !5
  %35 = load i32, ptr %7, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [4 x i8], ptr %2, i64 0, i64 %36
  %38 = load i8, ptr %37, align 1, !tbaa !13
  %39 = sext i8 %38 to i32
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %39)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %41

41:                                               ; preds = %31
  %42 = load i32, ptr %4, align 4, !tbaa !9
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %4, align 4, !tbaa !9
  br label %10, !llvm.loop !14

44:                                               ; preds = %13
  %45 = load double, ptr %3, align 8, !tbaa !5
  %46 = call double @llvm.fmuladd.f64(double %45, double 6.500000e-01, double -1.000000e+00)
  %47 = fmul double %46, 2.000000e+00
  %48 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, double noundef %47)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  %49 = load i32, ptr %1, align 4
  ret i32 %49
}

; 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: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, 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 @printf(ptr noundef, ...) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #4

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: readwrite) }
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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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"}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !12}


; 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"

@__const.main.c = external hidden unnamed_addr constant [4 x i8], align 1
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
.preheader:
  %0 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %0) #4
  %1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %0)
  %2 = load double, ptr %0, align 8, !tbaa !5
  %.inv = fcmp oge double %2, 0.000000e+00
  %.112 = select i1 %.inv, double %2, double 0.000000e+00
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %0) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %0) #4
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %0)
  %4 = load double, ptr %0, align 8, !tbaa !5
  %5 = fcmp ole double %.112, %4
  %.112.1 = select i1 %5, double %4, double %.112
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %0) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %0) #4
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %0)
  %7 = load double, ptr %0, align 8, !tbaa !5
  %8 = fcmp ugt double %.112.1, %7
  %.112.2 = select i1 %8, double %.112.1, double %7
  %9 = zext i1 %5 to i64
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %0) #4
  %10 = select i1 %8, i64 %9, i64 2
  %11 = getelementptr inbounds [4 x i8], ptr @__const.main.c, i64 0, i64 %10
  %12 = load i8, ptr %11, align 1, !tbaa !9
  %13 = sext i8 %12 to i32
  %14 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %13)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %0) #4
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %0)
  %16 = load double, ptr %0, align 8, !tbaa !5
  %.inv23 = fcmp oge double %16, 0.000000e+00
  %.112.121 = select i1 %.inv23, double %16, double 0.000000e+00
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %0) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %0) #4
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %0)
  %18 = load double, ptr %0, align 8, !tbaa !5
  %19 = fcmp ole double %.112.121, %18
  %.112.1.1 = select i1 %19, double %18, double %.112.121
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %0) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %0) #4
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %0)
  %21 = load double, ptr %0, align 8, !tbaa !5
  %22 = fcmp ugt double %.112.1.1, %21
  %.112.2.1 = select i1 %22, double %.112.1.1, double %21
  %23 = zext i1 %19 to i64
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %0) #4
  %24 = fmul double %.112.2, %.112.2.1
  %25 = select i1 %22, i64 %23, i64 2
  %26 = getelementptr inbounds [4 x i8], ptr @__const.main.c, i64 0, i64 %25
  %27 = load i8, ptr %26, align 1, !tbaa !9
  %28 = sext i8 %27 to i32
  %29 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %28)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %0) #4
  %30 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %0)
  %31 = load double, ptr %0, align 8, !tbaa !5
  %.inv24 = fcmp oge double %31, 0.000000e+00
  %.112.222 = select i1 %.inv24, double %31, double 0.000000e+00
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %0) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %0) #4
  %32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %0)
  %33 = load double, ptr %0, align 8, !tbaa !5
  %34 = fcmp ole double %.112.222, %33
  %.112.1.2 = select i1 %34, double %33, double %.112.222
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %0) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %0) #4
  %35 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %0)
  %36 = load double, ptr %0, align 8, !tbaa !5
  %37 = fcmp ugt double %.112.1.2, %36
  %.112.2.2 = select i1 %37, double %.112.1.2, double %36
  %38 = zext i1 %34 to i64
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %0) #4
  %39 = fmul double %24, %.112.2.2
  %40 = select i1 %37, i64 %38, i64 2
  %41 = getelementptr inbounds [4 x i8], ptr @__const.main.c, i64 0, i64 %40
  %42 = load i8, ptr %41, align 1, !tbaa !9
  %43 = sext i8 %42 to i32
  %44 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %43)
  %45 = call double @llvm.fmuladd.f64(double %39, double 6.500000e-01, double -1.000000e+00)
  %46 = fmul double %45, 2.000000e+00
  %47 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, double noundef %46)
  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 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #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 = { 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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass