; LLVM IR from tyalie/Sudoku-Generator-CPP :: src/Generator/GenSudoku.ll (ZNK9GenSudoku10rule1_colsEPb)

; 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.Sudoku = type { [81 x i8], i8 }
%class.GenSudoku = type { %class.Sudoku, i64 }

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

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

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

8:                                                ; preds = %34, %2
  %9 = load i32, ptr %5, align 4, !tbaa !9
  %10 = icmp slt i32 %9, 9
  br i1 %10, label %12, label %11

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

12:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #2
  %13 = getelementptr inbounds %class.Sudoku, ptr %7, i32 0, i32 0
  %14 = load i32, ptr %5, align 4, !tbaa !9
  %15 = mul nsw i32 %14, 9
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds %class.GenSudoku, ptr %7, i32 0, i32 1
  %18 = load i64, ptr %17, align 8, !tbaa !11
  %19 = urem i64 %18, 9
  %20 = add i64 %16, %19
  %21 = getelementptr inbounds [81 x i8], ptr %13, i64 0, i64 %20
  %22 = load i8, ptr %21, align 1, !tbaa !16
  store i8 %22, ptr %6, align 1, !tbaa !16
  %23 = load i8, ptr %6, align 1, !tbaa !16
  %24 = zext i8 %23 to i32
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %33

26:                                               ; preds = %12
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = load i8, ptr %6, align 1, !tbaa !16
  %29 = zext i8 %28 to i32
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds i8, ptr %27, i64 %30
  %32 = getelementptr inbounds i8, ptr %31, i64 -1
  store i8 0, ptr %32, align 1, !tbaa !17
  br label %33

33:                                               ; preds = %26, %12
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #2
  br label %34

34:                                               ; preds = %33
  %35 = load i32, ptr %5, align 4, !tbaa !9
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %5, align 4, !tbaa !9
  br label %8, !llvm.loop !18

37:                                               ; preds = %11
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  ret ptr %38
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!"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 = !{!12, !15, i64 88}
!12 = !{!"_ZTS9GenSudoku", !13, i64 0, !15, i64 88}
!13 = !{!"_ZTS6Sudoku", !7, i64 0, !14, i64 81}
!14 = !{!"bool", !7, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!7, !7, i64 0}
!17 = !{!14, !14, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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(argmem: readwrite) uwtable
define dso_local noundef ptr @_ZNK9GenSudoku10rule1_colsEPb(ptr nocapture noundef nonnull readonly align 8 dereferenceable(96) %0, ptr noundef returned writeonly %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 88
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = urem i64 %4, 9
  %invariant.gep = getelementptr i8, ptr %1, i64 -1
  %6 = getelementptr inbounds [81 x i8], ptr %0, i64 0, i64 %5
  %7 = load i8, ptr %6, align 1, !tbaa !12
  %.not = icmp eq i8 %7, 0
  br i1 %.not, label %10, label %8

8:                                                ; preds = %2
  %9 = zext i8 %7 to i64
  %gep = getelementptr i8, ptr %invariant.gep, i64 %9
  store i8 0, ptr %gep, align 1, !tbaa !13
  br label %10

10:                                               ; preds = %8, %2
  %11 = add nuw nsw i64 %5, 9
  %12 = getelementptr inbounds [81 x i8], ptr %0, i64 0, i64 %11
  %13 = load i8, ptr %12, align 1, !tbaa !12
  %.not.1 = icmp eq i8 %13, 0
  br i1 %.not.1, label %16, label %14

14:                                               ; preds = %10
  %15 = zext i8 %13 to i64
  %gep.1 = getelementptr i8, ptr %invariant.gep, i64 %15
  store i8 0, ptr %gep.1, align 1, !tbaa !13
  br label %16

16:                                               ; preds = %14, %10
  %17 = add nuw nsw i64 %5, 18
  %18 = getelementptr inbounds [81 x i8], ptr %0, i64 0, i64 %17
  %19 = load i8, ptr %18, align 1, !tbaa !12
  %.not.2 = icmp eq i8 %19, 0
  br i1 %.not.2, label %22, label %20

20:                                               ; preds = %16
  %21 = zext i8 %19 to i64
  %gep.2 = getelementptr i8, ptr %invariant.gep, i64 %21
  store i8 0, ptr %gep.2, align 1, !tbaa !13
  br label %22

22:                                               ; preds = %20, %16
  %23 = add nuw nsw i64 %5, 27
  %24 = getelementptr inbounds [81 x i8], ptr %0, i64 0, i64 %23
  %25 = load i8, ptr %24, align 1, !tbaa !12
  %.not.3 = icmp eq i8 %25, 0
  br i1 %.not.3, label %28, label %26

26:                                               ; preds = %22
  %27 = zext i8 %25 to i64
  %gep.3 = getelementptr i8, ptr %invariant.gep, i64 %27
  store i8 0, ptr %gep.3, align 1, !tbaa !13
  br label %28

28:                                               ; preds = %26, %22
  %29 = add nuw nsw i64 %5, 36
  %30 = getelementptr inbounds [81 x i8], ptr %0, i64 0, i64 %29
  %31 = load i8, ptr %30, align 1, !tbaa !12
  %.not.4 = icmp eq i8 %31, 0
  br i1 %.not.4, label %34, label %32

32:                                               ; preds = %28
  %33 = zext i8 %31 to i64
  %gep.4 = getelementptr i8, ptr %invariant.gep, i64 %33
  store i8 0, ptr %gep.4, align 1, !tbaa !13
  br label %34

34:                                               ; preds = %32, %28
  %35 = add nuw nsw i64 %5, 45
  %36 = getelementptr inbounds [81 x i8], ptr %0, i64 0, i64 %35
  %37 = load i8, ptr %36, align 1, !tbaa !12
  %.not.5 = icmp eq i8 %37, 0
  br i1 %.not.5, label %40, label %38

38:                                               ; preds = %34
  %39 = zext i8 %37 to i64
  %gep.5 = getelementptr i8, ptr %invariant.gep, i64 %39
  store i8 0, ptr %gep.5, align 1, !tbaa !13
  br label %40

40:                                               ; preds = %38, %34
  %41 = add nuw nsw i64 %5, 54
  %42 = getelementptr inbounds [81 x i8], ptr %0, i64 0, i64 %41
  %43 = load i8, ptr %42, align 1, !tbaa !12
  %.not.6 = icmp eq i8 %43, 0
  br i1 %.not.6, label %46, label %44

44:                                               ; preds = %40
  %45 = zext i8 %43 to i64
  %gep.6 = getelementptr i8, ptr %invariant.gep, i64 %45
  store i8 0, ptr %gep.6, align 1, !tbaa !13
  br label %46

46:                                               ; preds = %44, %40
  %47 = add nuw nsw i64 %5, 63
  %48 = getelementptr inbounds [81 x i8], ptr %0, i64 0, i64 %47
  %49 = load i8, ptr %48, align 1, !tbaa !12
  %.not.7 = icmp eq i8 %49, 0
  br i1 %.not.7, label %52, label %50

50:                                               ; preds = %46
  %51 = zext i8 %49 to i64
  %gep.7 = getelementptr i8, ptr %invariant.gep, i64 %51
  store i8 0, ptr %gep.7, align 1, !tbaa !13
  br label %52

52:                                               ; preds = %50, %46
  %53 = add nuw nsw i64 %5, 72
  %54 = getelementptr inbounds [81 x i8], ptr %0, i64 0, i64 %53
  %55 = load i8, ptr %54, align 1, !tbaa !12
  %.not.8 = icmp eq i8 %55, 0
  br i1 %.not.8, label %58, label %56

56:                                               ; preds = %52
  %57 = zext i8 %55 to i64
  %gep.8 = getelementptr i8, ptr %invariant.gep, i64 %57
  store i8 0, ptr %gep.8, align 1, !tbaa !13
  br label %58

58:                                               ; preds = %56, %52
  ret ptr %1
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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, !11, i64 88}
!6 = !{!"_ZTS9GenSudoku", !7, i64 0, !11, i64 88}
!7 = !{!"_ZTS6Sudoku", !8, i64 0, !10, i64 81}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!8, !8, i64 0}
!13 = !{!10, !10, i64 0}


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