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

@__const.printexpr.opnames = external hidden unnamed_addr constant [10 x ptr], align 16
@.str.30 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [5 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

; 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) #1

declare void @unsixbit(i64 noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @printexpr(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca [8 x i8], align 1
  %4 = alloca [10 x ptr], align 16
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 80, ptr %4) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %4, ptr align 16 @__const.printexpr.opnames, i64 80, i1 false)
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.Expr, ptr %5, i32 0, i32 0
  %7 = load i32, ptr %6, align 8, !tbaa !9
  %8 = icmp eq i32 %7, 0
  br i1 %8, label %9, label %19

9:                                                ; preds = %1
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.Expr, ptr %10, i32 0, i32 1
  %12 = getelementptr inbounds %struct.Value, ptr %11, i32 0, i32 0
  %13 = load i64, ptr %12, align 8, !tbaa !14
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.Expr, ptr %14, i32 0, i32 1
  %16 = getelementptr inbounds %struct.Value, ptr %15, i32 0, i32 1
  %17 = load i32, ptr %16, align 8, !tbaa !15
  %18 = call i32 (ptr, ...) @printf(ptr noundef @.str.30, i64 noundef %13, i32 noundef %17)
  br label %76

19:                                               ; preds = %1
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.Expr, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 8, !tbaa !9
  %23 = icmp eq i32 %22, 1
  br i1 %23, label %24, label %33

24:                                               ; preds = %19
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.Expr, ptr %25, i32 0, i32 2
  %27 = load ptr, ptr %26, align 8, !tbaa !16
  %28 = getelementptr inbounds %struct.Sym, ptr %27, i32 0, i32 0
  %29 = load i64, ptr %28, align 8, !tbaa !17
  %30 = getelementptr inbounds [8 x i8], ptr %3, i64 0, i64 0
  call void @unsixbit(i64 noundef %29, ptr noundef %30)
  %31 = getelementptr inbounds [8 x i8], ptr %3, i64 0, i64 0
  %32 = call i32 (ptr, ...) @printf(ptr noundef @.str.31, ptr noundef %31)
  br label %75

33:                                               ; preds = %19
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.Expr, ptr %34, i32 0, i32 0
  %36 = load i32, ptr %35, align 8, !tbaa !9
  %37 = icmp eq i32 %36, 2
  br i1 %37, label %38, label %51

38:                                               ; preds = %33
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.Expr, ptr %39, i32 0, i32 3
  %41 = load i32, ptr %40, align 8, !tbaa !19
  %42 = sub nsw i32 %41, 3
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [10 x ptr], ptr %4, i64 0, i64 %43
  %45 = load ptr, ptr %44, align 8, !tbaa !5
  %46 = call i32 (ptr, ...) @printf(ptr noundef @.str.32, ptr noundef %45)
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.Expr, ptr %47, i32 0, i32 5
  %49 = load ptr, ptr %48, align 8, !tbaa !20
  call void @printexpr(ptr noundef %49)
  %50 = call i32 (ptr, ...) @printf(ptr noundef @.str.33)
  br label %74

51:                                               ; preds = %33
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.Expr, ptr %52, i32 0, i32 0
  %54 = load i32, ptr %53, align 8, !tbaa !9
  %55 = icmp eq i32 %54, 3
  br i1 %55, label %56, label %73

56:                                               ; preds = %51
  %57 = call i32 (ptr, ...) @printf(ptr noundef @.str.34)
  %58 = load ptr, ptr %2, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.Expr, ptr %58, i32 0, i32 4
  %60 = load ptr, ptr %59, align 8, !tbaa !21
  call void @printexpr(ptr noundef %60)
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.Expr, ptr %61, i32 0, i32 3
  %63 = load i32, ptr %62, align 8, !tbaa !19
  %64 = sub nsw i32 %63, 3
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [10 x ptr], ptr %4, i64 0, i64 %65
  %67 = load ptr, ptr %66, align 8, !tbaa !5
  %68 = call i32 (ptr, ...) @printf(ptr noundef @.str.35, ptr noundef %67)
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.Expr, ptr %69, i32 0, i32 5
  %71 = load ptr, ptr %70, align 8, !tbaa !20
  call void @printexpr(ptr noundef %71)
  %72 = call i32 (ptr, ...) @printf(ptr noundef @.str.33)
  br label %73

73:                                               ; preds = %56, %51
  br label %74

74:                                               ; preds = %73, %38
  br label %75

75:                                               ; preds = %74, %24
  br label %76

76:                                               ; preds = %75, %9
  call void @llvm.lifetime.end.p0(i64 80, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret void
}

declare i32 @printf(ptr noundef, ...) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 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 #4 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"Expr", !11, i64 0, !12, i64 8, !6, i64 24, !11, i64 32, !6, i64 40, !6, i64 48}
!11 = !{!"int", !7, i64 0}
!12 = !{!"Value", !13, i64 0, !11, i64 8}
!13 = !{!"long", !7, i64 0}
!14 = !{!10, !13, i64 8}
!15 = !{!10, !11, i64 16}
!16 = !{!10, !6, i64 24}
!17 = !{!18, !13, i64 0}
!18 = !{!"Sym", !13, i64 0, !11, i64 8, !7, i64 16, !6, i64 32}
!19 = !{!10, !11, i64 32}
!20 = !{!10, !6, i64 48}
!21 = !{!10, !6, i64 40}


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

@__const.printexpr.opnames = external hidden unnamed_addr constant [10 x ptr], align 16
@.str.30 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [5 x i8], align 1

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

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

declare void @unsixbit(i64 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @printexpr(ptr nocapture noundef readonly %0) local_unnamed_addr #2 {
  %2 = alloca [8 x i8], align 1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  %3 = load i32, ptr %0, align 8, !tbaa !5
  switch i32 %3, label %40 [
    i32 0, label %4
    i32 1, label %10
    i32 2, label %15
    i32 3, label %26
  ]

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load i64, ptr %5, align 8, !tbaa !13
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load i32, ptr %7, align 8, !tbaa !14
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.30, i64 noundef %6, i32 noundef %8)
  br label %40

10:                                               ; preds = %1
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = load ptr, ptr %11, align 8, !tbaa !15
  %13 = load i64, ptr %12, align 8, !tbaa !16
  call void @unsixbit(i64 noundef %13, ptr noundef nonnull %2) #4
  %14 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.31, ptr noundef nonnull %2)
  br label %40

15:                                               ; preds = %1
  %16 = getelementptr inbounds i8, ptr %0, i64 32
  %17 = load i32, ptr %16, align 8, !tbaa !18
  %18 = add nsw i32 %17, -3
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [10 x ptr], ptr @__const.printexpr.opnames, i64 0, i64 %19
  %21 = load ptr, ptr %20, align 8, !tbaa !19
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.32, ptr noundef %21)
  %23 = getelementptr inbounds i8, ptr %0, i64 48
  %24 = load ptr, ptr %23, align 8, !tbaa !20
  tail call void @printexpr(ptr noundef %24)
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.33)
  br label %40

26:                                               ; preds = %1
  %27 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.34)
  %28 = getelementptr inbounds i8, ptr %0, i64 40
  %29 = load ptr, ptr %28, align 8, !tbaa !21
  tail call void @printexpr(ptr noundef %29)
  %30 = getelementptr inbounds i8, ptr %0, i64 32
  %31 = load i32, ptr %30, align 8, !tbaa !18
  %32 = add nsw i32 %31, -3
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [10 x ptr], ptr @__const.printexpr.opnames, i64 0, i64 %33
  %35 = load ptr, ptr %34, align 8, !tbaa !19
  %36 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.35, ptr noundef %35)
  %37 = getelementptr inbounds i8, ptr %0, i64 48
  %38 = load ptr, ptr %37, align 8, !tbaa !20
  tail call void @printexpr(ptr noundef %38)
  %39 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.33)
  br label %40

40:                                               ; preds = %1, %10, %26, %15, %4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

attributes #0 = { mustprogress 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 = { 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 #4 = { 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 = !{!"Expr", !7, i64 0, !10, i64 8, !12, i64 24, !7, i64 32, !12, i64 40, !12, i64 48}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"Value", !11, i64 0, !7, i64 8}
!11 = !{!"long", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!6, !11, i64 8}
!14 = !{!6, !7, i64 16}
!15 = !{!6, !12, i64 24}
!16 = !{!17, !11, i64 0}
!17 = !{!"Sym", !11, i64 0, !7, i64 8, !8, i64 16, !12, i64 32}
!18 = !{!6, !7, i64 32}
!19 = !{!12, !12, i64 0}
!20 = !{!6, !12, i64 48}
!21 = !{!6, !12, i64 40}


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