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

@.str = external hidden unnamed_addr constant [14 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [15 x i8], align 1
@__func__.token_set_string = external hidden unnamed_addr constant [17 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [14 x i8], align 1

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

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #1

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

9:                                                ; preds = %3
  br label %11

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

11:                                               ; preds = %10, %9
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.token_t, ptr %12, i32 0, i32 0
  %14 = load i32, ptr %13, align 8, !tbaa !11
  %15 = icmp eq i32 %14, 5
  br i1 %15, label %21, label %16

16:                                               ; preds = %11
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.token_t, ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 8, !tbaa !11
  %20 = icmp eq i32 %19, 8
  br i1 %20, label %21, label %22

21:                                               ; preds = %16, %11
  br label %23

22:                                               ; preds = %16
  call void @ponyint_assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i64 noundef 318, ptr noundef @__func__.token_set_string)
  br label %23

23:                                               ; preds = %22, %21
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.token_t, ptr %24, i32 0, i32 6
  %26 = load i8, ptr %25, align 8, !tbaa !15, !range !16, !noundef !17
  %27 = trunc i8 %26 to i1
  br i1 %27, label %29, label %28

28:                                               ; preds = %23
  br label %30

29:                                               ; preds = %23
  call void @ponyint_assert_fail(ptr noundef @.str.19, ptr noundef @.str.1, i64 noundef 320, ptr noundef @__func__.token_set_string)
  br label %30

30:                                               ; preds = %29, %28
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %34

33:                                               ; preds = %30
  br label %35

34:                                               ; preds = %30
  call void @ponyint_assert_fail(ptr noundef @.str.20, ptr noundef @.str.1, i64 noundef 322, ptr noundef @__func__.token_set_string)
  br label %35

35:                                               ; preds = %34, %33
  %36 = load i64, ptr %6, align 8, !tbaa !9
  %37 = icmp eq i64 %36, 0
  br i1 %37, label %38, label %41

38:                                               ; preds = %35
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = call i64 @strlen(ptr noundef %39) #3
  store i64 %40, ptr %6, align 8, !tbaa !9
  br label %41

41:                                               ; preds = %38, %35
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = load i64, ptr %6, align 8, !tbaa !9
  %44 = call ptr @stringtab_len(ptr noundef %42, i64 noundef %43)
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.token_t, ptr %45, i32 0, i32 5
  %47 = getelementptr inbounds %struct.anon, ptr %46, i32 0, i32 0
  store ptr %44, ptr %47, align 8, !tbaa !18
  %48 = load i64, ptr %6, align 8, !tbaa !9
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.token_t, ptr %49, i32 0, i32 5
  %51 = getelementptr inbounds %struct.anon, ptr %50, i32 0, i32 1
  store i64 %48, ptr %51, align 8, !tbaa !18
  ret void
}

declare ptr @stringtab_len(ptr noundef, i64 noundef) #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 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 #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 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 = !{!"long", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"token_t", !13, i64 0, !6, i64 8, !10, i64 16, !10, i64 24, !6, i64 32, !7, i64 40, !14, i64 56}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!12, !14, i64 56}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!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"

@.str = external hidden unnamed_addr constant [14 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [15 x i8], align 1
@__func__.token_set_string = external hidden unnamed_addr constant [17 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [14 x i8], align 1

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

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

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

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

5:                                                ; preds = %3, %4
  %6 = load i32, ptr %0, align 8, !tbaa !5
  switch i32 %6, label %7 [
    i32 5, label %8
    i32 8, label %8
  ]

7:                                                ; preds = %5
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i64 noundef 318, ptr noundef nonnull @__func__.token_set_string) #3
  br label %8

8:                                                ; preds = %5, %5, %7
  %9 = getelementptr inbounds i8, ptr %0, i64 56
  %10 = load i8, ptr %9, align 8, !tbaa !13, !range !14, !noundef !15
  %11 = trunc nuw i8 %10 to i1
  br i1 %11, label %12, label %13

12:                                               ; preds = %8
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.19, ptr noundef nonnull @.str.1, i64 noundef 320, ptr noundef nonnull @__func__.token_set_string) #3
  br label %13

13:                                               ; preds = %8, %12
  %.not13 = icmp eq ptr %1, null
  br i1 %.not13, label %14, label %15

14:                                               ; preds = %13
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.20, ptr noundef nonnull @.str.1, i64 noundef 322, ptr noundef nonnull @__func__.token_set_string) #3
  br label %15

15:                                               ; preds = %13, %14
  %16 = icmp eq i64 %2, 0
  br i1 %16, label %17, label %19

17:                                               ; preds = %15
  %18 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #4
  br label %19

19:                                               ; preds = %17, %15
  %.0 = phi i64 [ %18, %17 ], [ %2, %15 ]
  %20 = tail call ptr @stringtab_len(ptr noundef %1, i64 noundef %.0) #3
  %21 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr %20, ptr %21, align 8, !tbaa !16
  %22 = getelementptr inbounds i8, ptr %0, i64 48
  store i64 %.0, ptr %22, align 8, !tbaa !16
  ret void
}

declare ptr @stringtab_len(ptr noundef, i64 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 = { 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 #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 }
attributes #4 = { 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 = !{!6, !12, i64 56}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!8, !8, i64 0}


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