; LLVM IR from aap/pdp6 :: tools (as6)

; 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 = type { i32, %union.anon.0 }
%union.anon.0 = type { i64 }

@ctab = external dso_local global [128 x i32], align 16
@lp = external dso_local global ptr, align 8
@peekt = external dso_local global %struct.Token, align 8
@.str.10 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [25 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @err(i32 noundef, 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: 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

; Function Attrs: nounwind uwtable
declare dso_local void @skipwhite() #0

; Function Attrs: nounwind uwtable
declare dso_local { i32, i64 } @symnum() #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @character(i8 noundef signext, i32 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local { i32, i64 } @token() #0 {
  %1 = alloca %struct.Token, align 8
  %2 = alloca %struct.Token, align 8
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 16, ptr %2) #3
  %4 = load i32, ptr @peekt, align 8, !tbaa !5
  %5 = icmp ne i32 %4, 0
  br i1 %5, label %6, label %7

6:                                                ; preds = %0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %2, ptr align 8 @peekt, i64 16, i1 false), !tbaa.struct !10
  store i32 0, ptr @peekt, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %1, ptr align 8 %2, i64 16, i1 false), !tbaa.struct !10
  store i32 1, ptr %3, align 4
  br label %111

7:                                                ; preds = %0
  call void @skipwhite()
  br label %8

8:                                                ; preds = %108, %7
  %9 = load ptr, ptr @lp, align 8, !tbaa !13
  %10 = load i8, ptr %9, align 1, !tbaa !12
  %11 = icmp ne i8 %10, 0
  br i1 %11, label %12, label %109

12:                                               ; preds = %8
  %13 = load ptr, ptr @lp, align 8, !tbaa !13
  %14 = load i8, ptr %13, align 1, !tbaa !12
  %15 = sext i8 %14 to i64
  %16 = getelementptr inbounds [128 x i32], ptr @ctab, i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !11
  switch i32 %17, label %100 [
    i32 14, label %18
    i32 15, label %18
    i32 34, label %24
    i32 39, label %30
    i32 59, label %36
    i32 94, label %46
    i32 0, label %93
    i32 16, label %97
  ]

18:                                               ; preds = %12, %12
  %19 = call { i32, i64 } @symnum()
  %20 = getelementptr inbounds { i32, i64 }, ptr %1, i32 0, i32 0
  %21 = extractvalue { i32, i64 } %19, 0
  store i32 %21, ptr %20, align 8
  %22 = getelementptr inbounds { i32, i64 }, ptr %1, i32 0, i32 1
  %23 = extractvalue { i32, i64 } %19, 1
  store i64 %23, ptr %22, align 8
  store i32 1, ptr %3, align 4
  br label %111

24:                                               ; preds = %12
  %25 = load ptr, ptr @lp, align 8, !tbaa !13
  %26 = getelementptr inbounds i8, ptr %25, i32 1
  store ptr %26, ptr @lp, align 8, !tbaa !13
  %27 = getelementptr inbounds %struct.Token, ptr %2, i32 0, i32 0
  store i32 2, ptr %27, align 8, !tbaa !5
  %28 = call i64 @character(i8 noundef signext 34, i32 noundef 7)
  %29 = getelementptr inbounds %struct.Token, ptr %2, i32 0, i32 1
  store i64 %28, ptr %29, align 8, !tbaa !12
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %1, ptr align 8 %2, i64 16, i1 false), !tbaa.struct !10
  store i32 1, ptr %3, align 4
  br label %111

30:                                               ; preds = %12
  %31 = load ptr, ptr @lp, align 8, !tbaa !13
  %32 = getelementptr inbounds i8, ptr %31, i32 1
  store ptr %32, ptr @lp, align 8, !tbaa !13
  %33 = getelementptr inbounds %struct.Token, ptr %2, i32 0, i32 0
  store i32 2, ptr %33, align 8, !tbaa !5
  %34 = call i64 @character(i8 noundef signext 39, i32 noundef 6)
  %35 = getelementptr inbounds %struct.Token, ptr %2, i32 0, i32 1
  store i64 %34, ptr %35, align 8, !tbaa !12
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %1, ptr align 8 %2, i64 16, i1 false), !tbaa.struct !10
  store i32 1, ptr %3, align 4
  br label %111

36:                                               ; preds = %12
  br label %37

37:                                               ; preds = %41, %36
  %38 = load ptr, ptr @lp, align 8, !tbaa !13
  %39 = load i8, ptr %38, align 1, !tbaa !12
  %40 = icmp ne i8 %39, 0
  br i1 %40, label %41, label %44

41:                                               ; preds = %37
  %42 = load ptr, ptr @lp, align 8, !tbaa !13
  %43 = getelementptr inbounds i8, ptr %42, i32 1
  store ptr %43, ptr @lp, align 8, !tbaa !13
  br label %37, !llvm.loop !15

44:                                               ; preds = %37
  %45 = getelementptr inbounds %struct.Token, ptr %2, i32 0, i32 0
  store i32 13, ptr %45, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %1, ptr align 8 %2, i64 16, i1 false), !tbaa.struct !10
  store i32 1, ptr %3, align 4
  br label %111

46:                                               ; preds = %12
  %47 = load ptr, ptr @lp, align 8, !tbaa !13
  %48 = getelementptr inbounds i8, ptr %47, i32 1
  store ptr %48, ptr @lp, align 8, !tbaa !13
  %49 = load ptr, ptr @lp, align 8, !tbaa !13
  %50 = load i8, ptr %49, align 1, !tbaa !12
  %51 = sext i8 %50 to i32
  %52 = icmp eq i32 %51, 68
  br i1 %52, label %53, label %55

53:                                               ; preds = %46
  %54 = getelementptr inbounds %struct.Token, ptr %2, i32 0, i32 0
  store i32 10, ptr %54, align 8, !tbaa !5
  br label %90

55:                                               ; preds = %46
  %56 = load ptr, ptr @lp, align 8, !tbaa !13
  %57 = load i8, ptr %56, align 1, !tbaa !12
  %58 = sext i8 %57 to i32
  %59 = icmp eq i32 %58, 79
  br i1 %59, label %60, label %62

60:                                               ; preds = %55
  %61 = getelementptr inbounds %struct.Token, ptr %2, i32 0, i32 0
  store i32 11, ptr %61, align 8, !tbaa !5
  br label %89

62:                                               ; preds = %55
  %63 = load ptr, ptr @lp, align 8, !tbaa !13
  %64 = load i8, ptr %63, align 1, !tbaa !12
  %65 = sext i8 %64 to i32
  %66 = icmp eq i32 %65, 66
  br i1 %66, label %67, label %69

67:                                               ; preds = %62
  %68 = getelementptr inbounds %struct.Token, ptr %2, i32 0, i32 0
  store i32 12, ptr %68, align 8, !tbaa !5
  br label %88

69:                                               ; preds = %62
  %70 = load ptr, ptr @lp, align 8, !tbaa !13
  %71 = load i8, ptr %70, align 1, !tbaa !12
  %72 = sext i8 %71 to i32
  %73 = icmp eq i32 %72, 70
  br i1 %73, label %74, label %82

74:                                               ; preds = %69
  %75 = load ptr, ptr @lp, align 8, !tbaa !13
  %76 = getelementptr inbounds i8, ptr %75, i32 -1
  store ptr %76, ptr @lp, align 8, !tbaa !13
  %77 = call { i32, i64 } @symnum()
  %78 = getelementptr inbounds { i32, i64 }, ptr %1, i32 0, i32 0
  %79 = extractvalue { i32, i64 } %77, 0
  store i32 %79, ptr %78, align 8
  %80 = getelementptr inbounds { i32, i64 }, ptr %1, i32 0, i32 1
  %81 = extractvalue { i32, i64 } %77, 1
  store i64 %81, ptr %80, align 8
  store i32 1, ptr %3, align 4
  br label %111

82:                                               ; preds = %69
  %83 = load ptr, ptr @lp, align 8, !tbaa !13
  %84 = load i8, ptr %83, align 1, !tbaa !12
  %85 = sext i8 %84 to i32
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.10, i32 noundef %85)
  %86 = getelementptr inbounds %struct.Token, ptr %2, i32 0, i32 0
  store i32 11, ptr %86, align 8, !tbaa !5
  br label %87

87:                                               ; preds = %82
  br label %88

88:                                               ; preds = %87, %67
  br label %89

89:                                               ; preds = %88, %60
  br label %90

90:                                               ; preds = %89, %53
  %91 = load ptr, ptr @lp, align 8, !tbaa !13
  %92 = getelementptr inbounds i8, ptr %91, i32 1
  store ptr %92, ptr @lp, align 8, !tbaa !13
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %1, ptr align 8 %2, i64 16, i1 false), !tbaa.struct !10
  store i32 1, ptr %3, align 4
  br label %111

93:                                               ; preds = %12
  %94 = load ptr, ptr @lp, align 8, !tbaa !13
  %95 = load i8, ptr %94, align 1, !tbaa !12
  %96 = sext i8 %95 to i32
  call void (i32, ptr, ...) @err(i32 noundef 0, ptr noundef @.str.11, i32 noundef %96)
  br label %97

97:                                               ; preds = %93, %12
  %98 = load ptr, ptr @lp, align 8, !tbaa !13
  %99 = getelementptr inbounds i8, ptr %98, i32 1
  store ptr %99, ptr @lp, align 8, !tbaa !13
  br label %108

100:                                              ; preds = %12
  %101 = load ptr, ptr @lp, align 8, !tbaa !13
  %102 = getelementptr inbounds i8, ptr %101, i32 1
  store ptr %102, ptr @lp, align 8, !tbaa !13
  %103 = load i8, ptr %101, align 1, !tbaa !12
  %104 = sext i8 %103 to i64
  %105 = getelementptr inbounds [128 x i32], ptr @ctab, i64 0, i64 %104
  %106 = load i32, ptr %105, align 4, !tbaa !11
  %107 = getelementptr inbounds %struct.Token, ptr %2, i32 0, i32 0
  store i32 %106, ptr %107, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %1, ptr align 8 %2, i64 16, i1 false), !tbaa.struct !10
  store i32 1, ptr %3, align 4
  br label %111

108:                                              ; preds = %97
  br label %8, !llvm.loop !17

109:                                              ; preds = %8
  %110 = getelementptr inbounds %struct.Token, ptr %2, i32 0, i32 0
  store i32 13, ptr %110, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %1, ptr align 8 %2, i64 16, i1 false), !tbaa.struct !10
  store i32 1, ptr %3, align 4
  br label %111

111:                                              ; preds = %109, %100, %90, %74, %44, %30, %24, %18, %6
  call void @llvm.lifetime.end.p0(i64 16, ptr %2) #3
  %112 = load { i32, i64 }, ptr %1, align 8
  ret { i32, i64 } %112
}

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 = { 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 0}
!6 = !{!"Token", !7, i64 0, !8, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{i64 0, i64 4, !11, i64 8, i64 8, !12}
!11 = !{!7, !7, i64 0}
!12 = !{!8, !8, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !8, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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.Token = type { i32, %union.anon.0 }
%union.anon.0 = type { i64 }

@ctab = external dso_local local_unnamed_addr global [128 x i32], align 16
@lp = external dso_local local_unnamed_addr global ptr, align 8
@peekt = external dso_local local_unnamed_addr global %struct.Token, align 8
@.str.10 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [25 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @err(i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @skipwhite() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local { i32, i64 } @symnum() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @character(i8 noundef signext, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local { i32, i64 } @token() local_unnamed_addr #0 {
  %1 = load i32, ptr @peekt, align 8, !tbaa !5
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %3, label %2

2:                                                ; preds = %0
  %.sroa.1921.0.copyload = load i64, ptr getelementptr inbounds (i8, ptr @peekt, i64 8), align 8, !tbaa !9
  store i32 0, ptr @peekt, align 8, !tbaa !10
  br label %.loopexit

3:                                                ; preds = %0
  tail call void @skipwhite()
  %4 = load ptr, ptr @lp, align 8, !tbaa !12
  %5 = load i8, ptr %4, align 1, !tbaa !9
  %.not3847 = icmp eq i8 %5, 0
  br i1 %.not3847, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %3, %39
  %6 = phi i8 [ %42, %39 ], [ %5, %3 ]
  %lp.promoted = phi ptr [ %41, %39 ], [ %4, %3 ]
  %7 = sext i8 %6 to i64
  %8 = getelementptr inbounds [128 x i32], ptr @ctab, i64 0, i64 %7
  %9 = load i32, ptr %8, align 4, !tbaa !5
  switch i32 %9, label %43 [
    i32 14, label %10
    i32 15, label %10
    i32 34, label %14
    i32 39, label %17
    i32 59, label %.lr.ph49
    i32 94, label %23
    i32 0, label %37
    i32 16, label %39
  ]

10:                                               ; preds = %.lr.ph, %.lr.ph
  %11 = tail call { i32, i64 } @symnum()
  %12 = extractvalue { i32, i64 } %11, 0
  %13 = extractvalue { i32, i64 } %11, 1
  br label %.loopexit

14:                                               ; preds = %.lr.ph
  %15 = getelementptr inbounds i8, ptr %lp.promoted, i64 1
  store ptr %15, ptr @lp, align 8, !tbaa !12
  %16 = tail call i64 @character(i8 noundef signext 34, i32 noundef 7)
  br label %.loopexit

17:                                               ; preds = %.lr.ph
  %18 = getelementptr inbounds i8, ptr %lp.promoted, i64 1
  store ptr %18, ptr @lp, align 8, !tbaa !12
  %19 = tail call i64 @character(i8 noundef signext 39, i32 noundef 6)
  br label %.loopexit

.lr.ph49:                                         ; preds = %.lr.ph, %.lr.ph49
  %20 = phi ptr [ %21, %.lr.ph49 ], [ %lp.promoted, %.lr.ph ]
  %21 = getelementptr inbounds i8, ptr %20, i64 1
  store ptr %21, ptr @lp, align 8, !tbaa !12
  %22 = load i8, ptr %21, align 1, !tbaa !9
  %.not39 = icmp eq i8 %22, 0
  br i1 %.not39, label %.loopexit, label %.lr.ph49, !llvm.loop !14

23:                                               ; preds = %.lr.ph
  %24 = getelementptr inbounds i8, ptr %lp.promoted, i64 1
  store ptr %24, ptr @lp, align 8, !tbaa !12
  %25 = load i8, ptr %24, align 1, !tbaa !9
  switch i8 %25, label %32 [
    i8 68, label %34
    i8 79, label %26
    i8 66, label %27
    i8 70, label %28
  ]

26:                                               ; preds = %23
  br label %34

27:                                               ; preds = %23
  br label %34

28:                                               ; preds = %23
  store ptr %lp.promoted, ptr @lp, align 8, !tbaa !12
  %29 = tail call { i32, i64 } @symnum()
  %30 = extractvalue { i32, i64 } %29, 0
  %31 = extractvalue { i32, i64 } %29, 1
  br label %.loopexit

32:                                               ; preds = %23
  %33 = sext i8 %25 to i32
  tail call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.10, i32 noundef %33)
  %.pre57 = load ptr, ptr @lp, align 8, !tbaa !12
  br label %34

34:                                               ; preds = %23, %26, %32, %27
  %35 = phi ptr [ %24, %26 ], [ %24, %27 ], [ %.pre57, %32 ], [ %24, %23 ]
  %.sroa.0.0 = phi i32 [ 11, %26 ], [ 12, %27 ], [ 11, %32 ], [ 10, %23 ]
  %36 = getelementptr inbounds i8, ptr %35, i64 1
  store ptr %36, ptr @lp, align 8, !tbaa !12
  br label %.loopexit

37:                                               ; preds = %.lr.ph
  %38 = sext i8 %6 to i32
  tail call void (i32, ptr, ...) @err(i32 noundef 0, ptr noundef nonnull @.str.11, i32 noundef %38)
  %.pre = load ptr, ptr @lp, align 8, !tbaa !12
  br label %39

39:                                               ; preds = %37, %.lr.ph
  %40 = phi ptr [ %.pre, %37 ], [ %lp.promoted, %.lr.ph ]
  %41 = getelementptr inbounds i8, ptr %40, i64 1
  store ptr %41, ptr @lp, align 8, !tbaa !12
  %42 = load i8, ptr %41, align 1, !tbaa !9
  %.not38 = icmp eq i8 %42, 0
  br i1 %.not38, label %.loopexit, label %.lr.ph, !llvm.loop !16

43:                                               ; preds = %.lr.ph
  %44 = getelementptr inbounds i8, ptr %lp.promoted, i64 1
  store ptr %44, ptr @lp, align 8, !tbaa !12
  %45 = load i8, ptr %lp.promoted, align 1, !tbaa !9
  %46 = sext i8 %45 to i64
  %47 = getelementptr inbounds [128 x i32], ptr @ctab, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %39, %.lr.ph49, %3, %43, %34, %28, %17, %14, %10, %2
  %.sroa.17.0 = phi i64 [ %.sroa.1921.0.copyload, %2 ], [ undef, %43 ], [ undef, %34 ], [ %31, %28 ], [ %19, %17 ], [ %16, %14 ], [ %13, %10 ], [ undef, %3 ], [ undef, %.lr.ph49 ], [ undef, %39 ]
  %.sroa.035.0 = phi i32 [ %1, %2 ], [ %48, %43 ], [ %.sroa.0.0, %34 ], [ %30, %28 ], [ 2, %17 ], [ 2, %14 ], [ %12, %10 ], [ 13, %3 ], [ 13, %.lr.ph49 ], [ 13, %39 ]
  %.fca.0.insert = insertvalue { i32, i64 } poison, i32 %.sroa.035.0, 0
  %.fca.1.insert = insertvalue { i32, i64 } %.fca.0.insert, i64 %.sroa.17.0, 1
  ret { i32, i64 } %.fca.1.insert
}

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

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !6, i64 0}
!11 = !{!"Token", !6, i64 0, !7, i64 8}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


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