; LLVM IR from yettabaa/cub3D :: Mandatory/parsing (first_lines)

; 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_map_result = type { i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i8 }

@.str.1 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [23 x i8], align 1

declare i64 @ft_atoi(ptr noundef) #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 void @if_int(ptr noundef) #2

declare void @free_array(ptr noundef) #0

declare void @ft_error(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @coma_split(ptr noundef %0, i32 noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !9
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = call ptr @ft_split(ptr noundef %9, i8 noundef signext 44)
  store ptr %10, ptr %7, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %18, %3
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  %13 = load i32, ptr %8, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds ptr, ptr %12, i64 %14
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %21

18:                                               ; preds = %11
  %19 = load i32, ptr %8, align 4, !tbaa !9
  %20 = add nsw i32 %19, 1
  store i32 %20, ptr %8, align 4, !tbaa !9
  br label %11, !llvm.loop !11

21:                                               ; preds = %11
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = icmp ne i32 %22, 3
  br i1 %23, label %24, label %26

24:                                               ; preds = %21
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  call void @free_array(ptr noundef %25)
  call void @ft_error(ptr noundef @.str.3, ptr noundef @.str.1)
  br label %26

26:                                               ; preds = %24, %21
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  call void @if_int(ptr noundef %27)
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = icmp eq i32 %28, 3
  br i1 %29, label %30, label %49

30:                                               ; preds = %26
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds ptr, ptr %31, i64 0
  %33 = load ptr, ptr %32, align 8, !tbaa !5
  %34 = call i64 @ft_atoi(ptr noundef %33)
  %35 = trunc i64 %34 to i32
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds ptr, ptr %36, i64 1
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  %39 = call i64 @ft_atoi(ptr noundef %38)
  %40 = trunc i64 %39 to i32
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds ptr, ptr %41, i64 2
  %43 = load ptr, ptr %42, align 8, !tbaa !5
  %44 = call i64 @ft_atoi(ptr noundef %43)
  %45 = trunc i64 %44 to i32
  %46 = call i32 @create_trgb(i32 noundef 0, i32 noundef %35, i32 noundef %40, i32 noundef %45)
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.s_map_result, ptr %47, i32 0, i32 1
  store i32 %46, ptr %48, align 4, !tbaa !13
  br label %49

49:                                               ; preds = %30, %26
  %50 = load i32, ptr %5, align 4, !tbaa !9
  %51 = icmp eq i32 %50, 6
  br i1 %51, label %52, label %71

52:                                               ; preds = %49
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = getelementptr inbounds ptr, ptr %53, i64 0
  %55 = load ptr, ptr %54, align 8, !tbaa !5
  %56 = call i64 @ft_atoi(ptr noundef %55)
  %57 = trunc i64 %56 to i32
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = getelementptr inbounds ptr, ptr %58, i64 1
  %60 = load ptr, ptr %59, align 8, !tbaa !5
  %61 = call i64 @ft_atoi(ptr noundef %60)
  %62 = trunc i64 %61 to i32
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = getelementptr inbounds ptr, ptr %63, i64 2
  %65 = load ptr, ptr %64, align 8, !tbaa !5
  %66 = call i64 @ft_atoi(ptr noundef %65)
  %67 = trunc i64 %66 to i32
  %68 = call i32 @create_trgb(i32 noundef 0, i32 noundef %57, i32 noundef %62, i32 noundef %67)
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.s_map_result, ptr %69, i32 0, i32 0
  store i32 %68, ptr %70, align 8, !tbaa !15
  br label %71

71:                                               ; preds = %52, %49
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  call void @free_array(ptr noundef %72)
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free(ptr noundef %73) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret void
}

declare ptr @ft_split(ptr noundef, i8 noundef signext) #0

declare i32 @create_trgb(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { 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 = !{!14, !10, i64 4}
!14 = !{!"s_map_result", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !7, i64 72}
!15 = !{!14, !10, i64 0}


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

declare i64 @ft_atoi(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @if_int(ptr noundef) local_unnamed_addr #1

declare void @free_array(ptr noundef) local_unnamed_addr #0

declare void @ft_error(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @coma_split(ptr noundef %0, i32 noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 {
  %4 = tail call ptr @ft_split(ptr noundef %0, i8 noundef signext 44) #3
  br label %5

5:                                                ; preds = %5, %3
  %indvars.iv = phi i64 [ %indvars.iv.next, %5 ], [ 0, %3 ]
  %6 = getelementptr inbounds ptr, ptr %4, i64 %indvars.iv
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %.not = icmp eq ptr %7, null
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  br i1 %.not, label %8, label %5, !llvm.loop !9

8:                                                ; preds = %5
  %.not18 = icmp eq i64 %indvars.iv, 3
  br i1 %.not18, label %10, label %9

9:                                                ; preds = %8
  tail call void @free_array(ptr noundef nonnull %4) #3
  tail call void @ft_error(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1) #3
  br label %10

10:                                               ; preds = %9, %8
  tail call void @if_int(ptr noundef nonnull %4)
  switch i32 %1, label %38 [
    i32 3, label %11
    i32 6, label %25
  ]

11:                                               ; preds = %10
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = tail call i64 @ft_atoi(ptr noundef %12) #3
  %14 = trunc i64 %13 to i32
  %15 = getelementptr inbounds i8, ptr %4, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  %17 = tail call i64 @ft_atoi(ptr noundef %16) #3
  %18 = trunc i64 %17 to i32
  %19 = getelementptr inbounds i8, ptr %4, i64 16
  %20 = load ptr, ptr %19, align 8, !tbaa !5
  %21 = tail call i64 @ft_atoi(ptr noundef %20) #3
  %22 = trunc i64 %21 to i32
  %23 = tail call i32 @create_trgb(i32 noundef 0, i32 noundef %14, i32 noundef %18, i32 noundef %22) #3
  %24 = getelementptr inbounds i8, ptr %2, i64 4
  store i32 %23, ptr %24, align 4, !tbaa !11
  br label %38

25:                                               ; preds = %10
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = tail call i64 @ft_atoi(ptr noundef %26) #3
  %28 = trunc i64 %27 to i32
  %29 = getelementptr inbounds i8, ptr %4, i64 8
  %30 = load ptr, ptr %29, align 8, !tbaa !5
  %31 = tail call i64 @ft_atoi(ptr noundef %30) #3
  %32 = trunc i64 %31 to i32
  %33 = getelementptr inbounds i8, ptr %4, i64 16
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  %35 = tail call i64 @ft_atoi(ptr noundef %34) #3
  %36 = trunc i64 %35 to i32
  %37 = tail call i32 @create_trgb(i32 noundef 0, i32 noundef %28, i32 noundef %32, i32 noundef %36) #3
  store i32 %37, ptr %2, align 8, !tbaa !14
  br label %38

38:                                               ; preds = %11, %10, %25
  tail call void @free_array(ptr noundef nonnull %4) #3
  tail call void @free(ptr noundef %0) #3
  ret void
}

declare ptr @ft_split(ptr noundef, i8 noundef signext) local_unnamed_addr #0

declare i32 @create_trgb(i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #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 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 #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 = !{!"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 = !{!12, !13, i64 4}
!12 = !{!"s_map_result", !13, i64 0, !13, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !13, i64 56, !13, i64 60, !13, i64 64, !13, i64 68, !7, i64 72}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !13, i64 0}


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