; LLVM IR from masyagin1998/GCI :: src/lexer (token)

; 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.POS = type { ptr, i64, i64, i64, i64 }
%struct.TOKEN = type { i32, i32, %struct.FRAG, %union.anon }
%struct.FRAG = type { %struct.POS, %struct.POS }
%union.anon = type { i64, [24 x i8] }

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @create_token() #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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare void @pos_next(ptr dead_on_unwind writable sret(%struct.POS) align 8, ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @token_read_number(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca %struct.POS, align 8
  %8 = alloca %struct.POS, align 8
  %9 = alloca %struct.POS, align 8
  %10 = alloca %struct.POS, align 8
  %11 = alloca [64 x i8], align 16
  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) #6
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 40, ptr %7) #6
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 8 %12, i64 40, i1 false), !tbaa.struct !11
  %13 = call ptr @create_token()
  store ptr %13, ptr %6, align 8, !tbaa !5
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.TOKEN, ptr %14, i32 0, i32 0
  store i32 29, ptr %15, align 8, !tbaa !14
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.TOKEN, ptr %16, i32 0, i32 1
  store i32 2, ptr %17, align 4, !tbaa !18
  br label %18

18:                                               ; preds = %21, %2
  %19 = call i32 @pos_is_digit(ptr noundef %7)
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 40, ptr %8) #6
  call void @pos_next(ptr dead_on_unwind writable sret(%struct.POS) align 8 %8, ptr noundef %7)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 8 %8, i64 40, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 40, ptr %8) #6
  br label %18, !llvm.loop !19

22:                                               ; preds = %18
  %23 = call i32 @pos_get_code(ptr noundef %7)
  %24 = icmp eq i32 %23, 46
  br i1 %24, label %25, label %31

25:                                               ; preds = %22
  store i32 -1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 40, ptr %9) #6
  call void @pos_next(ptr dead_on_unwind writable sret(%struct.POS) align 8 %9, ptr noundef %7)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 8 %9, i64 40, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 40, ptr %9) #6
  br label %26

26:                                               ; preds = %29, %25
  %27 = call i32 @pos_is_digit(ptr noundef %7)
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %26
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 40, ptr %10) #6
  call void @pos_next(ptr dead_on_unwind writable sret(%struct.POS) align 8 %10, ptr noundef %7)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 8 %10, i64 40, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 40, ptr %10) #6
  br label %26, !llvm.loop !21

30:                                               ; preds = %26
  br label %31

31:                                               ; preds = %30, %22
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.TOKEN, ptr %32, i32 0, i32 2
  %34 = getelementptr inbounds %struct.FRAG, ptr %33, i32 0, i32 0
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %34, ptr align 8 %35, i64 40, i1 false), !tbaa.struct !11
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.TOKEN, ptr %36, i32 0, i32 2
  %38 = getelementptr inbounds %struct.FRAG, ptr %37, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %38, ptr align 8 %7, i64 40, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.start.p0(i64 64, ptr %11) #6
  %39 = getelementptr inbounds [64 x i8], ptr %11, i64 0, i64 0
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.TOKEN, ptr %40, i32 0, i32 2
  %42 = getelementptr inbounds %struct.FRAG, ptr %41, i32 0, i32 1
  %43 = getelementptr inbounds %struct.POS, ptr %42, i32 0, i32 4
  %44 = load i64, ptr %43, align 8, !tbaa !22
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.TOKEN, ptr %45, i32 0, i32 2
  %47 = getelementptr inbounds %struct.FRAG, ptr %46, i32 0, i32 0
  %48 = getelementptr inbounds %struct.POS, ptr %47, i32 0, i32 4
  %49 = load i64, ptr %48, align 8, !tbaa !23
  %50 = sub i64 %44, %49
  %51 = trunc i64 %50 to i32
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.TOKEN, ptr %52, i32 0, i32 2
  %54 = getelementptr inbounds %struct.FRAG, ptr %53, i32 0, i32 0
  %55 = getelementptr inbounds %struct.POS, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !24
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.TOKEN, ptr %57, i32 0, i32 2
  %59 = getelementptr inbounds %struct.FRAG, ptr %58, i32 0, i32 0
  %60 = getelementptr inbounds %struct.POS, ptr %59, i32 0, i32 4
  %61 = load i64, ptr %60, align 8, !tbaa !23
  %62 = getelementptr inbounds i8, ptr %56, i64 %61
  %63 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %39, i64 noundef 64, ptr noundef @.str.2, i32 noundef %51, ptr noundef %62) #6
  %64 = getelementptr inbounds [64 x i8], ptr %11, i64 0, i64 0
  %65 = call i64 @atoll(ptr noundef %64) #7
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.TOKEN, ptr %66, i32 0, i32 3
  store i64 %65, ptr %67, align 8, !tbaa !25
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %68, ptr %69, align 8, !tbaa !5
  %70 = load i32, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 64, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  ret i32 %70
}

declare i32 @pos_is_digit(ptr noundef) #3

declare i32 @pos_get_code(ptr noundef) #3

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

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare i64 @atoll(ptr noundef nonnull) #5

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 "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 = { inlinehint nounwind willreturn memory(read) 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 #6 = { nounwind }
attributes #7 = { 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{i64 0, i64 8, !5, i64 8, i64 8, !12, i64 16, i64 8, !12, i64 24, i64 8, !12, i64 32, i64 8, !12}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !10, i64 0}
!15 = !{!"TOKEN", !10, i64 0, !10, i64 4, !16, i64 8, !7, i64 88}
!16 = !{!"FRAG", !17, i64 0, !17, i64 40}
!17 = !{!"POS", !6, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32}
!18 = !{!15, !10, i64 4}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}
!22 = !{!15, !13, i64 80}
!23 = !{!15, !13, i64 40}
!24 = !{!15, !6, i64 8}
!25 = !{!7, !7, 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"

%struct.POS = type { ptr, i64, i64, i64, i64 }

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @create_token() local_unnamed_addr #0

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

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

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

declare void @pos_next(ptr dead_on_unwind writable sret(%struct.POS) align 8, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @token_read_number(ptr nocapture noundef writeonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca %struct.POS, align 8
  %4 = alloca %struct.POS, align 8
  %5 = alloca %struct.POS, align 8
  %6 = alloca %struct.POS, align 8
  %7 = alloca [64 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %3) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %3, ptr noundef nonnull align 8 dereferenceable(40) %1, i64 40, i1 false), !tbaa.struct !5
  %8 = tail call ptr @create_token()
  store i32 29, ptr %8, align 8, !tbaa !12
  %9 = getelementptr inbounds i8, ptr %8, i64 4
  store i32 2, ptr %9, align 4, !tbaa !17
  %10 = call i32 @pos_is_digit(ptr noundef nonnull %3) #6
  %.not14 = icmp eq i32 %10, 0
  br i1 %.not14, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %.lr.ph
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %4) #6
  call void @pos_next(ptr dead_on_unwind nonnull writable sret(%struct.POS) align 8 %4, ptr noundef nonnull %3) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %3, ptr noundef nonnull align 8 dereferenceable(40) %4, i64 40, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %4) #6
  %11 = call i32 @pos_is_digit(ptr noundef nonnull %3) #6
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !18

._crit_edge:                                      ; preds = %.lr.ph, %2
  %12 = call i32 @pos_get_code(ptr noundef nonnull %3) #6
  %13 = icmp eq i32 %12, 46
  br i1 %13, label %14, label %.loopexit

14:                                               ; preds = %._crit_edge
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %5) #6
  call void @pos_next(ptr dead_on_unwind nonnull writable sret(%struct.POS) align 8 %5, ptr noundef nonnull %3) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %3, ptr noundef nonnull align 8 dereferenceable(40) %5, i64 40, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %5) #6
  %15 = call i32 @pos_is_digit(ptr noundef nonnull %3) #6
  %.not1315 = icmp eq i32 %15, 0
  br i1 %.not1315, label %.loopexit, label %.lr.ph17

.lr.ph17:                                         ; preds = %14, %.lr.ph17
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %6) #6
  call void @pos_next(ptr dead_on_unwind nonnull writable sret(%struct.POS) align 8 %6, ptr noundef nonnull %3) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %3, ptr noundef nonnull align 8 dereferenceable(40) %6, i64 40, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %6) #6
  %16 = call i32 @pos_is_digit(ptr noundef nonnull %3) #6
  %.not13 = icmp eq i32 %16, 0
  br i1 %.not13, label %.loopexit, label %.lr.ph17, !llvm.loop !20

.loopexit:                                        ; preds = %.lr.ph17, %14, %._crit_edge
  %.1 = phi i32 [ 0, %._crit_edge ], [ -1, %14 ], [ 0, %.lr.ph17 ]
  %17 = getelementptr inbounds i8, ptr %8, i64 8
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %17, ptr noundef nonnull align 8 dereferenceable(40) %1, i64 40, i1 false), !tbaa.struct !5
  %18 = getelementptr inbounds i8, ptr %8, i64 48
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %18, ptr noundef nonnull align 8 dereferenceable(40) %3, i64 40, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %7) #6
  %19 = getelementptr inbounds i8, ptr %8, i64 80
  %20 = load i64, ptr %19, align 8, !tbaa !21
  %21 = getelementptr inbounds i8, ptr %8, i64 40
  %22 = load i64, ptr %21, align 8, !tbaa !22
  %23 = sub i64 %20, %22
  %24 = trunc i64 %23 to i32
  %25 = load ptr, ptr %17, align 8, !tbaa !23
  %26 = getelementptr inbounds i8, ptr %25, i64 %22
  %27 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %7, i64 noundef 64, ptr noundef nonnull @.str.2, i32 noundef %24, ptr noundef %26) #6
  %28 = call i64 @atoll(ptr nocapture noundef %7) #7
  %29 = getelementptr inbounds i8, ptr %8, i64 88
  store i64 %28, ptr %29, align 8, !tbaa !24
  store ptr %8, ptr %0, align 8, !tbaa !6
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %3) #6
  ret i32 %.1
}

declare i32 @pos_is_digit(ptr noundef) local_unnamed_addr #3

declare i32 @pos_get_code(ptr noundef) local_unnamed_addr #3

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

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i64 @atoll(ptr nocapture noundef nonnull) local_unnamed_addr #5

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = { 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 #5 = { inlinehint mustprogress nofree nounwind willreturn memory(read) 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 #6 = { nounwind }
attributes #7 = { 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 = !{i64 0, i64 8, !6, i64 8, i64 8, !10, i64 16, i64 8, !10, i64 24, i64 8, !10, i64 32, i64 8, !10}
!6 = !{!7, !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!13, !14, i64 0}
!13 = !{!"TOKEN", !14, i64 0, !14, i64 4, !15, i64 8, !8, i64 88}
!14 = !{!"int", !8, i64 0}
!15 = !{!"FRAG", !16, i64 0, !16, i64 40}
!16 = !{!"POS", !7, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!17 = !{!13, !14, i64 4}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}
!21 = !{!13, !11, i64 80}
!22 = !{!13, !11, i64 40}
!23 = !{!13, !7, i64 8}
!24 = !{!8, !8, i64 0}


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