; LLVM IR from clausecker/24puzzle :: transposition (canonical_automorphism)

; 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: 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: nounwind uwtable
declare dso_local i32 @tileset_morph(i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @is_admissible_morphism(i32 noundef, i32 noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @tileset_remove(i32 noundef, i32 noundef) #2

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

11:                                               ; preds = %30, %1
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = icmp ult i32 %12, 8
  br i1 %13, label %14, label %33

14:                                               ; preds = %11
  %15 = load i32, ptr %7, align 4, !tbaa !5
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = call i32 @tileset_morph(i32 noundef %15, i32 noundef %16)
  store i32 %17, ptr %6, align 4, !tbaa !5
  %18 = load i32, ptr %6, align 4, !tbaa !5
  %19 = load i32, ptr %5, align 4, !tbaa !5
  %20 = icmp uge i32 %18, %19
  br i1 %20, label %26, label %21

21:                                               ; preds = %14
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = load i32, ptr %3, align 4, !tbaa !5
  %24 = call i32 @is_admissible_morphism(i32 noundef %22, i32 noundef %23)
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %27, label %26

26:                                               ; preds = %21, %14
  br label %30

27:                                               ; preds = %21
  %28 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %28, ptr %5, align 4, !tbaa !5
  %29 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %29, ptr %4, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %27, %26
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = add i32 %31, 1
  store i32 %32, ptr %3, align 4, !tbaa !5
  br label %11, !llvm.loop !9

33:                                               ; preds = %11
  %34 = load i32, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret i32 %34
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { inlinehint 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/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: nounwind uwtable
declare dso_local i32 @tileset_morph(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @is_admissible_morphism(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @tileset_remove(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @canonical_automorphism(i32 noundef %0) local_unnamed_addr #0 {
  %2 = tail call i32 @tileset_remove(i32 noundef %0, i32 noundef 0)
  %3 = tail call i32 @tileset_morph(i32 noundef %2, i32 noundef 1)
  %.not = icmp ult i32 %3, %2
  br i1 %.not, label %4, label %6

4:                                                ; preds = %1
  %5 = tail call i32 @is_admissible_morphism(i32 noundef %0, i32 noundef 1)
  %.not17 = icmp ne i32 %5, 0
  %spec.select = select i1 %.not17, i32 %3, i32 %2
  %spec.select18 = zext i1 %.not17 to i32
  br label %6

6:                                                ; preds = %4, %1
  %.115 = phi i32 [ %2, %1 ], [ %spec.select, %4 ]
  %.1 = phi i32 [ 0, %1 ], [ %spec.select18, %4 ]
  %7 = tail call i32 @tileset_morph(i32 noundef %2, i32 noundef 2)
  %.not.1 = icmp ult i32 %7, %.115
  br i1 %.not.1, label %8, label %10

8:                                                ; preds = %6
  %9 = tail call i32 @is_admissible_morphism(i32 noundef %0, i32 noundef 2)
  %.not17.1 = icmp eq i32 %9, 0
  %spec.select.1 = select i1 %.not17.1, i32 %.115, i32 %7
  %spec.select18.1 = select i1 %.not17.1, i32 %.1, i32 2
  br label %10

10:                                               ; preds = %8, %6
  %.115.1 = phi i32 [ %.115, %6 ], [ %spec.select.1, %8 ]
  %.1.1 = phi i32 [ %.1, %6 ], [ %spec.select18.1, %8 ]
  %11 = tail call i32 @tileset_morph(i32 noundef %2, i32 noundef 3)
  %.not.2 = icmp ult i32 %11, %.115.1
  br i1 %.not.2, label %12, label %14

12:                                               ; preds = %10
  %13 = tail call i32 @is_admissible_morphism(i32 noundef %0, i32 noundef 3)
  %.not17.2 = icmp eq i32 %13, 0
  %spec.select.2 = select i1 %.not17.2, i32 %.115.1, i32 %11
  %spec.select18.2 = select i1 %.not17.2, i32 %.1.1, i32 3
  br label %14

14:                                               ; preds = %12, %10
  %.115.2 = phi i32 [ %.115.1, %10 ], [ %spec.select.2, %12 ]
  %.1.2 = phi i32 [ %.1.1, %10 ], [ %spec.select18.2, %12 ]
  %15 = tail call i32 @tileset_morph(i32 noundef %2, i32 noundef 4)
  %.not.3 = icmp ult i32 %15, %.115.2
  br i1 %.not.3, label %16, label %18

16:                                               ; preds = %14
  %17 = tail call i32 @is_admissible_morphism(i32 noundef %0, i32 noundef 4)
  %.not17.3 = icmp eq i32 %17, 0
  %spec.select.3 = select i1 %.not17.3, i32 %.115.2, i32 %15
  %spec.select18.3 = select i1 %.not17.3, i32 %.1.2, i32 4
  br label %18

18:                                               ; preds = %16, %14
  %.115.3 = phi i32 [ %.115.2, %14 ], [ %spec.select.3, %16 ]
  %.1.3 = phi i32 [ %.1.2, %14 ], [ %spec.select18.3, %16 ]
  %19 = tail call i32 @tileset_morph(i32 noundef %2, i32 noundef 5)
  %.not.4 = icmp ult i32 %19, %.115.3
  br i1 %.not.4, label %20, label %22

20:                                               ; preds = %18
  %21 = tail call i32 @is_admissible_morphism(i32 noundef %0, i32 noundef 5)
  %.not17.4 = icmp eq i32 %21, 0
  %spec.select.4 = select i1 %.not17.4, i32 %.115.3, i32 %19
  %spec.select18.4 = select i1 %.not17.4, i32 %.1.3, i32 5
  br label %22

22:                                               ; preds = %20, %18
  %.115.4 = phi i32 [ %.115.3, %18 ], [ %spec.select.4, %20 ]
  %.1.4 = phi i32 [ %.1.3, %18 ], [ %spec.select18.4, %20 ]
  %23 = tail call i32 @tileset_morph(i32 noundef %2, i32 noundef 6)
  %.not.5 = icmp ult i32 %23, %.115.4
  br i1 %.not.5, label %24, label %26

24:                                               ; preds = %22
  %25 = tail call i32 @is_admissible_morphism(i32 noundef %0, i32 noundef 6)
  %.not17.5 = icmp eq i32 %25, 0
  %spec.select.5 = select i1 %.not17.5, i32 %.115.4, i32 %23
  %spec.select18.5 = select i1 %.not17.5, i32 %.1.4, i32 6
  br label %26

26:                                               ; preds = %24, %22
  %.115.5 = phi i32 [ %.115.4, %22 ], [ %spec.select.5, %24 ]
  %.1.5 = phi i32 [ %.1.4, %22 ], [ %spec.select18.5, %24 ]
  %27 = tail call i32 @tileset_morph(i32 noundef %2, i32 noundef 7)
  %.not.6 = icmp ult i32 %27, %.115.5
  br i1 %.not.6, label %28, label %30

28:                                               ; preds = %26
  %29 = tail call i32 @is_admissible_morphism(i32 noundef %0, i32 noundef 7)
  %.not17.6 = icmp eq i32 %29, 0
  %spec.select18.6 = select i1 %.not17.6, i32 %.1.5, i32 7
  br label %30

30:                                               ; preds = %28, %26
  %.1.6 = phi i32 [ %.1.5, %26 ], [ %spec.select18.6, %28 ]
  ret i32 %.1.6
}

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 = { inlinehint 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)"}


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