; LLVM IR from Water-Melon/Melon :: src (mln_lex)

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

%union.mln_lex_off_t = type { ptr }
%struct.mln_lex_s = type { ptr, ptr, ptr, ptr, %struct.mln_lex_hooks_t, ptr, ptr, ptr, ptr, i64, i64, i32, i8, ptr, ptr }
%struct.mln_lex_hooks_t = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.mln_stack_t = type { ptr, ptr, ptr, ptr, i64, ptr, ptr }
%struct.mln_stack_node_s = type { ptr, ptr, ptr }
%struct.mln_lex_input_t = type { i32, i32, ptr, ptr, ptr, ptr, i64, i64 }

; 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
declare i64 @lseek(i32 noundef, i64 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @mln_lex_snapshot_apply(ptr noundef %0, ptr %1) #2 {
  %3 = alloca %union.mln_lex_off_t, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = getelementptr inbounds %union.mln_lex_off_t, ptr %3, i32 0, i32 0
  store ptr %1, ptr %8, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.mln_lex_s, ptr %9, i32 0, i32 2
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  store ptr %11, ptr %5, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = icmp eq ptr %12, null
  br i1 %13, label %14, label %34

14:                                               ; preds = %2
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.mln_lex_s, ptr %15, i32 0, i32 3
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  %18 = getelementptr inbounds %struct.mln_stack_t, ptr %17, i32 0, i32 1
  %19 = load ptr, ptr %18, align 8, !tbaa !15
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %22

21:                                               ; preds = %14
  br label %30

22:                                               ; preds = %14
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.mln_lex_s, ptr %23, i32 0, i32 3
  %25 = load ptr, ptr %24, align 8, !tbaa !14
  %26 = getelementptr inbounds %struct.mln_stack_t, ptr %25, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !15
  %28 = getelementptr inbounds %struct.mln_stack_node_s, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !17
  br label %30

30:                                               ; preds = %22, %21
  %31 = phi ptr [ null, %21 ], [ %29, %22 ]
  store ptr %31, ptr %5, align 8, !tbaa !5
  %32 = icmp eq ptr %31, null
  br i1 %32, label %33, label %34

33:                                               ; preds = %30
  store i32 1, ptr %6, align 4
  br label %96

34:                                               ; preds = %30, %2
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.mln_lex_input_t, ptr %35, i32 0, i32 0
  %37 = load i32, ptr %36, align 8, !tbaa !19
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %39, label %60

39:                                               ; preds = %34
  %40 = load ptr, ptr %3, align 8, !tbaa !21
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.mln_lex_input_t, ptr %41, i32 0, i32 4
  %43 = load ptr, ptr %42, align 8, !tbaa !22
  %44 = icmp ult ptr %40, %43
  br i1 %44, label %55, label %45

45:                                               ; preds = %39
  %46 = load ptr, ptr %3, align 8, !tbaa !21
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.mln_lex_input_t, ptr %47, i32 0, i32 4
  %49 = load ptr, ptr %48, align 8, !tbaa !22
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.mln_lex_input_t, ptr %50, i32 0, i32 6
  %52 = load i64, ptr %51, align 8, !tbaa !23
  %53 = getelementptr inbounds i8, ptr %49, i64 %52
  %54 = icmp uge ptr %46, %53
  br i1 %54, label %55, label %56

55:                                               ; preds = %45, %39
  store i32 1, ptr %6, align 4
  br label %96

56:                                               ; preds = %45
  %57 = load ptr, ptr %3, align 8, !tbaa !21
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.mln_lex_input_t, ptr %58, i32 0, i32 5
  store ptr %57, ptr %59, align 8, !tbaa !24
  br label %95

60:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.mln_lex_input_t, ptr %61, i32 0, i32 1
  %63 = load i32, ptr %62, align 4, !tbaa !25
  %64 = call i64 @lseek(i32 noundef %63, i64 noundef 0, i32 noundef 1) #3
  store i64 %64, ptr %7, align 8, !tbaa !26
  %65 = load i64, ptr %3, align 8, !tbaa !21
  %66 = load i64, ptr %7, align 8, !tbaa !26
  %67 = icmp sge i64 %65, %66
  br i1 %67, label %76, label %68

68:                                               ; preds = %60
  %69 = load i64, ptr %3, align 8, !tbaa !21
  %70 = load i64, ptr %7, align 8, !tbaa !26
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.mln_lex_input_t, ptr %71, i32 0, i32 6
  %73 = load i64, ptr %72, align 8, !tbaa !23
  %74 = sub i64 %70, %73
  %75 = icmp ult i64 %69, %74
  br i1 %75, label %76, label %77

76:                                               ; preds = %68, %60
  store i32 1, ptr %6, align 4
  br label %92

77:                                               ; preds = %68
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.mln_lex_input_t, ptr %78, i32 0, i32 1
  %80 = load i32, ptr %79, align 4, !tbaa !25
  %81 = load i64, ptr %3, align 8, !tbaa !21
  %82 = call i64 @lseek(i32 noundef %80, i64 noundef %81, i32 noundef 0) #3
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.mln_lex_input_t, ptr %83, i32 0, i32 4
  %85 = load ptr, ptr %84, align 8, !tbaa !22
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.mln_lex_input_t, ptr %86, i32 0, i32 6
  %88 = load i64, ptr %87, align 8, !tbaa !23
  %89 = getelementptr inbounds i8, ptr %85, i64 %88
  %90 = load ptr, ptr %5, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.mln_lex_input_t, ptr %90, i32 0, i32 5
  store ptr %89, ptr %91, align 8, !tbaa !24
  store i32 0, ptr %6, align 4
  br label %92

92:                                               ; preds = %77, %76
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  %93 = load i32, ptr %6, align 4
  switch i32 %93, label %96 [
    i32 0, label %94
  ]

94:                                               ; preds = %92
  br label %95

95:                                               ; preds = %94, %56
  store i32 0, ptr %6, align 4
  br label %96

96:                                               ; preds = %95, %92, %55, %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  %97 = load i32, ptr %6, align 4
  switch i32 %97, label %99 [
    i32 0, label %98
    i32 1, label %98
  ]

98:                                               ; preds = %96, %96
  ret void

99:                                               ; preds = %96
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 }

!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, !6, i64 16}
!10 = !{!"mln_lex_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !11, i64 32, !6, i64 544, !6, i64 552, !6, i64 560, !6, i64 568, !12, i64 576, !12, i64 584, !13, i64 592, !13, i64 596, !13, i64 596, !6, i64 600, !6, i64 608}
!11 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !6, i64 296, !6, i64 304, !6, i64 312, !6, i64 320, !6, i64 328, !6, i64 336, !6, i64 344, !6, i64 352, !6, i64 360, !6, i64 368, !6, i64 376, !6, i64 384, !6, i64 392, !6, i64 400, !6, i64 408, !6, i64 416, !6, i64 424, !6, i64 432, !6, i64 440, !6, i64 448, !6, i64 456, !6, i64 464, !6, i64 472, !6, i64 480, !6, i64 488, !6, i64 496, !6, i64 504}
!12 = !{!"long", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!10, !6, i64 24}
!15 = !{!16, !6, i64 8}
!16 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !12, i64 32, !6, i64 40, !6, i64 48}
!17 = !{!18, !6, i64 0}
!18 = !{!"mln_stack_node_s", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!20, !13, i64 0}
!20 = !{!"", !13, i64 0, !13, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !12, i64 40, !12, i64 48}
!21 = !{!7, !7, i64 0}
!22 = !{!20, !6, i64 24}
!23 = !{!20, !12, i64 40}
!24 = !{!20, !6, i64 32}
!25 = !{!20, !13, i64 4}
!26 = !{!12, !12, 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"

; Function Attrs: nounwind
declare i64 @lseek(i32 noundef, i64 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @mln_lex_snapshot_apply(ptr nocapture noundef readonly %0, ptr %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = icmp eq ptr %4, null
  br i1 %5, label %6, label %15

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = load ptr, ptr %7, align 8, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %8, i64 8
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  %11 = icmp eq ptr %10, null
  br i1 %11, label %.thread, label %12

12:                                               ; preds = %6
  %13 = load ptr, ptr %10, align 8, !tbaa !16
  %14 = icmp eq ptr %13, null
  br i1 %14, label %.thread, label %15

15:                                               ; preds = %12, %2
  %.0 = phi ptr [ %13, %12 ], [ %4, %2 ]
  %16 = load i32, ptr %.0, align 8, !tbaa !18
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %18, label %26

18:                                               ; preds = %15
  %19 = getelementptr inbounds i8, ptr %.0, i64 24
  %20 = load ptr, ptr %19, align 8, !tbaa !20
  %21 = icmp ugt ptr %20, %1
  br i1 %21, label %.thread, label %22

22:                                               ; preds = %18
  %23 = getelementptr inbounds i8, ptr %.0, i64 40
  %24 = load i64, ptr %23, align 8, !tbaa !21
  %25 = getelementptr inbounds i8, ptr %20, i64 %24
  %.not29 = icmp ugt ptr %25, %1
  br i1 %.not29, label %.thread.sink.split, label %.thread

26:                                               ; preds = %15
  %27 = getelementptr inbounds i8, ptr %.0, i64 4
  %28 = load i32, ptr %27, align 4, !tbaa !22
  %29 = tail call i64 @lseek(i32 noundef %28, i64 noundef 0, i32 noundef 1) #2
  %30 = ptrtoint ptr %1 to i64
  %.not = icmp sgt i64 %29, %30
  br i1 %.not, label %31, label %.thread

31:                                               ; preds = %26
  %32 = getelementptr inbounds i8, ptr %.0, i64 40
  %33 = load i64, ptr %32, align 8, !tbaa !21
  %34 = sub i64 %29, %33
  %35 = icmp ugt i64 %34, %30
  br i1 %35, label %.thread, label %.critedge

.critedge:                                        ; preds = %31
  %36 = load i32, ptr %27, align 4, !tbaa !22
  %37 = tail call i64 @lseek(i32 noundef %36, i64 noundef %30, i32 noundef 0) #2
  %38 = getelementptr inbounds i8, ptr %.0, i64 24
  %39 = load ptr, ptr %38, align 8, !tbaa !20
  %40 = load i64, ptr %32, align 8, !tbaa !21
  %41 = getelementptr inbounds i8, ptr %39, i64 %40
  br label %.thread.sink.split

.thread.sink.split:                               ; preds = %22, %.critedge
  %.sink = phi ptr [ %41, %.critedge ], [ %1, %22 ]
  %42 = getelementptr inbounds i8, ptr %.0, i64 32
  store ptr %.sink, ptr %42, align 8, !tbaa !23
  br label %.thread

.thread:                                          ; preds = %.thread.sink.split, %6, %31, %26, %18, %22, %12
  ret void
}

attributes #0 = { 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 #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 }

!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, !7, i64 16}
!6 = !{!"mln_lex_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !7, i64 544, !7, i64 552, !7, i64 560, !7, i64 568, !11, i64 576, !11, i64 584, !12, i64 592, !12, i64 596, !12, i64 596, !7, i64 600, !7, i64 608}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !7, i64 160, !7, i64 168, !7, i64 176, !7, i64 184, !7, i64 192, !7, i64 200, !7, i64 208, !7, i64 216, !7, i64 224, !7, i64 232, !7, i64 240, !7, i64 248, !7, i64 256, !7, i64 264, !7, i64 272, !7, i64 280, !7, i64 288, !7, i64 296, !7, i64 304, !7, i64 312, !7, i64 320, !7, i64 328, !7, i64 336, !7, i64 344, !7, i64 352, !7, i64 360, !7, i64 368, !7, i64 376, !7, i64 384, !7, i64 392, !7, i64 400, !7, i64 408, !7, i64 416, !7, i64 424, !7, i64 432, !7, i64 440, !7, i64 448, !7, i64 456, !7, i64 464, !7, i64 472, !7, i64 480, !7, i64 488, !7, i64 496, !7, i64 504}
!11 = !{!"long", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!6, !7, i64 24}
!14 = !{!15, !7, i64 8}
!15 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !11, i64 32, !7, i64 40, !7, i64 48}
!16 = !{!17, !7, i64 0}
!17 = !{!"mln_stack_node_s", !7, i64 0, !7, i64 8, !7, i64 16}
!18 = !{!19, !12, i64 0}
!19 = !{!"", !12, i64 0, !12, i64 4, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !11, i64 40, !11, i64 48}
!20 = !{!19, !7, i64 24}
!21 = !{!19, !11, i64 40}
!22 = !{!19, !12, i64 4}
!23 = !{!19, !7, i64 32}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass