; LLVM IR from ponylang/ponyc :: src/libponyc/ast (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.token_t = type { i32, ptr, i64, i64, ptr, %union.anon, i8 }
%union.anon = type { %struct.anon }
%struct.anon = type { ptr, i64 }
%struct.lexint_t = type { i64, i64 }

@.str = external hidden unnamed_addr constant [14 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@__func__.token_print = external hidden unnamed_addr constant [12 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [17 x i8], align 1

; 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

declare void @ponyint_assert_fail(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @token_print(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = icmp ne ptr %7, null
  br i1 %8, label %9, label %10

9:                                                ; preds = %1
  br label %11

10:                                               ; preds = %1
  call void @ponyint_assert_fail(ptr noundef @.str, ptr noundef @.str.1, i64 noundef 150, ptr noundef @__func__.token_print)
  br label %11

11:                                               ; preds = %10, %9
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.token_t, ptr %12, i32 0, i32 0
  %14 = load i32, ptr %13, align 8, !tbaa !9
  switch i32 %14, label %82 [
    i32 0, label %15
    i32 8, label %16
    i32 5, label %16
    i32 6, label %21
    i32 7, label %42
    i32 1, label %81
  ]

15:                                               ; preds = %11
  store ptr @.str.5, ptr %2, align 8
  br label %113

16:                                               ; preds = %11, %11
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.token_t, ptr %17, i32 0, i32 5
  %19 = getelementptr inbounds %struct.anon, ptr %18, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8, !tbaa !14
  store ptr %20, ptr %2, align 8
  br label %113

21:                                               ; preds = %11
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.token_t, ptr %22, i32 0, i32 4
  %24 = load ptr, ptr %23, align 8, !tbaa !15
  %25 = icmp eq ptr %24, null
  br i1 %25, label %26, label %30

26:                                               ; preds = %21
  %27 = call noalias ptr @ponyint_pool_alloc_size(i64 noundef 64)
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.token_t, ptr %28, i32 0, i32 4
  store ptr %27, ptr %29, align 8, !tbaa !15
  br label %30

30:                                               ; preds = %26, %21
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.token_t, ptr %31, i32 0, i32 4
  %33 = load ptr, ptr %32, align 8, !tbaa !15
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.token_t, ptr %34, i32 0, i32 5
  %36 = getelementptr inbounds %struct.lexint_t, ptr %35, i32 0, i32 0
  %37 = load i64, ptr %36, align 8, !tbaa !14
  %38 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %33, i64 noundef 64, ptr noundef @.str.6, i64 noundef %37) #5
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.token_t, ptr %39, i32 0, i32 4
  %41 = load ptr, ptr %40, align 8, !tbaa !15
  store ptr %41, ptr %2, align 8
  br label %113

42:                                               ; preds = %11
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.token_t, ptr %43, i32 0, i32 4
  %45 = load ptr, ptr %44, align 8, !tbaa !15
  %46 = icmp eq ptr %45, null
  br i1 %46, label %47, label %51

47:                                               ; preds = %42
  %48 = call noalias ptr @ponyint_pool_alloc_size(i64 noundef 64)
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.token_t, ptr %49, i32 0, i32 4
  store ptr %48, ptr %50, align 8, !tbaa !15
  br label %51

51:                                               ; preds = %47, %42
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.token_t, ptr %52, i32 0, i32 4
  %54 = load ptr, ptr %53, align 8, !tbaa !15
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.token_t, ptr %55, i32 0, i32 5
  %57 = load double, ptr %56, align 8, !tbaa !14
  %58 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %54, i64 noundef 64, ptr noundef @.str.7, double noundef %57) #5
  store i32 %58, ptr %4, align 4, !tbaa !16
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.token_t, ptr %59, i32 0, i32 4
  %61 = load ptr, ptr %60, align 8, !tbaa !15
  %62 = call i64 @strcspn(ptr noundef %61, ptr noundef @.str.8) #6
  %63 = load i32, ptr %4, align 4, !tbaa !16
  %64 = sext i32 %63 to i64
  %65 = icmp eq i64 %62, %64
  br i1 %65, label %66, label %77

66:                                               ; preds = %51
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.token_t, ptr %67, i32 0, i32 4
  %69 = load ptr, ptr %68, align 8, !tbaa !15
  %70 = load i32, ptr %4, align 4, !tbaa !16
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds i8, ptr %69, i64 %71
  %73 = load i32, ptr %4, align 4, !tbaa !16
  %74 = sub nsw i32 64, %73
  %75 = sext i32 %74 to i64
  %76 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %72, i64 noundef %75, ptr noundef @.str.9) #5
  br label %77

77:                                               ; preds = %66, %51
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.token_t, ptr %78, i32 0, i32 4
  %80 = load ptr, ptr %79, align 8, !tbaa !15
  store ptr %80, ptr %2, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %113

81:                                               ; preds = %11
  store ptr @.str.10, ptr %2, align 8
  br label %113

82:                                               ; preds = %11
  br label %83

83:                                               ; preds = %82
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %84 = load ptr, ptr %3, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.token_t, ptr %84, i32 0, i32 0
  %86 = load i32, ptr %85, align 8, !tbaa !9
  %87 = call ptr @lexer_print(i32 noundef %86)
  store ptr %87, ptr %5, align 8, !tbaa !5
  %88 = load ptr, ptr %5, align 8, !tbaa !5
  %89 = icmp ne ptr %88, null
  br i1 %89, label %90, label %92

90:                                               ; preds = %83
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %91, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %112

92:                                               ; preds = %83
  %93 = load ptr, ptr %3, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.token_t, ptr %93, i32 0, i32 4
  %95 = load ptr, ptr %94, align 8, !tbaa !15
  %96 = icmp eq ptr %95, null
  br i1 %96, label %97, label %101

97:                                               ; preds = %92
  %98 = call noalias ptr @ponyint_pool_alloc_size(i64 noundef 64)
  %99 = load ptr, ptr %3, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.token_t, ptr %99, i32 0, i32 4
  store ptr %98, ptr %100, align 8, !tbaa !15
  br label %101

101:                                              ; preds = %97, %92
  %102 = load ptr, ptr %3, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.token_t, ptr %102, i32 0, i32 4
  %104 = load ptr, ptr %103, align 8, !tbaa !15
  %105 = load ptr, ptr %3, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.token_t, ptr %105, i32 0, i32 0
  %107 = load i32, ptr %106, align 8, !tbaa !9
  %108 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %104, i64 noundef 64, ptr noundef @.str.11, i32 noundef %107) #5
  %109 = load ptr, ptr %3, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.token_t, ptr %109, i32 0, i32 4
  %111 = load ptr, ptr %110, align 8, !tbaa !15
  store ptr %111, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %112

112:                                              ; preds = %101, %90
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %113

113:                                              ; preds = %112, %81, %77, %30, %16, %15
  %114 = load ptr, ptr %2, align 8
  ret ptr %114
}

declare noalias ptr @ponyint_pool_alloc_size(i64 noundef) #1

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

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strcspn(ptr noundef, ptr noundef) #4

declare ptr @lexer_print(i32 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"token_t", !11, i64 0, !6, i64 8, !12, i64 16, !12, i64 24, !6, i64 32, !7, i64 40, !13, i64 56}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!7, !7, i64 0}
!15 = !{!10, !6, i64 32}
!16 = !{!11, !11, 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 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@__func__.token_print = external hidden unnamed_addr constant [12 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [17 x i8], align 1

declare void @ponyint_assert_fail(ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @token_print(ptr noundef %0) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %2, label %3

2:                                                ; preds = %1
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i64 noundef 150, ptr noundef nonnull @__func__.token_print) #4
  br label %3

3:                                                ; preds = %1, %2
  %4 = load i32, ptr %0, align 8, !tbaa !5
  switch i32 %4, label %41 [
    i32 0, label %54
    i32 8, label %5
    i32 5, label %5
    i32 6, label %8
    i32 7, label %20
    i32 1, label %40
  ]

5:                                                ; preds = %3, %3
  %6 = getelementptr inbounds i8, ptr %0, i64 40
  %7 = load ptr, ptr %6, align 8, !tbaa !13
  br label %54

8:                                                ; preds = %3
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %14

12:                                               ; preds = %8
  %13 = tail call noalias ptr @ponyint_pool_alloc_size(i64 noundef 64) #4
  store ptr %13, ptr %9, align 8, !tbaa !14
  br label %14

14:                                               ; preds = %12, %8
  %15 = phi ptr [ %13, %12 ], [ %10, %8 ]
  %16 = getelementptr inbounds i8, ptr %0, i64 40
  %17 = load i64, ptr %16, align 8, !tbaa !13
  %18 = tail call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %15, i64 noundef 64, ptr noundef nonnull @.str.6, i64 noundef %17) #4
  %19 = load ptr, ptr %9, align 8, !tbaa !14
  br label %54

20:                                               ; preds = %3
  %21 = getelementptr inbounds i8, ptr %0, i64 32
  %22 = load ptr, ptr %21, align 8, !tbaa !14
  %23 = icmp eq ptr %22, null
  br i1 %23, label %24, label %26

24:                                               ; preds = %20
  %25 = tail call noalias ptr @ponyint_pool_alloc_size(i64 noundef 64) #4
  store ptr %25, ptr %21, align 8, !tbaa !14
  br label %26

26:                                               ; preds = %24, %20
  %27 = phi ptr [ %25, %24 ], [ %22, %20 ]
  %28 = getelementptr inbounds i8, ptr %0, i64 40
  %29 = load double, ptr %28, align 8, !tbaa !13
  %30 = tail call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %27, i64 noundef 64, ptr noundef nonnull @.str.7, double noundef %29) #4
  %31 = load ptr, ptr %21, align 8, !tbaa !14
  %32 = tail call i64 @strcspn(ptr noundef %31, ptr noundef nonnull @.str.8) #5
  %33 = sext i32 %30 to i64
  %34 = icmp eq i64 %32, %33
  br i1 %34, label %35, label %54

35:                                               ; preds = %26
  %36 = getelementptr inbounds i8, ptr %31, i64 %32
  %37 = sub nsw i32 64, %30
  %38 = sext i32 %37 to i64
  %39 = tail call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %36, i64 noundef %38, ptr noundef nonnull @.str.9) #4
  %.pre = load ptr, ptr %21, align 8, !tbaa !14
  br label %54

40:                                               ; preds = %3
  br label %54

41:                                               ; preds = %3
  %42 = tail call ptr @lexer_print(i32 noundef %4) #4
  %.not28 = icmp eq ptr %42, null
  br i1 %.not28, label %43, label %54

43:                                               ; preds = %41
  %44 = getelementptr inbounds i8, ptr %0, i64 32
  %45 = load ptr, ptr %44, align 8, !tbaa !14
  %46 = icmp eq ptr %45, null
  br i1 %46, label %47, label %49

47:                                               ; preds = %43
  %48 = tail call noalias ptr @ponyint_pool_alloc_size(i64 noundef 64) #4
  store ptr %48, ptr %44, align 8, !tbaa !14
  br label %49

49:                                               ; preds = %47, %43
  %50 = phi ptr [ %48, %47 ], [ %45, %43 ]
  %51 = load i32, ptr %0, align 8, !tbaa !5
  %52 = tail call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %50, i64 noundef 64, ptr noundef nonnull @.str.11, i32 noundef %51) #4
  %53 = load ptr, ptr %44, align 8, !tbaa !14
  br label %54

54:                                               ; preds = %26, %35, %49, %41, %3, %40, %14, %5
  %.1 = phi ptr [ @.str.10, %40 ], [ %19, %14 ], [ %7, %5 ], [ @.str.5, %3 ], [ %53, %49 ], [ %42, %41 ], [ %.pre, %35 ], [ %31, %26 ]
  ret ptr %.1
}

declare noalias ptr @ponyint_pool_alloc_size(i64 noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strcspn(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #3

declare ptr @lexer_print(i32 noundef) local_unnamed_addr #0

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 = { 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 #3 = { mustprogress nofree nounwind willreturn memory(argmem: 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, !7, i64 0}
!6 = !{!"token_t", !7, i64 0, !10, i64 8, !11, i64 16, !11, i64 24, !10, i64 32, !8, i64 40, !12, i64 56}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!"_Bool", !8, i64 0}
!13 = !{!8, !8, i64 0}
!14 = !{!6, !10, i64 32}


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