; LLVM IR from attractivechaos/plb2 :: src/c (sudoku)

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

@hard20 = external dso_local global [20 x ptr], align 16

; Function Attrs: nounwind uwtable
declare dso_local ptr @sd_genmat() #0

; 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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca [82 x i8], align 16
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 200, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 82, ptr %10) #6
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = icmp sgt i32 %11, 1
  br i1 %12, label %13, label %18

13:                                               ; preds = %2
  %14 = load ptr, ptr %5, align 8, !tbaa !9
  %15 = getelementptr inbounds ptr, ptr %14, i64 1
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = call i32 @atoi(ptr noundef %16) #7
  store i32 %17, ptr %8, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %13, %2
  %19 = call ptr @sd_genmat()
  store ptr %19, ptr %9, align 8, !tbaa !9
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %42, %18
  %21 = load i32, ptr %6, align 4, !tbaa !5
  %22 = load i32, ptr %8, align 4, !tbaa !5
  %23 = icmp slt i32 %21, %22
  br i1 %23, label %24, label %45

24:                                               ; preds = %20
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %25

25:                                               ; preds = %38, %24
  %26 = load i32, ptr %7, align 4, !tbaa !5
  %27 = icmp slt i32 %26, 20
  br i1 %27, label %28, label %41

28:                                               ; preds = %25
  %29 = getelementptr inbounds [82 x i8], ptr %10, i64 0, i64 0
  %30 = load i32, ptr %7, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [20 x ptr], ptr @hard20, i64 0, i64 %31
  %33 = load ptr, ptr %32, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %29, ptr align 1 %33, i64 81, i1 false)
  %34 = load ptr, ptr %9, align 8, !tbaa !9
  %35 = getelementptr inbounds [82 x i8], ptr %10, i64 0, i64 0
  %36 = call i32 @sd_solve(ptr noundef %34, ptr noundef %35)
  %37 = call i32 @putchar(i32 noundef 10)
  br label %38

38:                                               ; preds = %28
  %39 = load i32, ptr %7, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %7, align 4, !tbaa !5
  br label %25, !llvm.loop !11

41:                                               ; preds = %25
  br label %42

42:                                               ; preds = %41
  %43 = load i32, ptr %6, align 4, !tbaa !5
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %6, align 4, !tbaa !5
  br label %20, !llvm.loop !13

45:                                               ; preds = %20
  %46 = load ptr, ptr %9, align 8, !tbaa !9
  call void @free(ptr noundef %46) #6
  call void @llvm.lifetime.end.p0(i64 82, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  ret i32 0
}

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr noundef nonnull) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: inlinehint nounwind uwtable
declare i32 @putchar(i32 noundef) #4

; Function Attrs: nounwind
declare void @free(ptr noundef) #5

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 = { inlinehint nounwind willreturn memory(read) 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(read) }

!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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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

@hard20 = external dso_local local_unnamed_addr global [20 x ptr], align 16

; Function Attrs: nounwind uwtable
declare dso_local ptr @sd_genmat() local_unnamed_addr #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca [82 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 82, ptr nonnull %3) #6
  %4 = icmp sgt i32 %0, 1
  br i1 %4, label %6, label %.thread

.thread:                                          ; preds = %2
  %5 = tail call ptr @sd_genmat()
  br label %.preheader.preheader

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = tail call i32 @atoi(ptr nocapture noundef %8) #7
  %10 = tail call ptr @sd_genmat()
  %11 = icmp sgt i32 %9, 0
  br i1 %11, label %.preheader.preheader, label %._crit_edge

.preheader.preheader:                             ; preds = %.thread, %6
  %12 = phi ptr [ %5, %.thread ], [ %10, %6 ]
  %.0915 = phi i32 [ 200, %.thread ], [ %9, %6 ]
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %.preheader
  %.012 = phi i32 [ %73, %.preheader ], [ 0, %.preheader.preheader ]
  %13 = load ptr, ptr @hard20, align 16, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(81) %3, ptr noundef nonnull align 1 dereferenceable(81) %13, i64 81, i1 false)
  %14 = call i32 @sd_solve(ptr noundef %12, ptr noundef nonnull %3)
  %15 = call i32 @putchar(i32 noundef 10)
  %16 = load ptr, ptr getelementptr inbounds (i8, ptr @hard20, i64 8), align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(81) %3, ptr noundef nonnull align 1 dereferenceable(81) %16, i64 81, i1 false)
  %17 = call i32 @sd_solve(ptr noundef %12, ptr noundef nonnull %3)
  %18 = call i32 @putchar(i32 noundef 10)
  %19 = load ptr, ptr getelementptr inbounds (i8, ptr @hard20, i64 16), align 16, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(81) %3, ptr noundef nonnull align 1 dereferenceable(81) %19, i64 81, i1 false)
  %20 = call i32 @sd_solve(ptr noundef %12, ptr noundef nonnull %3)
  %21 = call i32 @putchar(i32 noundef 10)
  %22 = load ptr, ptr getelementptr inbounds (i8, ptr @hard20, i64 24), align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(81) %3, ptr noundef nonnull align 1 dereferenceable(81) %22, i64 81, i1 false)
  %23 = call i32 @sd_solve(ptr noundef %12, ptr noundef nonnull %3)
  %24 = call i32 @putchar(i32 noundef 10)
  %25 = load ptr, ptr getelementptr inbounds (i8, ptr @hard20, i64 32), align 16, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(81) %3, ptr noundef nonnull align 1 dereferenceable(81) %25, i64 81, i1 false)
  %26 = call i32 @sd_solve(ptr noundef %12, ptr noundef nonnull %3)
  %27 = call i32 @putchar(i32 noundef 10)
  %28 = load ptr, ptr getelementptr inbounds (i8, ptr @hard20, i64 40), align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(81) %3, ptr noundef nonnull align 1 dereferenceable(81) %28, i64 81, i1 false)
  %29 = call i32 @sd_solve(ptr noundef %12, ptr noundef nonnull %3)
  %30 = call i32 @putchar(i32 noundef 10)
  %31 = load ptr, ptr getelementptr inbounds (i8, ptr @hard20, i64 48), align 16, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(81) %3, ptr noundef nonnull align 1 dereferenceable(81) %31, i64 81, i1 false)
  %32 = call i32 @sd_solve(ptr noundef %12, ptr noundef nonnull %3)
  %33 = call i32 @putchar(i32 noundef 10)
  %34 = load ptr, ptr getelementptr inbounds (i8, ptr @hard20, i64 56), align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(81) %3, ptr noundef nonnull align 1 dereferenceable(81) %34, i64 81, i1 false)
  %35 = call i32 @sd_solve(ptr noundef %12, ptr noundef nonnull %3)
  %36 = call i32 @putchar(i32 noundef 10)
  %37 = load ptr, ptr getelementptr inbounds (i8, ptr @hard20, i64 64), align 16, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(81) %3, ptr noundef nonnull align 1 dereferenceable(81) %37, i64 81, i1 false)
  %38 = call i32 @sd_solve(ptr noundef %12, ptr noundef nonnull %3)
  %39 = call i32 @putchar(i32 noundef 10)
  %40 = load ptr, ptr getelementptr inbounds (i8, ptr @hard20, i64 72), align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(81) %3, ptr noundef nonnull align 1 dereferenceable(81) %40, i64 81, i1 false)
  %41 = call i32 @sd_solve(ptr noundef %12, ptr noundef nonnull %3)
  %42 = call i32 @putchar(i32 noundef 10)
  %43 = load ptr, ptr getelementptr inbounds (i8, ptr @hard20, i64 80), align 16, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(81) %3, ptr noundef nonnull align 1 dereferenceable(81) %43, i64 81, i1 false)
  %44 = call i32 @sd_solve(ptr noundef %12, ptr noundef nonnull %3)
  %45 = call i32 @putchar(i32 noundef 10)
  %46 = load ptr, ptr getelementptr inbounds (i8, ptr @hard20, i64 88), align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(81) %3, ptr noundef nonnull align 1 dereferenceable(81) %46, i64 81, i1 false)
  %47 = call i32 @sd_solve(ptr noundef %12, ptr noundef nonnull %3)
  %48 = call i32 @putchar(i32 noundef 10)
  %49 = load ptr, ptr getelementptr inbounds (i8, ptr @hard20, i64 96), align 16, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(81) %3, ptr noundef nonnull align 1 dereferenceable(81) %49, i64 81, i1 false)
  %50 = call i32 @sd_solve(ptr noundef %12, ptr noundef nonnull %3)
  %51 = call i32 @putchar(i32 noundef 10)
  %52 = load ptr, ptr getelementptr inbounds (i8, ptr @hard20, i64 104), align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(81) %3, ptr noundef nonnull align 1 dereferenceable(81) %52, i64 81, i1 false)
  %53 = call i32 @sd_solve(ptr noundef %12, ptr noundef nonnull %3)
  %54 = call i32 @putchar(i32 noundef 10)
  %55 = load ptr, ptr getelementptr inbounds (i8, ptr @hard20, i64 112), align 16, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(81) %3, ptr noundef nonnull align 1 dereferenceable(81) %55, i64 81, i1 false)
  %56 = call i32 @sd_solve(ptr noundef %12, ptr noundef nonnull %3)
  %57 = call i32 @putchar(i32 noundef 10)
  %58 = load ptr, ptr getelementptr inbounds (i8, ptr @hard20, i64 120), align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(81) %3, ptr noundef nonnull align 1 dereferenceable(81) %58, i64 81, i1 false)
  %59 = call i32 @sd_solve(ptr noundef %12, ptr noundef nonnull %3)
  %60 = call i32 @putchar(i32 noundef 10)
  %61 = load ptr, ptr getelementptr inbounds (i8, ptr @hard20, i64 128), align 16, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(81) %3, ptr noundef nonnull align 1 dereferenceable(81) %61, i64 81, i1 false)
  %62 = call i32 @sd_solve(ptr noundef %12, ptr noundef nonnull %3)
  %63 = call i32 @putchar(i32 noundef 10)
  %64 = load ptr, ptr getelementptr inbounds (i8, ptr @hard20, i64 136), align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(81) %3, ptr noundef nonnull align 1 dereferenceable(81) %64, i64 81, i1 false)
  %65 = call i32 @sd_solve(ptr noundef %12, ptr noundef nonnull %3)
  %66 = call i32 @putchar(i32 noundef 10)
  %67 = load ptr, ptr getelementptr inbounds (i8, ptr @hard20, i64 144), align 16, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(81) %3, ptr noundef nonnull align 1 dereferenceable(81) %67, i64 81, i1 false)
  %68 = call i32 @sd_solve(ptr noundef %12, ptr noundef nonnull %3)
  %69 = call i32 @putchar(i32 noundef 10)
  %70 = load ptr, ptr getelementptr inbounds (i8, ptr @hard20, i64 152), align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(81) %3, ptr noundef nonnull align 1 dereferenceable(81) %70, i64 81, i1 false)
  %71 = call i32 @sd_solve(ptr noundef %12, ptr noundef nonnull %3)
  %72 = call i32 @putchar(i32 noundef 10)
  %73 = add nuw nsw i32 %.012, 1
  %exitcond.not = icmp eq i32 %73, %.0915
  br i1 %exitcond.not, label %._crit_edge, label %.preheader, !llvm.loop !9

._crit_edge:                                      ; preds = %.preheader, %6
  %74 = phi ptr [ %10, %6 ], [ %12, %.preheader ]
  call void @free(ptr noundef %74) #6
  call void @llvm.lifetime.end.p0(i64 82, ptr nonnull %3) #6
  ret i32 0
}

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr nocapture noundef nonnull) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: inlinehint nofree nounwind uwtable
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #5

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint mustprogress nofree nounwind willreturn memory(read) 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { inlinehint 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" }
attributes #5 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(read) }

!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/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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