; 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 }
%struct.Value = type { i64, i32 }

@radix = external dso_local global i32, align 4
@peekt = external dso_local global %struct.Token, align 8
@.str.38 = external hidden unnamed_addr constant [20 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 @putv(i64 noundef, i32 noundef) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local void @byteOp() #0 {
  %1 = alloca %struct.Token, align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %struct.Token, align 8
  %9 = alloca %struct.Value, align 8
  %10 = alloca %struct.Token, align 8
  %11 = alloca %struct.Value, align 8
  %12 = alloca %struct.Token, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i64 0, ptr %3, align 8, !tbaa !5
  store i32 36, ptr %7, align 4, !tbaa !9
  store i32 6, ptr %4, align 4, !tbaa !9
  store i32 63, ptr %5, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %89, %0
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #3
  %14 = call { i32, i64 } @token()
  %15 = getelementptr inbounds { i32, i64 }, ptr %8, i32 0, i32 0
  %16 = extractvalue { i32, i64 } %14, 0
  store i32 %16, ptr %15, align 8
  %17 = getelementptr inbounds { i32, i64 }, ptr %8, i32 0, i32 1
  %18 = extractvalue { i32, i64 } %14, 1
  store i64 %18, ptr %17, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %1, ptr align 8 %8, i64 16, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #3
  %19 = getelementptr inbounds %struct.Token, ptr %1, i32 0, i32 0
  %20 = load i32, ptr %19, align 8, !tbaa !13
  %21 = icmp eq i32 %20, 40
  br i1 %21, label %22, label %46

22:                                               ; preds = %13
  %23 = load i32, ptr @radix, align 4, !tbaa !9
  store i32 %23, ptr %6, align 4, !tbaa !9
  store i32 10, ptr @radix, align 4, !tbaa !9
  %24 = call { i64, i32 } @expr(i32 noundef 0, ptr noundef null)
  %25 = getelementptr inbounds { i64, i32 }, ptr %9, i32 0, i32 0
  %26 = extractvalue { i64, i32 } %24, 0
  store i64 %26, ptr %25, align 8
  %27 = getelementptr inbounds { i64, i32 }, ptr %9, i32 0, i32 1
  %28 = extractvalue { i64, i32 } %24, 1
  store i32 %28, ptr %27, align 8
  %29 = getelementptr inbounds %struct.Value, ptr %9, i32 0, i32 0
  %30 = load i64, ptr %29, align 8, !tbaa !15
  %31 = trunc i64 %30 to i32
  store i32 %31, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #3
  %32 = call { i32, i64 } @token()
  %33 = getelementptr inbounds { i32, i64 }, ptr %10, i32 0, i32 0
  %34 = extractvalue { i32, i64 } %32, 0
  store i32 %34, ptr %33, align 8
  %35 = getelementptr inbounds { i32, i64 }, ptr %10, i32 0, i32 1
  %36 = extractvalue { i32, i64 } %32, 1
  store i64 %36, ptr %35, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %1, ptr align 8 %10, i64 16, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #3
  %37 = getelementptr inbounds %struct.Token, ptr %1, i32 0, i32 0
  %38 = load i32, ptr %37, align 8, !tbaa !13
  %39 = icmp ne i32 %38, 41
  br i1 %39, label %40, label %41

40:                                               ; preds = %22
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.38)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 @peekt, ptr align 8 %1, i64 16, i1 false), !tbaa.struct !11
  br label %41

41:                                               ; preds = %40, %22
  %42 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %42, ptr @radix, align 4, !tbaa !9
  %43 = load i32, ptr %4, align 4, !tbaa !9
  %44 = shl i32 1, %43
  %45 = sub nsw i32 %44, 1
  store i32 %45, ptr %5, align 4, !tbaa !9
  br label %47

46:                                               ; preds = %13
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 @peekt, ptr align 8 %1, i64 16, i1 false), !tbaa.struct !11
  br label %47

47:                                               ; preds = %46, %41
  %48 = call { i64, i32 } @expr(i32 noundef 2, ptr noundef null)
  %49 = getelementptr inbounds { i64, i32 }, ptr %11, i32 0, i32 0
  %50 = extractvalue { i64, i32 } %48, 0
  store i64 %50, ptr %49, align 8
  %51 = getelementptr inbounds { i64, i32 }, ptr %11, i32 0, i32 1
  %52 = extractvalue { i64, i32 } %48, 1
  store i32 %52, ptr %51, align 8
  %53 = getelementptr inbounds %struct.Value, ptr %11, i32 0, i32 0
  %54 = load i64, ptr %53, align 8, !tbaa !15
  %55 = load i32, ptr %5, align 4, !tbaa !9
  %56 = sext i32 %55 to i64
  %57 = and i64 %54, %56
  store i64 %57, ptr %2, align 8, !tbaa !5
  %58 = load i32, ptr %4, align 4, !tbaa !9
  %59 = load i32, ptr %7, align 4, !tbaa !9
  %60 = sub nsw i32 %59, %58
  store i32 %60, ptr %7, align 4, !tbaa !9
  %61 = load i32, ptr %7, align 4, !tbaa !9
  %62 = icmp slt i32 %61, 0
  br i1 %62, label %63, label %67

63:                                               ; preds = %47
  %64 = load i64, ptr %3, align 8, !tbaa !5
  call void @putv(i64 noundef %64, i32 noundef 0)
  store i64 0, ptr %3, align 8, !tbaa !5
  %65 = load i32, ptr %4, align 4, !tbaa !9
  %66 = sub nsw i32 36, %65
  store i32 %66, ptr %7, align 4, !tbaa !9
  br label %67

67:                                               ; preds = %63, %47
  %68 = load i64, ptr %2, align 8, !tbaa !5
  %69 = load i32, ptr %7, align 4, !tbaa !9
  %70 = zext i32 %69 to i64
  %71 = shl i64 %68, %70
  %72 = load i64, ptr %3, align 8, !tbaa !5
  %73 = or i64 %72, %71
  store i64 %73, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #3
  %74 = call { i32, i64 } @token()
  %75 = getelementptr inbounds { i32, i64 }, ptr %12, i32 0, i32 0
  %76 = extractvalue { i32, i64 } %74, 0
  store i32 %76, ptr %75, align 8
  %77 = getelementptr inbounds { i32, i64 }, ptr %12, i32 0, i32 1
  %78 = extractvalue { i32, i64 } %74, 1
  store i64 %78, ptr %77, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %1, ptr align 8 %12, i64 16, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #3
  %79 = getelementptr inbounds %struct.Token, ptr %1, i32 0, i32 0
  %80 = load i32, ptr %79, align 8, !tbaa !13
  %81 = icmp eq i32 %80, 40
  br i1 %81, label %82, label %83

82:                                               ; preds = %67
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 @peekt, ptr align 8 %1, i64 16, i1 false), !tbaa.struct !11
  br label %89

83:                                               ; preds = %67
  %84 = getelementptr inbounds %struct.Token, ptr %1, i32 0, i32 0
  %85 = load i32, ptr %84, align 8, !tbaa !13
  %86 = icmp ne i32 %85, 44
  br i1 %86, label %87, label %88

87:                                               ; preds = %83
  br label %90

88:                                               ; preds = %83
  br label %89

89:                                               ; preds = %88, %82
  br label %13

90:                                               ; preds = %87
  %91 = load i64, ptr %3, align 8, !tbaa !5
  call void @putv(i64 noundef %91, i32 noundef 0)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %1) #3
  ret void
}

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, !6, i64 0}
!6 = !{!"long", !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 4, !9, i64 8, i64 8, !12}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"Token", !10, i64 0, !7, i64 8}
!15 = !{!16, !6, i64 0}
!16 = !{!"Value", !6, i64 0, !10, i64 8}


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

@radix = external dso_local local_unnamed_addr global i32, align 4
@peekt = external dso_local local_unnamed_addr global %struct.Token, align 8
@.str.38 = external hidden unnamed_addr constant [20 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 @putv(i64 noundef, i32 noundef) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
define dso_local void @byteOp() local_unnamed_addr #0 {
  br label %1

1:                                                ; preds = %.backedge, %0
  %.036 = phi i32 [ 36, %0 ], [ %.137, %.backedge ]
  %.034 = phi i32 [ 63, %0 ], [ %.135, %.backedge ]
  %.032 = phi i32 [ 6, %0 ], [ %.133, %.backedge ]
  %.0 = phi i64 [ 0, %0 ], [ %30, %.backedge ]
  %2 = tail call { i32, i64 } @token()
  %3 = extractvalue { i32, i64 } %2, 0
  %4 = icmp eq i32 %3, 40
  br i1 %4, label %5, label %16

5:                                                ; preds = %1
  %6 = load i32, ptr @radix, align 4, !tbaa !5
  store i32 10, ptr @radix, align 4, !tbaa !5
  %7 = tail call { i64, i32 } @expr(i32 noundef 0, ptr noundef null)
  %8 = extractvalue { i64, i32 } %7, 0
  %9 = trunc i64 %8 to i32
  %10 = tail call { i32, i64 } @token()
  %11 = extractvalue { i32, i64 } %10, 0
  %.not = icmp eq i32 %11, 41
  br i1 %.not, label %14, label %12

12:                                               ; preds = %5
  %13 = extractvalue { i32, i64 } %10, 1
  tail call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.38)
  store i32 %11, ptr @peekt, align 8, !tbaa !5
  store i64 %13, ptr getelementptr inbounds (i8, ptr @peekt, i64 8), align 8, !tbaa !9
  br label %14

14:                                               ; preds = %12, %5
  store i32 %6, ptr @radix, align 4, !tbaa !5
  %notmask = shl nsw i32 -1, %9
  %15 = xor i32 %notmask, -1
  br label %18

16:                                               ; preds = %1
  %17 = extractvalue { i32, i64 } %2, 1
  store i32 %3, ptr @peekt, align 8, !tbaa !5
  store i64 %17, ptr getelementptr inbounds (i8, ptr @peekt, i64 8), align 8, !tbaa !9
  br label %18

18:                                               ; preds = %16, %14
  %.135 = phi i32 [ %15, %14 ], [ %.034, %16 ]
  %.133 = phi i32 [ %9, %14 ], [ %.032, %16 ]
  %19 = tail call { i64, i32 } @expr(i32 noundef 2, ptr noundef null)
  %20 = extractvalue { i64, i32 } %19, 0
  %21 = sext i32 %.135 to i64
  %22 = and i64 %20, %21
  %23 = sub nsw i32 %.036, %.133
  %24 = icmp slt i32 %23, 0
  br i1 %24, label %25, label %27

25:                                               ; preds = %18
  tail call void @putv(i64 noundef %.0, i32 noundef 0)
  %26 = sub nsw i32 36, %.133
  br label %27

27:                                               ; preds = %25, %18
  %.137 = phi i32 [ %26, %25 ], [ %23, %18 ]
  %.1 = phi i64 [ 0, %25 ], [ %.0, %18 ]
  %28 = zext nneg i32 %.137 to i64
  %29 = shl i64 %22, %28
  %30 = or i64 %29, %.1
  %31 = tail call { i32, i64 } @token()
  %32 = extractvalue { i32, i64 } %31, 0
  switch i32 %32, label %35 [
    i32 40, label %33
    i32 44, label %.backedge
  ]

.backedge:                                        ; preds = %27, %33
  br label %1

33:                                               ; preds = %27
  %34 = extractvalue { i32, i64 } %31, 1
  store i32 40, ptr @peekt, align 8, !tbaa !5
  store i64 %34, ptr getelementptr inbounds (i8, ptr @peekt, i64 8), align 8, !tbaa !9
  br label %.backedge

35:                                               ; preds = %27
  tail call void @putv(i64 noundef %30, i32 noundef 0)
  ret void
}

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}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass