; LLVM IR from DionysiosB/CodeForces :: 0300-0399 (328A-IQTest)

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

7:                                                ; preds = %17, %0
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = icmp slt i32 %8, 4
  br i1 %9, label %11, label %10

10:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %20

11:                                               ; preds = %7
  %12 = getelementptr inbounds [4 x i32], ptr %2, i64 0, i64 0
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds i32, ptr %12, i64 %14
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %15)
  br label %17

17:                                               ; preds = %11
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr %3, align 4, !tbaa !5
  br label %7, !llvm.loop !9

20:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %21 = getelementptr inbounds [4 x i32], ptr %2, i64 0, i64 1
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = getelementptr inbounds [4 x i32], ptr %2, i64 0, i64 0
  %24 = load i32, ptr %23, align 16, !tbaa !5
  %25 = sub nsw i32 %22, %24
  store i32 %25, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %26 = getelementptr inbounds [4 x i32], ptr %2, i64 0, i64 1
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = sitofp i32 %27 to double
  %29 = fmul double 1.000000e+00, %28
  %30 = getelementptr inbounds [4 x i32], ptr %2, i64 0, i64 0
  %31 = load i32, ptr %30, align 16, !tbaa !5
  %32 = sitofp i32 %31 to double
  %33 = fdiv double %29, %32
  store double %33, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store double 0.000000e+00, ptr %6, align 8, !tbaa !11
  %34 = getelementptr inbounds [4 x i32], ptr %2, i64 0, i64 2
  %35 = load i32, ptr %34, align 8, !tbaa !5
  %36 = getelementptr inbounds [4 x i32], ptr %2, i64 0, i64 1
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = sub nsw i32 %35, %37
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = icmp eq i32 %38, %39
  br i1 %40, label %41, label %55

41:                                               ; preds = %20
  %42 = getelementptr inbounds [4 x i32], ptr %2, i64 0, i64 3
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = getelementptr inbounds [4 x i32], ptr %2, i64 0, i64 2
  %45 = load i32, ptr %44, align 8, !tbaa !5
  %46 = sub nsw i32 %43, %45
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = icmp eq i32 %46, %47
  br i1 %48, label %49, label %55

49:                                               ; preds = %41
  %50 = getelementptr inbounds [4 x i32], ptr %2, i64 0, i64 3
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = load i32, ptr %4, align 4, !tbaa !5
  %53 = add nsw i32 %51, %52
  %54 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %53)
  br label %95

55:                                               ; preds = %41, %20
  %56 = getelementptr inbounds [4 x i32], ptr %2, i64 0, i64 2
  %57 = load i32, ptr %56, align 8, !tbaa !5
  %58 = sitofp i32 %57 to double
  %59 = fmul double 1.000000e+00, %58
  %60 = getelementptr inbounds [4 x i32], ptr %2, i64 0, i64 1
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = sitofp i32 %61 to double
  %63 = fdiv double %59, %62
  %64 = load double, ptr %5, align 8, !tbaa !11
  %65 = fcmp oeq double %63, %64
  br i1 %65, label %66, label %92

66:                                               ; preds = %55
  %67 = getelementptr inbounds [4 x i32], ptr %2, i64 0, i64 3
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = sitofp i32 %68 to double
  %70 = fmul double 1.000000e+00, %69
  %71 = getelementptr inbounds [4 x i32], ptr %2, i64 0, i64 2
  %72 = load i32, ptr %71, align 8, !tbaa !5
  %73 = sitofp i32 %72 to double
  %74 = fdiv double %70, %73
  %75 = load double, ptr %5, align 8, !tbaa !11
  %76 = fcmp oeq double %74, %75
  br i1 %76, label %77, label %92

77:                                               ; preds = %66
  %78 = load double, ptr %5, align 8, !tbaa !11
  %79 = getelementptr inbounds [4 x i32], ptr %2, i64 0, i64 3
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %81 = sitofp i32 %80 to double
  %82 = fmul double %78, %81
  %83 = call double @modf(double noundef %82, ptr noundef %6) #5
  %84 = fcmp oeq double %83, 0.000000e+00
  br i1 %84, label %85, label %92

85:                                               ; preds = %77
  %86 = getelementptr inbounds [4 x i32], ptr %2, i64 0, i64 3
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = sitofp i32 %87 to double
  %89 = load double, ptr %5, align 8, !tbaa !11
  %90 = fmul double %88, %89
  %91 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, double noundef %90)
  br label %94

92:                                               ; preds = %77, %66, %55
  %93 = call i32 @puts(ptr noundef @.str.2)
  br label %94

94:                                               ; preds = %92, %85
  br label %95

95:                                               ; preds = %94, %49
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %2) #5
  ret i32 0
}

; 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 @printf(ptr noundef, ...) #3

; Function Attrs: nounwind
declare double @modf(double noundef, ptr noundef) #4

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

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


; 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 [7 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 [4 x i32], align 16
  %2 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %1, i8 0, i64 16, i1 false)
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %4 = getelementptr inbounds i8, ptr %1, i64 4
  %5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %4)
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %6)
  %8 = getelementptr inbounds i8, ptr %1, i64 12
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %8)
  %10 = load i32, ptr %4, align 4, !tbaa !5
  %11 = load i32, ptr %1, align 16, !tbaa !5
  %12 = sub nsw i32 %10, %11
  %13 = sitofp i32 %10 to double
  %14 = sitofp i32 %11 to double
  %15 = fdiv double %13, %14
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  %16 = load i32, ptr %6, align 8, !tbaa !5
  %17 = sub nsw i32 %16, %10
  %18 = icmp eq i32 %17, %12
  br i1 %18, label %19, label %26

19:                                               ; preds = %0
  %20 = load i32, ptr %8, align 4, !tbaa !5
  %21 = sub nsw i32 %20, %16
  %22 = icmp eq i32 %21, %12
  br i1 %22, label %23, label %26

23:                                               ; preds = %19
  %24 = add nsw i32 %20, %12
  %25 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %24)
  br label %43

26:                                               ; preds = %19, %0
  %27 = sitofp i32 %16 to double
  %28 = fdiv double %27, %13
  %29 = fcmp oeq double %28, %15
  br i1 %29, label %30, label %41

30:                                               ; preds = %26
  %31 = load i32, ptr %8, align 4, !tbaa !5
  %32 = sitofp i32 %31 to double
  %33 = fdiv double %32, %27
  %34 = fcmp oeq double %33, %15
  br i1 %34, label %35, label %41

35:                                               ; preds = %30
  %36 = fmul double %15, %32
  %37 = call double @modf(double noundef %36, ptr noundef nonnull %2) #5
  %38 = fcmp oeq double %37, 0.000000e+00
  br i1 %38, label %39, label %41

39:                                               ; preds = %35
  %40 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %36)
  br label %43

41:                                               ; preds = %35, %30, %26
  %42 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %43

43:                                               ; preds = %39, %41, %23
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 16, 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: 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 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: write)
declare double @modf(double noundef, ptr nocapture noundef) local_unnamed_addr #4

; 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 = { mustprogress nofree nounwind willreturn memory(argmem: write) "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 }

!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"}


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