; LLVM IR from Izaron/ACM-ICPC :: Timus Online Judge/Volume 8/1792. Hamming Code.ll (Z5isHamv)

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

@m = external dso_local global [7 x i32], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z5isHamv() #0 {
  %1 = alloca i1, align 1
  %2 = load i32, ptr getelementptr inbounds ([7 x i32], ptr @m, i64 0, i64 4), align 16, !tbaa !5
  %3 = load i32, ptr getelementptr inbounds ([7 x i32], ptr @m, i64 0, i64 1), align 4, !tbaa !5
  %4 = load i32, ptr getelementptr inbounds ([7 x i32], ptr @m, i64 0, i64 2), align 8, !tbaa !5
  %5 = add nsw i32 %3, %4
  %6 = load i32, ptr getelementptr inbounds ([7 x i32], ptr @m, i64 0, i64 3), align 4, !tbaa !5
  %7 = add nsw i32 %5, %6
  %8 = srem i32 %7, 2
  %9 = icmp eq i32 %2, %8
  br i1 %9, label %10, label %31

10:                                               ; preds = %0
  %11 = load i32, ptr getelementptr inbounds ([7 x i32], ptr @m, i64 0, i64 5), align 4, !tbaa !5
  %12 = load i32, ptr @m, align 16, !tbaa !5
  %13 = load i32, ptr getelementptr inbounds ([7 x i32], ptr @m, i64 0, i64 2), align 8, !tbaa !5
  %14 = add nsw i32 %12, %13
  %15 = load i32, ptr getelementptr inbounds ([7 x i32], ptr @m, i64 0, i64 3), align 4, !tbaa !5
  %16 = add nsw i32 %14, %15
  %17 = srem i32 %16, 2
  %18 = icmp eq i32 %11, %17
  br i1 %18, label %19, label %30

19:                                               ; preds = %10
  %20 = load i32, ptr getelementptr inbounds ([7 x i32], ptr @m, i64 0, i64 6), align 8, !tbaa !5
  %21 = load i32, ptr @m, align 16, !tbaa !5
  %22 = load i32, ptr getelementptr inbounds ([7 x i32], ptr @m, i64 0, i64 1), align 4, !tbaa !5
  %23 = add nsw i32 %21, %22
  %24 = load i32, ptr getelementptr inbounds ([7 x i32], ptr @m, i64 0, i64 3), align 4, !tbaa !5
  %25 = add nsw i32 %23, %24
  %26 = srem i32 %25, 2
  %27 = icmp eq i32 %20, %26
  br i1 %27, label %28, label %29

28:                                               ; preds = %19
  store i1 true, ptr %1, align 1
  br label %32

29:                                               ; preds = %19
  br label %30

30:                                               ; preds = %29, %10
  br label %31

31:                                               ; preds = %30, %0
  store i1 false, ptr %1, align 1
  br label %32

32:                                               ; preds = %31, %28
  %33 = load i1, ptr %1, align 1
  ret i1 %33
}

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

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


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

@m = external dso_local local_unnamed_addr global [7 x i32], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local noundef zeroext i1 @_Z5isHamv() local_unnamed_addr #0 {
  %1 = load i32, ptr getelementptr inbounds (i8, ptr @m, i64 16), align 16, !tbaa !5
  %2 = load i32, ptr getelementptr inbounds (i8, ptr @m, i64 4), align 4, !tbaa !5
  %3 = load i32, ptr getelementptr inbounds (i8, ptr @m, i64 8), align 8, !tbaa !5
  %4 = load i32, ptr getelementptr inbounds (i8, ptr @m, i64 12), align 4, !tbaa !5
  %5 = add i32 %4, %2
  %6 = add i32 %5, %3
  %7 = srem i32 %6, 2
  %8 = icmp eq i32 %1, %7
  br i1 %8, label %9, label %21

9:                                                ; preds = %0
  %10 = load i32, ptr getelementptr inbounds (i8, ptr @m, i64 20), align 4, !tbaa !5
  %11 = load i32, ptr @m, align 16, !tbaa !5
  %12 = add i32 %4, %3
  %13 = add i32 %12, %11
  %14 = srem i32 %13, 2
  %15 = icmp eq i32 %10, %14
  br i1 %15, label %16, label %21

16:                                               ; preds = %9
  %17 = load i32, ptr getelementptr inbounds (i8, ptr @m, i64 24), align 8, !tbaa !5
  %18 = add i32 %5, %11
  %19 = srem i32 %18, 2
  %20 = icmp eq i32 %17, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %9, %16, %0
  br label %22

22:                                               ; preds = %16, %21
  %.0 = phi i1 [ false, %21 ], [ true, %16 ]
  ret i1 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) 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" }

!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: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass