; LLVM IR from yettabaa/cub3D :: mlx-linux (mlx_xpm)

; 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.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1

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

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

8:                                                ; preds = %13, %2
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = load i32, ptr %5, align 4, !tbaa !9
  %11 = call i32 @mlx_int_str_str_cote(ptr noundef %9, ptr noundef @.str.3, i32 noundef %10)
  store i32 %11, ptr %6, align 4, !tbaa !9
  %12 = icmp ne i32 %11, -1
  br i1 %12, label %13, label %31

13:                                               ; preds = %8
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = load i32, ptr %6, align 4, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds i8, ptr %14, i64 %16
  %18 = getelementptr inbounds i8, ptr %17, i64 2
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = load i32, ptr %6, align 4, !tbaa !9
  %21 = sub nsw i32 %19, %20
  %22 = sub nsw i32 %21, 2
  %23 = call i32 @mlx_int_str_str(ptr noundef %18, ptr noundef @.str.4, i32 noundef %22)
  store i32 %23, ptr %7, align 4, !tbaa !9
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = load i32, ptr %6, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds i8, ptr %24, i64 %26
  %28 = load i32, ptr %7, align 4, !tbaa !9
  %29 = add nsw i32 %28, 4
  %30 = sext i32 %29 to i64
  call void @llvm.memset.p0.i64(ptr align 1 %27, i8 32, i64 %30, i1 false)
  br label %8, !llvm.loop !11

31:                                               ; preds = %8
  br label %32

32:                                               ; preds = %37, %31
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = load i32, ptr %5, align 4, !tbaa !9
  %35 = call i32 @mlx_int_str_str_cote(ptr noundef %33, ptr noundef @.str.5, i32 noundef %34)
  store i32 %35, ptr %6, align 4, !tbaa !9
  %36 = icmp ne i32 %35, -1
  br i1 %36, label %37, label %55

37:                                               ; preds = %32
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds i8, ptr %38, i64 %40
  %42 = getelementptr inbounds i8, ptr %41, i64 2
  %43 = load i32, ptr %5, align 4, !tbaa !9
  %44 = load i32, ptr %6, align 4, !tbaa !9
  %45 = sub nsw i32 %43, %44
  %46 = sub nsw i32 %45, 2
  %47 = call i32 @mlx_int_str_str(ptr noundef %42, ptr noundef @.str.6, i32 noundef %46)
  store i32 %47, ptr %7, align 4, !tbaa !9
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = load i32, ptr %6, align 4, !tbaa !9
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds i8, ptr %48, i64 %50
  %52 = load i32, ptr %7, align 4, !tbaa !9
  %53 = add nsw i32 %52, 3
  %54 = sext i32 %53 to i64
  call void @llvm.memset.p0.i64(ptr align 1 %51, i8 32, i64 %54, i1 false)
  br label %32, !llvm.loop !13

55:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %56 = load i32, ptr %3, align 4
  ret i32 %56
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !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"

@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1

declare i32 @mlx_int_str_str(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @mlx_int_file_get_rid_comment(ptr noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = tail call i32 @mlx_int_str_str_cote(ptr noundef %0, ptr noundef nonnull @.str.3, i32 noundef %1) #3
  %.not21 = icmp eq i32 %3, -1
  br i1 %.not21, label %.preheader, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %4 = add i32 %1, -2
  br label %7

.preheader:                                       ; preds = %7, %2
  %5 = tail call i32 @mlx_int_str_str_cote(ptr noundef %0, ptr noundef nonnull @.str.5, i32 noundef %1) #3
  %.not1922 = icmp eq i32 %5, -1
  br i1 %.not1922, label %._crit_edge, label %.lr.ph23

.lr.ph23:                                         ; preds = %.preheader
  %6 = add i32 %1, -2
  br label %17

7:                                                ; preds = %.lr.ph, %7
  %8 = phi i32 [ %3, %.lr.ph ], [ %16, %7 ]
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds i8, ptr %0, i64 %9
  %11 = getelementptr inbounds i8, ptr %10, i64 2
  %12 = sub i32 %4, %8
  %13 = tail call i32 @mlx_int_str_str(ptr noundef nonnull %11, ptr noundef nonnull @.str.4, i32 noundef %12) #3
  %14 = add nsw i32 %13, 4
  %15 = sext i32 %14 to i64
  tail call void @llvm.memset.p0.i64(ptr align 1 %10, i8 32, i64 %15, i1 false)
  %16 = tail call i32 @mlx_int_str_str_cote(ptr noundef %0, ptr noundef nonnull @.str.3, i32 noundef %1) #3
  %.not = icmp eq i32 %16, -1
  br i1 %.not, label %.preheader, label %7, !llvm.loop !5

17:                                               ; preds = %.lr.ph23, %17
  %18 = phi i32 [ %5, %.lr.ph23 ], [ %26, %17 ]
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds i8, ptr %0, i64 %19
  %21 = getelementptr inbounds i8, ptr %20, i64 2
  %22 = sub i32 %6, %18
  %23 = tail call i32 @mlx_int_str_str(ptr noundef nonnull %21, ptr noundef nonnull @.str.6, i32 noundef %22) #3
  %24 = add nsw i32 %23, 3
  %25 = sext i32 %24 to i64
  tail call void @llvm.memset.p0.i64(ptr align 1 %20, i8 32, i64 %25, i1 false)
  %26 = tail call i32 @mlx_int_str_str_cote(ptr noundef %0, ptr noundef nonnull @.str.5, i32 noundef %1) #3
  %.not19 = icmp eq i32 %26, -1
  br i1 %.not19, label %._crit_edge, label %17, !llvm.loop !7

._crit_edge:                                      ; preds = %17, %.preheader
  ret i32 undef
}

declare i32 @mlx_int_str_str_cote(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

attributes #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 = { 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}


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