; LLVM IR from xirc/cp-algorithm :: codeforces/1395/A/main.ll (Z5solveiiii)

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

%class.anon = type { ptr, ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z5solveiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #0 {
  %5 = alloca i1, align 1
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %class.anon, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %10) #3
  %13 = getelementptr inbounds %class.anon, ptr %10, i32 0, i32 0
  store ptr %6, ptr %13, align 8, !tbaa !9
  %14 = getelementptr inbounds %class.anon, ptr %10, i32 0, i32 1
  store ptr %7, ptr %14, align 8, !tbaa !9
  %15 = getelementptr inbounds %class.anon, ptr %10, i32 0, i32 2
  store ptr %8, ptr %15, align 8, !tbaa !9
  %16 = getelementptr inbounds %class.anon, ptr %10, i32 0, i32 3
  store ptr %9, ptr %16, align 8, !tbaa !9
  %17 = load i32, ptr %6, align 4, !tbaa !5
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %25, label %19

19:                                               ; preds = %4
  %20 = load i32, ptr %7, align 4, !tbaa !5
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %25, label %22

22:                                               ; preds = %19
  %23 = load i32, ptr %8, align 4, !tbaa !5
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %28

25:                                               ; preds = %22, %19, %4
  %26 = call noundef i32 @"_ZZ5solveiiiiENK3$_0clEv"(ptr noundef nonnull align 8 dereferenceable(32) %10)
  %27 = icmp sle i32 %26, 1
  store i1 %27, ptr %5, align 1
  store i32 1, ptr %11, align 4
  br label %55

28:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  store i32 0, ptr %12, align 4, !tbaa !5
  %29 = load i32, ptr %6, align 4, !tbaa !5
  %30 = and i32 %29, 1
  %31 = load i32, ptr %12, align 4, !tbaa !5
  %32 = add nsw i32 %31, %30
  store i32 %32, ptr %12, align 4, !tbaa !5
  %33 = load i32, ptr %7, align 4, !tbaa !5
  %34 = and i32 %33, 1
  %35 = load i32, ptr %12, align 4, !tbaa !5
  %36 = add nsw i32 %35, %34
  store i32 %36, ptr %12, align 4, !tbaa !5
  %37 = load i32, ptr %8, align 4, !tbaa !5
  %38 = and i32 %37, 1
  %39 = load i32, ptr %12, align 4, !tbaa !5
  %40 = add nsw i32 %39, %38
  store i32 %40, ptr %12, align 4, !tbaa !5
  %41 = load i32, ptr %12, align 4, !tbaa !5
  %42 = icmp sge i32 %41, 2
  br i1 %42, label %43, label %52

43:                                               ; preds = %28
  %44 = load i32, ptr %6, align 4, !tbaa !5
  %45 = add nsw i32 %44, -1
  store i32 %45, ptr %6, align 4, !tbaa !5
  %46 = load i32, ptr %7, align 4, !tbaa !5
  %47 = add nsw i32 %46, -1
  store i32 %47, ptr %7, align 4, !tbaa !5
  %48 = load i32, ptr %8, align 4, !tbaa !5
  %49 = add nsw i32 %48, -1
  store i32 %49, ptr %8, align 4, !tbaa !5
  %50 = load i32, ptr %9, align 4, !tbaa !5
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %9, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %43, %28
  %53 = call noundef i32 @"_ZZ5solveiiiiENK3$_0clEv"(ptr noundef nonnull align 8 dereferenceable(32) %10)
  %54 = icmp sle i32 %53, 1
  store i1 %54, ptr %5, align 1
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  br label %55

55:                                               ; preds = %52, %25
  call void @llvm.lifetime.end.p0(i64 32, ptr %10) #3
  %56 = load i1, ptr %5, align 1
  ret i1 %56
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i32 @"_ZZ5solveiiiiENK3$_0clEv"(ptr noundef nonnull align 8 dereferenceable(32)) #2 align 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 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 = { inlinehint 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 #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 = !{!"any pointer", !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"

%class.anon = type { ptr, ptr, ptr, ptr }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z5solveiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %class.anon, align 8
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %9) #3
  store ptr %5, ptr %9, align 8, !tbaa !9
  %10 = getelementptr inbounds i8, ptr %9, i64 8
  store ptr %6, ptr %10, align 8, !tbaa !9
  %11 = getelementptr inbounds i8, ptr %9, i64 16
  store ptr %7, ptr %11, align 8, !tbaa !9
  %12 = getelementptr inbounds i8, ptr %9, i64 24
  store ptr %8, ptr %12, align 8, !tbaa !9
  %13 = icmp eq i32 %0, 0
  %14 = icmp eq i32 %1, 0
  %or.cond = or i1 %13, %14
  %15 = icmp eq i32 %2, 0
  %or.cond3 = or i1 %or.cond, %15
  br i1 %or.cond3, label %28, label %16

16:                                               ; preds = %4
  %17 = and i32 %0, 1
  %18 = and i32 %1, 1
  %19 = add nuw nsw i32 %18, %17
  %20 = and i32 %2, 1
  %21 = add nuw nsw i32 %19, %20
  %22 = icmp ugt i32 %21, 1
  br i1 %22, label %23, label %28

23:                                               ; preds = %16
  %24 = add nsw i32 %0, -1
  store i32 %24, ptr %5, align 4, !tbaa !5
  %25 = add nsw i32 %1, -1
  store i32 %25, ptr %6, align 4, !tbaa !5
  %26 = add nsw i32 %2, -1
  store i32 %26, ptr %7, align 4, !tbaa !5
  %27 = add nsw i32 %3, 1
  store i32 %27, ptr %8, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %16, %23, %4
  %29 = call noundef i32 @"_ZZ5solveiiiiENK3$_0clEv"(ptr noundef nonnull align 8 dereferenceable(32) %9)
  %.0 = icmp slt i32 %29, 2
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %9) #3
  ret i1 %.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: inlinehint mustprogress nounwind uwtable
declare hidden noundef i32 @"_ZZ5solveiiiiENK3$_0clEv"(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 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 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 = { inlinehint 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 #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 = !{!"any pointer", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass