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

; 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 [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z3Nc3x(i64 noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store i64 0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store i64 0, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store i64 0, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store i64 0, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store i64 0, ptr %7, align 8, !tbaa !5
  br label %9

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

13:                                               ; preds = %9
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %6, ptr noundef %3, ptr noundef %4, ptr noundef %5)
  %15 = load i64, ptr %6, align 8, !tbaa !5
  %16 = call noundef i64 @_Z3Nc3x(i64 noundef %15)
  %17 = load i64, ptr %6, align 8, !tbaa !5
  %18 = load i64, ptr %3, align 8, !tbaa !5
  %19 = sub nsw i64 %17, %18
  %20 = sub nsw i64 %19, 1
  %21 = call noundef i64 @_Z3Nc3x(i64 noundef %20)
  %22 = sub nsw i64 %16, %21
  %23 = load i64, ptr %6, align 8, !tbaa !5
  %24 = load i64, ptr %4, align 8, !tbaa !5
  %25 = sub nsw i64 %23, %24
  %26 = sub nsw i64 %25, 1
  %27 = call noundef i64 @_Z3Nc3x(i64 noundef %26)
  %28 = sub nsw i64 %22, %27
  %29 = load i64, ptr %6, align 8, !tbaa !5
  %30 = load i64, ptr %5, align 8, !tbaa !5
  %31 = sub nsw i64 %29, %30
  %32 = sub nsw i64 %31, 1
  %33 = call noundef i64 @_Z3Nc3x(i64 noundef %32)
  %34 = sub nsw i64 %28, %33
  %35 = load i64, ptr %6, align 8, !tbaa !5
  %36 = load i64, ptr %3, align 8, !tbaa !5
  %37 = sub nsw i64 %35, %36
  %38 = load i64, ptr %4, align 8, !tbaa !5
  %39 = sub nsw i64 %37, %38
  %40 = sub nsw i64 %39, 2
  %41 = call noundef i64 @_Z3Nc3x(i64 noundef %40)
  %42 = add nsw i64 %34, %41
  %43 = load i64, ptr %6, align 8, !tbaa !5
  %44 = load i64, ptr %4, align 8, !tbaa !5
  %45 = sub nsw i64 %43, %44
  %46 = load i64, ptr %5, align 8, !tbaa !5
  %47 = sub nsw i64 %45, %46
  %48 = sub nsw i64 %47, 2
  %49 = call noundef i64 @_Z3Nc3x(i64 noundef %48)
  %50 = add nsw i64 %42, %49
  %51 = load i64, ptr %6, align 8, !tbaa !5
  %52 = load i64, ptr %3, align 8, !tbaa !5
  %53 = sub nsw i64 %51, %52
  %54 = load i64, ptr %5, align 8, !tbaa !5
  %55 = sub nsw i64 %53, %54
  %56 = sub nsw i64 %55, 2
  %57 = call noundef i64 @_Z3Nc3x(i64 noundef %56)
  %58 = add nsw i64 %50, %57
  %59 = load i64, ptr %6, align 8, !tbaa !5
  %60 = load i64, ptr %3, align 8, !tbaa !5
  %61 = sub nsw i64 %59, %60
  %62 = load i64, ptr %4, align 8, !tbaa !5
  %63 = sub nsw i64 %61, %62
  %64 = load i64, ptr %5, align 8, !tbaa !5
  %65 = sub nsw i64 %63, %64
  %66 = sub nsw i64 %65, 3
  %67 = call noundef i64 @_Z3Nc3x(i64 noundef %66)
  %68 = sub nsw i64 %58, %67
  store i64 %68, ptr %7, align 8, !tbaa !5
  %69 = load i64, ptr %7, align 8, !tbaa !5
  %70 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %69)
  br label %9, !llvm.loop !11

71:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  ret i32 0
}

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

declare i32 @__isoc99_scanf(ptr noundef, ...) #3

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

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

attributes #0 = { mustprogress 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 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 #2 = { nocallback nofree nosync 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 = { 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 = !{!"long long", !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 [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z3Nc3x(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  store i64 0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  store i64 0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  store i64 0, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  store i64 0, ptr %5, align 8, !tbaa !5
  %7 = load i32, ptr %1, align 4, !tbaa !9
  %8 = add nsw i32 %7, -1
  store i32 %8, ptr %1, align 4, !tbaa !9
  %.not20 = icmp eq i32 %7, 0
  br i1 %.not20, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %.lr.ph
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %5, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %10 = load i64, ptr %5, align 8, !tbaa !5
  %11 = call noundef i64 @_Z3Nc3x(i64 noundef %10)
  %12 = load i64, ptr %5, align 8, !tbaa !5
  %13 = load i64, ptr %2, align 8, !tbaa !5
  %14 = xor i64 %13, -1
  %15 = add i64 %12, %14
  %16 = call noundef i64 @_Z3Nc3x(i64 noundef %15)
  %17 = load i64, ptr %5, align 8, !tbaa !5
  %18 = load i64, ptr %3, align 8, !tbaa !5
  %19 = xor i64 %18, -1
  %20 = add i64 %17, %19
  %21 = call noundef i64 @_Z3Nc3x(i64 noundef %20)
  %22 = load i64, ptr %5, align 8, !tbaa !5
  %23 = load i64, ptr %4, align 8, !tbaa !5
  %24 = xor i64 %23, -1
  %25 = add i64 %22, %24
  %26 = call noundef i64 @_Z3Nc3x(i64 noundef %25)
  %27 = load i64, ptr %5, align 8, !tbaa !5
  %28 = load i64, ptr %2, align 8, !tbaa !5
  %29 = load i64, ptr %3, align 8, !tbaa !5
  %.neg7 = add i64 %27, -2
  %30 = add i64 %28, %29
  %31 = sub i64 %.neg7, %30
  %32 = call noundef i64 @_Z3Nc3x(i64 noundef %31)
  %33 = load i64, ptr %5, align 8, !tbaa !5
  %34 = load i64, ptr %3, align 8, !tbaa !5
  %35 = load i64, ptr %4, align 8, !tbaa !5
  %.neg10 = add i64 %33, -2
  %36 = add i64 %34, %35
  %37 = sub i64 %.neg10, %36
  %38 = call noundef i64 @_Z3Nc3x(i64 noundef %37)
  %39 = load i64, ptr %5, align 8, !tbaa !5
  %40 = load i64, ptr %2, align 8, !tbaa !5
  %41 = load i64, ptr %4, align 8, !tbaa !5
  %.neg13 = add i64 %39, -2
  %42 = add i64 %40, %41
  %43 = sub i64 %.neg13, %42
  %44 = call noundef i64 @_Z3Nc3x(i64 noundef %43)
  %45 = load i64, ptr %5, align 8, !tbaa !5
  %46 = load i64, ptr %2, align 8, !tbaa !5
  %47 = load i64, ptr %3, align 8, !tbaa !5
  %48 = load i64, ptr %4, align 8, !tbaa !5
  %.neg16 = add i64 %45, -3
  %49 = add i64 %46, %47
  %50 = add i64 %49, %48
  %51 = sub i64 %.neg16, %50
  %52 = call noundef i64 @_Z3Nc3x(i64 noundef %51)
  %53 = add i64 %16, %21
  %54 = add i64 %53, %26
  %55 = sub i64 %11, %54
  %56 = add nsw i64 %55, %32
  %57 = add nsw i64 %56, %38
  %58 = add nsw i64 %57, %44
  %59 = sub i64 %58, %52
  %60 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %59)
  %61 = load i32, ptr %1, align 4, !tbaa !9
  %62 = add nsw i32 %61, -1
  store i32 %62, ptr %1, align 4, !tbaa !9
  %.not = icmp eq i32 %61, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

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

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

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

attributes #0 = { mustprogress 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 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"long long", !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"}


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