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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @derection_name(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
define dso_local void @split_and_check(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = call i32 @derection_name(ptr noundef %6)
  %8 = icmp ne i32 %7, 0
  br i1 %8, label %10, label %9

9:                                                ; preds = %2
  call void @ft_error(ptr noundef @.str.6, ptr noundef @.str.7)
  br label %130

10:                                               ; preds = %2
  br label %11

11:                                               ; preds = %29, %10
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = load i32, ptr %5, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds i8, ptr %12, i64 %14
  %16 = load i8, ptr %15, align 1, !tbaa !11
  %17 = sext i8 %16 to i32
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %27

19:                                               ; preds = %11
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds i8, ptr %20, i64 %22
  %24 = load i8, ptr %23, align 1, !tbaa !11
  %25 = sext i8 %24 to i32
  %26 = icmp eq i32 %25, 32
  br label %27

27:                                               ; preds = %19, %11
  %28 = phi i1 [ false, %11 ], [ %26, %19 ]
  br i1 %28, label %29, label %32

29:                                               ; preds = %27
  %30 = load i32, ptr %5, align 4, !tbaa !9
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %5, align 4, !tbaa !9
  br label %11, !llvm.loop !12

32:                                               ; preds = %27
  br label %33

33:                                               ; preds = %51, %32
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = load i32, ptr %5, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds i8, ptr %34, i64 %36
  %38 = load i8, ptr %37, align 1, !tbaa !11
  %39 = sext i8 %38 to i32
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %49

41:                                               ; preds = %33
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = load i32, ptr %5, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds i8, ptr %42, i64 %44
  %46 = load i8, ptr %45, align 1, !tbaa !11
  %47 = sext i8 %46 to i32
  %48 = icmp ne i32 %47, 32
  br label %49

49:                                               ; preds = %41, %33
  %50 = phi i1 [ false, %33 ], [ %48, %41 ]
  br i1 %50, label %51, label %54

51:                                               ; preds = %49
  %52 = load i32, ptr %5, align 4, !tbaa !9
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %5, align 4, !tbaa !9
  br label %33, !llvm.loop !14

54:                                               ; preds = %49
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = call i32 @derection_name(ptr noundef %55)
  %57 = icmp eq i32 %56, 16
  br i1 %57, label %58, label %66

58:                                               ; preds = %54
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = load i32, ptr %5, align 4, !tbaa !9
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds i8, ptr %59, i64 %61
  %63 = call ptr @ft_strtrim(ptr noundef %62, ptr noundef @.str.8)
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.s_map_result, ptr %64, i32 0, i32 3
  store ptr %63, ptr %65, align 8, !tbaa !15
  br label %129

66:                                               ; preds = %54
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = call i32 @derection_name(ptr noundef %67)
  %69 = icmp eq i32 %68, 15
  br i1 %69, label %70, label %78

70:                                               ; preds = %66
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = load i32, ptr %5, align 4, !tbaa !9
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds i8, ptr %71, i64 %73
  %75 = call ptr @ft_strtrim(ptr noundef %74, ptr noundef @.str.8)
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.s_map_result, ptr %76, i32 0, i32 2
  store ptr %75, ptr %77, align 8, !tbaa !17
  br label %128

78:                                               ; preds = %66
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  %80 = call i32 @derection_name(ptr noundef %79)
  %81 = icmp eq i32 %80, 17
  br i1 %81, label %82, label %90

82:                                               ; preds = %78
  %83 = load ptr, ptr %3, align 8, !tbaa !5
  %84 = load i32, ptr %5, align 4, !tbaa !9
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds i8, ptr %83, i64 %85
  %87 = call ptr @ft_strtrim(ptr noundef %86, ptr noundef @.str.8)
  %88 = load ptr, ptr %4, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.s_map_result, ptr %88, i32 0, i32 4
  store ptr %87, ptr %89, align 8, !tbaa !18
  br label %127

90:                                               ; preds = %78
  %91 = load ptr, ptr %3, align 8, !tbaa !5
  %92 = call i32 @derection_name(ptr noundef %91)
  %93 = icmp eq i32 %92, 18
  br i1 %93, label %94, label %102

94:                                               ; preds = %90
  %95 = load ptr, ptr %3, align 8, !tbaa !5
  %96 = load i32, ptr %5, align 4, !tbaa !9
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds i8, ptr %95, i64 %97
  %99 = call ptr @ft_strtrim(ptr noundef %98, ptr noundef @.str.8)
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.s_map_result, ptr %100, i32 0, i32 5
  store ptr %99, ptr %101, align 8, !tbaa !19
  br label %126

102:                                              ; preds = %90
  %103 = load ptr, ptr %3, align 8, !tbaa !5
  %104 = call i32 @derection_name(ptr noundef %103)
  %105 = icmp eq i32 %104, 21
  br i1 %105, label %106, label %113

106:                                              ; preds = %102
  %107 = load ptr, ptr %3, align 8, !tbaa !5
  %108 = load i32, ptr %5, align 4, !tbaa !9
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds i8, ptr %107, i64 %109
  %111 = call ptr @ft_strtrim(ptr noundef %110, ptr noundef @.str.8)
  %112 = load ptr, ptr %4, align 8, !tbaa !5
  call void @check_f_and_c(ptr noundef %111, ptr noundef %112, i32 noundef 6)
  br label %125

113:                                              ; preds = %102
  %114 = load ptr, ptr %3, align 8, !tbaa !5
  %115 = call i32 @derection_name(ptr noundef %114)
  %116 = icmp eq i32 %115, 20
  br i1 %116, label %117, label %124

117:                                              ; preds = %113
  %118 = load ptr, ptr %3, align 8, !tbaa !5
  %119 = load i32, ptr %5, align 4, !tbaa !9
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds i8, ptr %118, i64 %120
  %122 = call ptr @ft_strtrim(ptr noundef %121, ptr noundef @.str.8)
  %123 = load ptr, ptr %4, align 8, !tbaa !5
  call void @check_f_and_c(ptr noundef %122, ptr noundef %123, i32 noundef 3)
  br label %124

124:                                              ; preds = %117, %113
  br label %125

125:                                              ; preds = %124, %106
  br label %126

126:                                              ; preds = %125, %94
  br label %127

127:                                              ; preds = %126, %82
  br label %128

128:                                              ; preds = %127, %70
  br label %129

129:                                              ; preds = %128, %58
  br label %130

130:                                              ; preds = %129, %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void
}

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

declare ptr @ft_strtrim(ptr noundef, ptr noundef) #2

declare void @check_f_and_c(ptr noundef, ptr noundef, i32 noundef) #2

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 = { "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 = !{!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}
!15 = !{!16, !6, i64 16}
!16 = !{!"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}
!17 = !{!16, !6, i64 8}
!18 = !{!16, !6, i64 24}
!19 = !{!16, !6, i64 32}


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

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

; Function Attrs: nounwind uwtable
define dso_local void @split_and_check(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = tail call i32 @derection_name(ptr noundef %0)
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %4, label %.preheader

4:                                                ; preds = %2
  tail call void @ft_error(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.7) #2
  br label %43

.preheader:                                       ; preds = %2, %.preheader
  %indvars.iv = phi i64 [ %indvars.iv.next, %.preheader ], [ 0, %2 ]
  %5 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv
  %6 = load i8, ptr %5, align 1, !tbaa !5
  %cond = icmp eq i8 %6, 32
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  br i1 %cond, label %.preheader, label %.critedge, !llvm.loop !8

.critedge:                                        ; preds = %.preheader, %8
  %7 = phi i8 [ %.pre, %8 ], [ %6, %.preheader ]
  %indvars.iv43 = phi i64 [ %indvars.iv.next44, %8 ], [ %indvars.iv, %.preheader ]
  switch i8 %7, label %8 [
    i8 0, label %.critedge2
    i8 32, label %.critedge2
  ]

8:                                                ; preds = %.critedge
  %indvars.iv.next44 = add nuw nsw i64 %indvars.iv43, 1
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 %indvars.iv.next44
  %.pre = load i8, ptr %.phi.trans.insert, align 1, !tbaa !5
  br label %.critedge, !llvm.loop !10

.critedge2:                                       ; preds = %.critedge, %.critedge
  %9 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv43
  %10 = tail call i32 @derection_name(ptr noundef nonnull %0)
  %11 = icmp eq i32 %10, 16
  br i1 %11, label %12, label %15

12:                                               ; preds = %.critedge2
  %13 = tail call ptr @ft_strtrim(ptr noundef nonnull %9, ptr noundef nonnull @.str.8) #2
  %14 = getelementptr inbounds i8, ptr %1, i64 16
  store ptr %13, ptr %14, align 8, !tbaa !11
  br label %43

15:                                               ; preds = %.critedge2
  %16 = tail call i32 @derection_name(ptr noundef nonnull %0)
  %17 = icmp eq i32 %16, 15
  br i1 %17, label %18, label %21

18:                                               ; preds = %15
  %19 = tail call ptr @ft_strtrim(ptr noundef nonnull %9, ptr noundef nonnull @.str.8) #2
  %20 = getelementptr inbounds i8, ptr %1, i64 8
  store ptr %19, ptr %20, align 8, !tbaa !15
  br label %43

21:                                               ; preds = %15
  %22 = tail call i32 @derection_name(ptr noundef nonnull %0)
  %23 = icmp eq i32 %22, 17
  br i1 %23, label %24, label %27

24:                                               ; preds = %21
  %25 = tail call ptr @ft_strtrim(ptr noundef nonnull %9, ptr noundef nonnull @.str.8) #2
  %26 = getelementptr inbounds i8, ptr %1, i64 24
  store ptr %25, ptr %26, align 8, !tbaa !16
  br label %43

27:                                               ; preds = %21
  %28 = tail call i32 @derection_name(ptr noundef nonnull %0)
  %29 = icmp eq i32 %28, 18
  br i1 %29, label %30, label %33

30:                                               ; preds = %27
  %31 = tail call ptr @ft_strtrim(ptr noundef nonnull %9, ptr noundef nonnull @.str.8) #2
  %32 = getelementptr inbounds i8, ptr %1, i64 32
  store ptr %31, ptr %32, align 8, !tbaa !17
  br label %43

33:                                               ; preds = %27
  %34 = tail call i32 @derection_name(ptr noundef nonnull %0)
  %35 = icmp eq i32 %34, 21
  br i1 %35, label %36, label %38

36:                                               ; preds = %33
  %37 = tail call ptr @ft_strtrim(ptr noundef nonnull %9, ptr noundef nonnull @.str.8) #2
  tail call void @check_f_and_c(ptr noundef %37, ptr noundef %1, i32 noundef 6) #2
  br label %43

38:                                               ; preds = %33
  %39 = tail call i32 @derection_name(ptr noundef nonnull %0)
  %40 = icmp eq i32 %39, 20
  br i1 %40, label %41, label %43

41:                                               ; preds = %38
  %42 = tail call ptr @ft_strtrim(ptr noundef nonnull %9, ptr noundef nonnull @.str.8) #2
  tail call void @check_f_and_c(ptr noundef %42, ptr noundef %1, i32 noundef 3) #2
  br label %43

43:                                               ; preds = %12, %24, %36, %41, %38, %30, %18, %4
  ret void
}

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

declare ptr @ft_strtrim(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @check_f_and_c(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #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 = { "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 }

!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 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}
!11 = !{!12, !14, i64 16}
!12 = !{!"s_map_result", !13, i64 0, !13, i64 4, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !14, i64 40, !14, i64 48, !13, i64 56, !13, i64 60, !13, i64 64, !13, i64 68, !6, i64 72}
!13 = !{!"int", !6, i64 0}
!14 = !{!"any pointer", !6, i64 0}
!15 = !{!12, !14, i64 8}
!16 = !{!12, !14, i64 24}
!17 = !{!12, !14, i64 32}


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