; LLVM IR from intuitive-robots/mdt_policy :: pyhash-0.9.3/src/smhasher/Bitvec.ll (Z10printbits2PKhi)

; 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 [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10printbits2PKhi(ptr noundef %0, i32 noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i8, align 1
  %8 = alloca i32, align 4
  %9 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %10 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %11 = load i32, ptr %4, align 4, !tbaa !9
  %12 = sub nsw i32 %11, 1
  store i32 %12, ptr %5, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %44, %2
  %14 = load i32, ptr %5, align 4, !tbaa !9
  %15 = icmp sge i32 %14, 0
  br i1 %15, label %17, label %16

16:                                               ; preds = %13
  store i32 2, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %47

17:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #3
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds i8, ptr %18, i64 %20
  %22 = load i8, ptr %21, align 1, !tbaa !11
  store i8 %22, ptr %7, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 7, ptr %8, align 4, !tbaa !9
  br label %23

23:                                               ; preds = %40, %17
  %24 = load i32, ptr %8, align 4, !tbaa !9
  %25 = icmp sge i32 %24, 0
  br i1 %25, label %27, label %26

26:                                               ; preds = %23
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %43

27:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #3
  %28 = load i8, ptr %7, align 1, !tbaa !11
  %29 = zext i8 %28 to i32
  %30 = load i32, ptr %8, align 4, !tbaa !9
  %31 = shl i32 1, %30
  %32 = and i32 %29, %31
  %33 = icmp ne i32 %32, 0
  %34 = zext i1 %33 to i64
  %35 = select i1 %33, i8 35, i8 32
  store i8 %35, ptr %9, align 1, !tbaa !11
  %36 = load i8, ptr %9, align 1, !tbaa !11
  %37 = zext i8 %36 to i32
  %38 = load ptr, ptr @stdout, align 8, !tbaa !5
  %39 = call i32 @putc(i32 noundef %37, ptr noundef %38)
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #3
  br label %40

40:                                               ; preds = %27
  %41 = load i32, ptr %8, align 4, !tbaa !9
  %42 = add nsw i32 %41, -1
  store i32 %42, ptr %8, align 4, !tbaa !9
  br label %23, !llvm.loop !12

43:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #3
  br label %44

44:                                               ; preds = %43
  %45 = load i32, ptr %5, align 4, !tbaa !9
  %46 = add nsw i32 %45, -1
  store i32 %46, ptr %5, align 4, !tbaa !9
  br label %13, !llvm.loop !14

47:                                               ; preds = %16
  %48 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  ret void
}

declare i32 @putc(i32 noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


; 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 [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8

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

; Function Attrs: mustprogress nofree nounwind uwtable
define dso_local void @_Z10printbits2PKhi(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %4 = icmp sgt i32 %1, 0
  br i1 %4, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %2
  %5 = zext nneg i32 %1 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %2
  %6 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  ret void

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %5, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %7 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv.next
  %8 = load i8, ptr %7, align 1, !tbaa !5
  %9 = zext i8 %8 to i32
  %.not = icmp sgt i8 %8, -1
  %10 = select i1 %.not, i32 32, i32 35
  %11 = load ptr, ptr @stdout, align 8, !tbaa !8
  %12 = tail call i32 @putc(i32 noundef %10, ptr noundef %11)
  %13 = and i32 %9, 64
  %.not.1 = icmp eq i32 %13, 0
  %14 = select i1 %.not.1, i32 32, i32 35
  %15 = load ptr, ptr @stdout, align 8, !tbaa !8
  %16 = tail call i32 @putc(i32 noundef %14, ptr noundef %15)
  %17 = and i32 %9, 32
  %.not.2 = icmp eq i32 %17, 0
  %18 = select i1 %.not.2, i32 32, i32 35
  %19 = load ptr, ptr @stdout, align 8, !tbaa !8
  %20 = tail call i32 @putc(i32 noundef %18, ptr noundef %19)
  %21 = and i32 %9, 16
  %.not.3 = icmp eq i32 %21, 0
  %22 = select i1 %.not.3, i32 32, i32 35
  %23 = load ptr, ptr @stdout, align 8, !tbaa !8
  %24 = tail call i32 @putc(i32 noundef %22, ptr noundef %23)
  %25 = and i32 %9, 8
  %.not.4 = icmp eq i32 %25, 0
  %26 = select i1 %.not.4, i32 32, i32 35
  %27 = load ptr, ptr @stdout, align 8, !tbaa !8
  %28 = tail call i32 @putc(i32 noundef %26, ptr noundef %27)
  %29 = and i32 %9, 4
  %.not.5 = icmp eq i32 %29, 0
  %30 = select i1 %.not.5, i32 32, i32 35
  %31 = load ptr, ptr @stdout, align 8, !tbaa !8
  %32 = tail call i32 @putc(i32 noundef %30, ptr noundef %31)
  %33 = and i32 %9, 2
  %.not.6 = icmp eq i32 %33, 0
  %34 = select i1 %.not.6, i32 32, i32 35
  %35 = load ptr, ptr @stdout, align 8, !tbaa !8
  %36 = tail call i32 @putc(i32 noundef %34, ptr noundef %35)
  %37 = and i32 %9, 1
  %.not.7 = icmp eq i32 %37, 0
  %38 = select i1 %.not.7, i32 32, i32 35
  %39 = load ptr, ptr @stdout, align 8, !tbaa !8
  %40 = tail call i32 @putc(i32 noundef %38, ptr noundef %39)
  %41 = icmp ugt i64 %indvars.iv, 1
  br i1 %41, label %.lr.ph, label %._crit_edge, !llvm.loop !10
}

; Function Attrs: nofree nounwind
declare noundef i32 @putc(i32 noundef, ptr nocapture noundef) local_unnamed_addr #0

attributes #0 = { 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 #1 = { mustprogress nofree 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass