; LLVM IR from IOsonata/IOsonata :: src (iosonata_logo_dither)

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

@g_IOsonataPortrait = external dso_local constant [392 x ptr], align 16

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

15:                                               ; preds = %77, %3
  %16 = load i32, ptr %8, align 4, !tbaa !9
  %17 = load i32, ptr %7, align 4, !tbaa !9
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  store i32 2, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %80

20:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %21 = load i32, ptr %8, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [392 x ptr], ptr @g_IOsonataPortrait, i64 0, i64 %22
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  store ptr %24, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #3
  store i8 -128, ptr %11, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #3
  store i8 0, ptr %12, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = load i32, ptr %8, align 4, !tbaa !9
  %27 = mul nsw i32 %26, 280
  %28 = sdiv i32 %27, 8
  %29 = add nsw i32 %28, 1400
  %30 = add nsw i32 %29, 5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds i8, ptr %25, i64 %31
  store ptr %32, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %71, %20
  %34 = load i32, ptr %14, align 4, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = load i32, ptr %8, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [392 x ptr], ptr @g_IOsonataPortrait, i64 0, i64 %37
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  %40 = call i64 @strlen(ptr noundef %39) #4
  %41 = icmp ult i64 %35, %40
  br i1 %41, label %43, label %42

42:                                               ; preds = %33
  store i32 5, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  br label %76

43:                                               ; preds = %33
  %44 = load i8, ptr %12, align 1, !tbaa !11
  %45 = zext i8 %44 to i32
  %46 = shl i32 %45, 1
  %47 = trunc i32 %46 to i8
  store i8 %47, ptr %12, align 1, !tbaa !11
  %48 = load ptr, ptr %10, align 8, !tbaa !5
  %49 = load i8, ptr %48, align 1, !tbaa !11
  %50 = sext i8 %49 to i32
  %51 = icmp eq i32 %50, 49
  br i1 %51, label %52, label %57

52:                                               ; preds = %43
  %53 = load i8, ptr %12, align 1, !tbaa !11
  %54 = zext i8 %53 to i32
  %55 = or i32 %54, 1
  %56 = trunc i32 %55 to i8
  store i8 %56, ptr %12, align 1, !tbaa !11
  br label %57

57:                                               ; preds = %52, %43
  %58 = load i8, ptr %11, align 1, !tbaa !11
  %59 = zext i8 %58 to i32
  %60 = ashr i32 %59, 1
  %61 = trunc i32 %60 to i8
  store i8 %61, ptr %11, align 1, !tbaa !11
  %62 = load i8, ptr %11, align 1, !tbaa !11
  %63 = zext i8 %62 to i32
  %64 = icmp eq i32 %63, 0
  br i1 %64, label %65, label %70

65:                                               ; preds = %57
  store i8 -128, ptr %11, align 1, !tbaa !11
  %66 = load i8, ptr %12, align 1, !tbaa !11
  %67 = load ptr, ptr %13, align 8, !tbaa !5
  store i8 %66, ptr %67, align 1, !tbaa !11
  %68 = load ptr, ptr %13, align 8, !tbaa !5
  %69 = getelementptr inbounds i8, ptr %68, i32 1
  store ptr %69, ptr %13, align 8, !tbaa !5
  store i8 0, ptr %12, align 1, !tbaa !11
  br label %70

70:                                               ; preds = %65, %57
  br label %71

71:                                               ; preds = %70
  %72 = load i32, ptr %14, align 4, !tbaa !9
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %14, align 4, !tbaa !9
  %74 = load ptr, ptr %10, align 8, !tbaa !5
  %75 = getelementptr inbounds i8, ptr %74, i32 1
  store ptr %75, ptr %10, align 8, !tbaa !5
  br label %33, !llvm.loop !12

76:                                               ; preds = %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %77

77:                                               ; preds = %76
  %78 = load i32, ptr %8, align 4, !tbaa !9
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %8, align 4, !tbaa !9
  br label %15, !llvm.loop !14

80:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret void
}

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

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #2

; 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 willreturn memory(read) "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 }
attributes #4 = { 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 = !{!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"

@g_IOsonataPortrait = external dso_local local_unnamed_addr constant [392 x ptr], align 16

; Function Attrs: nofree nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @PlaceIOsonata(ptr nocapture noundef writeonly %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %invariant.gep = getelementptr inbounds i8, ptr %0, i64 1405
  br label %5

4:                                                ; preds = %._crit_edge
  ret void

5:                                                ; preds = %3, %._crit_edge
  %indvars.iv30 = phi i64 [ 0, %3 ], [ %indvars.iv.next31, %._crit_edge ]
  %6 = getelementptr inbounds [392 x ptr], ptr @g_IOsonataPortrait, i64 0, i64 %indvars.iv30
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %char0 = load i8, ptr %7, align 1
  %.not = icmp eq i8 %char0, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %5
  %8 = mul nuw nsw i64 %indvars.iv30, 35
  %gep = getelementptr inbounds i8, ptr %invariant.gep, i64 %8
  br label %.lr.ph

._crit_edge:                                      ; preds = %18, %5
  %indvars.iv.next31 = add nuw nsw i64 %indvars.iv30, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next31, 392
  br i1 %exitcond.not, label %4, label %5, !llvm.loop !9

.lr.ph:                                           ; preds = %.lr.ph.preheader, %18
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %18 ]
  %.01727 = phi ptr [ %gep, %.lr.ph.preheader ], [ %.1, %18 ]
  %.01826 = phi i8 [ 0, %.lr.ph.preheader ], [ %.2, %18 ]
  %.02025 = phi i32 [ 128, %.lr.ph.preheader ], [ %.121, %18 ]
  %.02224 = phi ptr [ %7, %.lr.ph.preheader ], [ %19, %18 ]
  %9 = shl i8 %.01826, 1
  %10 = load i8, ptr %.02224, align 1, !tbaa !11
  %11 = icmp eq i8 %10, 49
  %12 = zext i1 %11 to i8
  %spec.select = or disjoint i8 %9, %12
  %13 = lshr i32 %.02025, 1
  %14 = and i32 %13, 127
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %18

16:                                               ; preds = %.lr.ph
  store i8 %spec.select, ptr %.01727, align 1, !tbaa !11
  %17 = getelementptr inbounds i8, ptr %.01727, i64 1
  br label %18

18:                                               ; preds = %.lr.ph, %16
  %.121 = phi i32 [ 128, %16 ], [ %14, %.lr.ph ]
  %.2 = phi i8 [ 0, %16 ], [ %spec.select, %.lr.ph ]
  %.1 = phi ptr [ %17, %16 ], [ %.01727, %.lr.ph ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %19 = getelementptr inbounds i8, ptr %.02224, i64 1
  %20 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %7) #2
  %21 = icmp ugt i64 %20, %indvars.iv.next
  br i1 %21, label %.lr.ph, label %._crit_edge, !llvm.loop !12
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #1

attributes #0 = { nofree nounwind memory(readwrite, inaccessiblemem: 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" }
attributes #1 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 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"}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !10}


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