; LLVM IR from kenjin/Awesome-LC-C-Cracker :: leetcode-c-sol/0461_Hamming-Distance (0461_Hamming-Distance)

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

; Function Attrs: nounwind uwtable
define dso_local i32 @hammingDistance(i32 noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = load i32, ptr %4, align 4, !tbaa !5
  %10 = xor i32 %8, %9
  store i32 %10, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %25, %2
  %12 = load i32, ptr %7, align 4, !tbaa !5
  %13 = icmp slt i32 %12, 32
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  br label %28

15:                                               ; preds = %11
  %16 = load i32, ptr %5, align 4, !tbaa !5
  %17 = load i32, ptr %7, align 4, !tbaa !5
  %18 = shl i32 1, %17
  %19 = and i32 %16, %18
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %21, label %24

21:                                               ; preds = %15
  %22 = load i32, ptr %6, align 4, !tbaa !5
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr %6, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %21, %15
  br label %25

25:                                               ; preds = %24
  %26 = load i32, ptr %7, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %7, align 4, !tbaa !5
  br label %11, !llvm.loop !9

28:                                               ; preds = %14
  %29 = load i32, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret i32 %29
}

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local i32 @hammingDistance(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = xor i32 %1, %0
  %4 = and i32 %3, 1
  %5 = lshr i32 %3, 1
  %6 = and i32 %5, 1
  %spec.select.1 = add nuw nsw i32 %6, %4
  %7 = lshr i32 %3, 2
  %8 = and i32 %7, 1
  %spec.select.2 = add nuw nsw i32 %8, %spec.select.1
  %9 = lshr i32 %3, 3
  %10 = and i32 %9, 1
  %spec.select.3 = add nuw nsw i32 %10, %spec.select.2
  %11 = lshr i32 %3, 4
  %12 = and i32 %11, 1
  %spec.select.4 = add nuw nsw i32 %12, %spec.select.3
  %13 = lshr i32 %3, 5
  %14 = and i32 %13, 1
  %spec.select.5 = add nuw nsw i32 %14, %spec.select.4
  %15 = lshr i32 %3, 6
  %16 = and i32 %15, 1
  %spec.select.6 = add nuw nsw i32 %16, %spec.select.5
  %17 = lshr i32 %3, 7
  %18 = and i32 %17, 1
  %spec.select.7 = add nuw nsw i32 %18, %spec.select.6
  %19 = lshr i32 %3, 8
  %20 = and i32 %19, 1
  %spec.select.8 = add nuw nsw i32 %20, %spec.select.7
  %21 = lshr i32 %3, 9
  %22 = and i32 %21, 1
  %spec.select.9 = add nuw nsw i32 %22, %spec.select.8
  %23 = lshr i32 %3, 10
  %24 = and i32 %23, 1
  %spec.select.10 = add nuw nsw i32 %24, %spec.select.9
  %25 = lshr i32 %3, 11
  %26 = and i32 %25, 1
  %spec.select.11 = add nuw nsw i32 %26, %spec.select.10
  %27 = lshr i32 %3, 12
  %28 = and i32 %27, 1
  %spec.select.12 = add nuw nsw i32 %28, %spec.select.11
  %29 = lshr i32 %3, 13
  %30 = and i32 %29, 1
  %spec.select.13 = add nuw nsw i32 %30, %spec.select.12
  %31 = lshr i32 %3, 14
  %32 = and i32 %31, 1
  %spec.select.14 = add nuw nsw i32 %32, %spec.select.13
  %33 = lshr i32 %3, 15
  %34 = and i32 %33, 1
  %spec.select.15 = add nuw nsw i32 %34, %spec.select.14
  %35 = lshr i32 %3, 16
  %36 = and i32 %35, 1
  %spec.select.16 = add nuw nsw i32 %36, %spec.select.15
  %37 = lshr i32 %3, 17
  %38 = and i32 %37, 1
  %spec.select.17 = add nuw nsw i32 %38, %spec.select.16
  %39 = lshr i32 %3, 18
  %40 = and i32 %39, 1
  %spec.select.18 = add nuw nsw i32 %40, %spec.select.17
  %41 = lshr i32 %3, 19
  %42 = and i32 %41, 1
  %spec.select.19 = add nuw nsw i32 %42, %spec.select.18
  %43 = lshr i32 %3, 20
  %44 = and i32 %43, 1
  %spec.select.20 = add nuw nsw i32 %44, %spec.select.19
  %45 = lshr i32 %3, 21
  %46 = and i32 %45, 1
  %spec.select.21 = add nuw nsw i32 %46, %spec.select.20
  %47 = lshr i32 %3, 22
  %48 = and i32 %47, 1
  %spec.select.22 = add nuw nsw i32 %48, %spec.select.21
  %49 = lshr i32 %3, 23
  %50 = and i32 %49, 1
  %spec.select.23 = add nuw nsw i32 %50, %spec.select.22
  %51 = lshr i32 %3, 24
  %52 = and i32 %51, 1
  %spec.select.24 = add nuw nsw i32 %52, %spec.select.23
  %53 = lshr i32 %3, 25
  %54 = and i32 %53, 1
  %spec.select.25 = add nuw nsw i32 %54, %spec.select.24
  %55 = lshr i32 %3, 26
  %56 = and i32 %55, 1
  %spec.select.26 = add nuw nsw i32 %56, %spec.select.25
  %57 = lshr i32 %3, 27
  %58 = and i32 %57, 1
  %spec.select.27 = add nuw nsw i32 %58, %spec.select.26
  %59 = lshr i32 %3, 28
  %60 = and i32 %59, 1
  %spec.select.28 = add nuw nsw i32 %60, %spec.select.27
  %61 = lshr i32 %3, 29
  %62 = and i32 %61, 1
  %spec.select.29 = add nuw nsw i32 %62, %spec.select.28
  %63 = lshr i32 %3, 30
  %64 = and i32 %63, 1
  %spec.select.30 = add nuw nsw i32 %64, %spec.select.29
  %65 = lshr i32 %3, 31
  %spec.select.31 = add nuw nsw i32 %65, %spec.select.30
  ret i32 %spec.select.31
}

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


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass