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

%struct.s_col_name = type { ptr, i32 }

@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@mlx_col_name = external global [0 x %struct.s_col_name], align 8

; 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
define dso_local i32 @mlx_int_get_text_rgb(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca [64 x i8], align 16
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 64, ptr %7) #4
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = load i8, ptr %9, align 1, !tbaa !9
  %11 = sext i8 %10 to i32
  %12 = icmp eq i32 %11, 35
  br i1 %12, label %13, label %18

13:                                               ; preds = %2
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %14, i64 1
  %16 = call i64 @strtol(ptr noundef %15, ptr noundef null, i32 noundef 16) #4
  %17 = trunc i64 %16 to i32
  store i32 %17, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %54

18:                                               ; preds = %2
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %27

21:                                               ; preds = %18
  %22 = getelementptr inbounds [64 x i8], ptr %7, i64 0, i64 0
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %22, i64 noundef 64, ptr noundef @.str.1, ptr noundef %23, ptr noundef %24) #4
  %26 = getelementptr inbounds [64 x i8], ptr %7, i64 0, i64 0
  store ptr %26, ptr %4, align 8, !tbaa !5
  br label %27

27:                                               ; preds = %21, %18
  store i32 0, ptr %6, align 4, !tbaa !10
  br label %28

28:                                               ; preds = %50, %27
  %29 = load i32, ptr %6, align 4, !tbaa !10
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [0 x %struct.s_col_name], ptr @mlx_col_name, i64 0, i64 %30
  %32 = getelementptr inbounds %struct.s_col_name, ptr %31, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !12
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %53

35:                                               ; preds = %28
  %36 = load i32, ptr %6, align 4, !tbaa !10
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [0 x %struct.s_col_name], ptr @mlx_col_name, i64 0, i64 %37
  %39 = getelementptr inbounds %struct.s_col_name, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !12
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = call i32 @strcasecmp(ptr noundef %40, ptr noundef %41) #5
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %50, label %44

44:                                               ; preds = %35
  %45 = load i32, ptr %6, align 4, !tbaa !10
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [0 x %struct.s_col_name], ptr @mlx_col_name, i64 0, i64 %46
  %48 = getelementptr inbounds %struct.s_col_name, ptr %47, i32 0, i32 1
  %49 = load i32, ptr %48, align 8, !tbaa !14
  store i32 %49, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %54

50:                                               ; preds = %35
  %51 = load i32, ptr %6, align 4, !tbaa !10
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %6, align 4, !tbaa !10
  br label %28, !llvm.loop !15

53:                                               ; preds = %28
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %54

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

; Function Attrs: nounwind
declare i64 @strtol(ptr noundef, ptr noundef, i32 noundef) #2

; Function Attrs: nounwind
declare i32 @snprintf(ptr noundef, i64 noundef, ptr noundef, ...) #2

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcasecmp(ptr noundef, ptr noundef) #3

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 = { 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 #3 = { 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 #4 = { nounwind }
attributes #5 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !6, i64 0}
!13 = !{!"s_col_name", !6, i64 0, !11, i64 8}
!14 = !{!13, !11, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"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"

%struct.s_col_name = type { ptr, i32 }

@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@mlx_col_name = external local_unnamed_addr global [0 x %struct.s_col_name], align 8

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

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

; Function Attrs: nofree nounwind uwtable
define dso_local i32 @mlx_int_get_text_rgb(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = alloca [64 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %3) #5
  %4 = load i8, ptr %0, align 1, !tbaa !5
  %5 = icmp eq i8 %4, 35
  br i1 %5, label %6, label %10

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 1
  %8 = tail call i64 @strtol(ptr nocapture noundef nonnull %7, ptr noundef null, i32 noundef 16) #5
  %9 = trunc i64 %8 to i32
  br label %.loopexit

10:                                               ; preds = %2
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %13, label %11

11:                                               ; preds = %10
  %12 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %3, i64 noundef 64, ptr noundef nonnull @.str.1, ptr noundef nonnull %0, ptr noundef nonnull %1) #5
  br label %13

13:                                               ; preds = %11, %10
  %.011 = phi ptr [ %3, %11 ], [ %0, %10 ]
  %14 = load ptr, ptr @mlx_col_name, align 8, !tbaa !8
  %.not1417 = icmp eq ptr %14, null
  br i1 %.not1417, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %13
  %15 = call i32 @strcasecmp(ptr noundef nonnull %14, ptr noundef nonnull %.011) #6
  %.not1523 = icmp eq i32 %15, 0
  br i1 %.not1523, label %.lr.ph._crit_edge, label %.lr.ph25

.lr.ph25:                                         ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv24 = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.lr.ph.preheader ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv24, 1
  %16 = getelementptr inbounds [0 x %struct.s_col_name], ptr @mlx_col_name, i64 0, i64 %indvars.iv.next
  %17 = load ptr, ptr %16, align 8, !tbaa !8
  %.not14 = icmp eq ptr %17, null
  br i1 %.not14, label %.loopexit, label %.lr.ph, !llvm.loop !12

.lr.ph:                                           ; preds = %.lr.ph25
  %18 = call i32 @strcasecmp(ptr noundef nonnull %17, ptr noundef nonnull %.011) #6
  %.not15 = icmp eq i32 %18, 0
  br i1 %.not15, label %.lr.ph._crit_edge, label %.lr.ph25, !llvm.loop !12

.lr.ph._crit_edge:                                ; preds = %.lr.ph, %.lr.ph.preheader
  %.lcssa = phi ptr [ @mlx_col_name, %.lr.ph.preheader ], [ %16, %.lr.ph ]
  %19 = getelementptr inbounds i8, ptr %.lcssa, i64 8
  %20 = load i32, ptr %19, align 8, !tbaa !14
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph25, %13, %.lr.ph._crit_edge, %6
  %.010 = phi i32 [ %9, %6 ], [ %20, %.lr.ph._crit_edge ], [ 0, %13 ], [ 0, %.lr.ph25 ]
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %3) #5
  ret i32 %.010
}

; Function Attrs: mustprogress nofree nounwind willreturn
declare i64 @strtol(ptr noundef readonly, ptr nocapture noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @snprintf(ptr noalias nocapture noundef writeonly, i64 noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(read)
declare i32 @strcasecmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress nofree nounwind willreturn "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 = { nofree 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 #4 = { mustprogress nofree 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 #5 = { nounwind }
attributes #6 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !10, i64 0}
!9 = !{!"s_col_name", !10, i64 0, !11, i64 8}
!10 = !{!"any pointer", !6, i64 0}
!11 = !{!"int", !6, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!9, !11, i64 8}


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