; LLVM IR from aap/pdp6 :: emu (mem)

; 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.Membus = type { i64, i64, i64, i64, i64, i64, ptr, [16 x ptr] }
%struct.Mem = type { %struct.Device, ptr, [4 x ptr], ptr, ptr, ptr }
%struct.Device = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.FMem = type { [16 x i64], i8, i8, i8 }
%struct.CMem = type { ptr, i32, i32, ptr, i64, i32, i8, i8, i8, i8, i8, i8 }

@.str.11 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [15 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: nounwind uwtable
define dso_local void @showmem(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.Membus, ptr %6, i32 0, i32 6
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = icmp ne ptr %8, null
  br i1 %9, label %10, label %21

10:                                               ; preds = %1
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.Membus, ptr %11, i32 0, i32 6
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = getelementptr inbounds %struct.Mem, ptr %13, i32 0, i32 1
  %15 = load ptr, ptr %14, align 8, !tbaa !12
  store ptr %15, ptr %5, align 8, !tbaa !5
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.FMem, ptr %16, i32 0, i32 1
  %18 = load i8, ptr %17, align 8, !tbaa !15
  %19 = sext i8 %18 to i32
  %20 = call i32 (ptr, ...) @printf(ptr noundef @.str.11, i32 noundef %19)
  br label %21

21:                                               ; preds = %10, %1
  store i32 0, ptr %3, align 4, !tbaa !17
  br label %22

22:                                               ; preds = %53, %21
  %23 = load i32, ptr %3, align 4, !tbaa !17
  %24 = icmp slt i32 %23, 16
  br i1 %24, label %25, label %56

25:                                               ; preds = %22
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.Membus, ptr %26, i32 0, i32 7
  %28 = load i32, ptr %3, align 4, !tbaa !17
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [16 x ptr], ptr %27, i64 0, i64 %29
  %31 = load ptr, ptr %30, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %52

33:                                               ; preds = %25
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.Membus, ptr %34, i32 0, i32 7
  %36 = load i32, ptr %3, align 4, !tbaa !17
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [16 x ptr], ptr %35, i64 0, i64 %37
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.Mem, ptr %39, i32 0, i32 1
  %41 = load ptr, ptr %40, align 8, !tbaa !12
  store ptr %41, ptr %4, align 8, !tbaa !5
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.CMem, ptr %42, i32 0, i32 0
  %44 = load ptr, ptr %43, align 8, !tbaa !19
  %45 = load i32, ptr %3, align 4, !tbaa !17
  %46 = shl i32 %45, 14
  %47 = load i32, ptr %3, align 4, !tbaa !17
  %48 = add nsw i32 %47, 1
  %49 = shl i32 %48, 14
  %50 = sub nsw i32 %49, 1
  %51 = call i32 (ptr, ...) @printf(ptr noundef @.str.12, ptr noundef %44, i32 noundef %46, i32 noundef %50)
  br label %52

52:                                               ; preds = %33, %25
  br label %53

53:                                               ; preds = %52
  %54 = load i32, ptr %3, align 4, !tbaa !17
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %3, align 4, !tbaa !17
  br label %22, !llvm.loop !21

56:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 }

!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, !6, i64 48}
!10 = !{!"Membus", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !6, i64 48, !7, i64 56}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !6, i64 64}
!13 = !{!"Mem", !14, i64 0, !6, i64 64, !7, i64 72, !6, i64 104, !6, i64 112, !6, i64 120}
!14 = !{!"Device", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!15 = !{!16, !7, i64 128}
!16 = !{!"FMem", !7, i64 0, !7, i64 128, !7, i64 129, !7, i64 130}
!17 = !{!18, !18, i64 0}
!18 = !{!"int", !7, i64 0}
!19 = !{!20, !6, i64 0}
!20 = !{!"CMem", !6, i64 0, !18, i64 8, !18, i64 12, !6, i64 16, !11, i64 24, !18, i64 32, !7, i64 36, !7, i64 37, !7, i64 38, !7, i64 39, !7, i64 40, !7, i64 41}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


; 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.11 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [15 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local void @showmem(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 48
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %11, label %4

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %3, i64 64
  %6 = load ptr, ptr %5, align 8, !tbaa !11
  %7 = getelementptr inbounds i8, ptr %6, i64 128
  %8 = load i8, ptr %7, align 8, !tbaa !14
  %9 = sext i8 %8 to i32
  %10 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, i32 noundef %9)
  br label %11

11:                                               ; preds = %4, %1
  %12 = getelementptr inbounds i8, ptr %0, i64 56
  %13 = load ptr, ptr %12, align 8, !tbaa !16
  %.not13 = icmp eq ptr %13, null
  br i1 %.not13, label %19, label %14

14:                                               ; preds = %11
  %15 = getelementptr inbounds i8, ptr %13, i64 64
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  %17 = load ptr, ptr %16, align 8, !tbaa !17
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, ptr noundef %17, i32 noundef 0, i32 noundef 16383)
  br label %19

19:                                               ; preds = %11, %14
  %20 = getelementptr inbounds i8, ptr %0, i64 64
  %21 = load ptr, ptr %20, align 8, !tbaa !16
  %.not13.1 = icmp eq ptr %21, null
  br i1 %.not13.1, label %27, label %22

22:                                               ; preds = %19
  %23 = getelementptr inbounds i8, ptr %21, i64 64
  %24 = load ptr, ptr %23, align 8, !tbaa !11
  %25 = load ptr, ptr %24, align 8, !tbaa !17
  %26 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, ptr noundef %25, i32 noundef 16384, i32 noundef 32767)
  br label %27

27:                                               ; preds = %22, %19
  %28 = getelementptr inbounds i8, ptr %0, i64 72
  %29 = load ptr, ptr %28, align 8, !tbaa !16
  %.not13.2 = icmp eq ptr %29, null
  br i1 %.not13.2, label %35, label %30

30:                                               ; preds = %27
  %31 = getelementptr inbounds i8, ptr %29, i64 64
  %32 = load ptr, ptr %31, align 8, !tbaa !11
  %33 = load ptr, ptr %32, align 8, !tbaa !17
  %34 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, ptr noundef %33, i32 noundef 32768, i32 noundef 49151)
  br label %35

35:                                               ; preds = %30, %27
  %36 = getelementptr inbounds i8, ptr %0, i64 80
  %37 = load ptr, ptr %36, align 8, !tbaa !16
  %.not13.3 = icmp eq ptr %37, null
  br i1 %.not13.3, label %43, label %38

38:                                               ; preds = %35
  %39 = getelementptr inbounds i8, ptr %37, i64 64
  %40 = load ptr, ptr %39, align 8, !tbaa !11
  %41 = load ptr, ptr %40, align 8, !tbaa !17
  %42 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, ptr noundef %41, i32 noundef 49152, i32 noundef 65535)
  br label %43

43:                                               ; preds = %38, %35
  %44 = getelementptr inbounds i8, ptr %0, i64 88
  %45 = load ptr, ptr %44, align 8, !tbaa !16
  %.not13.4 = icmp eq ptr %45, null
  br i1 %.not13.4, label %51, label %46

46:                                               ; preds = %43
  %47 = getelementptr inbounds i8, ptr %45, i64 64
  %48 = load ptr, ptr %47, align 8, !tbaa !11
  %49 = load ptr, ptr %48, align 8, !tbaa !17
  %50 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, ptr noundef %49, i32 noundef 65536, i32 noundef 81919)
  br label %51

51:                                               ; preds = %46, %43
  %52 = getelementptr inbounds i8, ptr %0, i64 96
  %53 = load ptr, ptr %52, align 8, !tbaa !16
  %.not13.5 = icmp eq ptr %53, null
  br i1 %.not13.5, label %59, label %54

54:                                               ; preds = %51
  %55 = getelementptr inbounds i8, ptr %53, i64 64
  %56 = load ptr, ptr %55, align 8, !tbaa !11
  %57 = load ptr, ptr %56, align 8, !tbaa !17
  %58 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, ptr noundef %57, i32 noundef 81920, i32 noundef 98303)
  br label %59

59:                                               ; preds = %54, %51
  %60 = getelementptr inbounds i8, ptr %0, i64 104
  %61 = load ptr, ptr %60, align 8, !tbaa !16
  %.not13.6 = icmp eq ptr %61, null
  br i1 %.not13.6, label %67, label %62

62:                                               ; preds = %59
  %63 = getelementptr inbounds i8, ptr %61, i64 64
  %64 = load ptr, ptr %63, align 8, !tbaa !11
  %65 = load ptr, ptr %64, align 8, !tbaa !17
  %66 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, ptr noundef %65, i32 noundef 98304, i32 noundef 114687)
  br label %67

67:                                               ; preds = %62, %59
  %68 = getelementptr inbounds i8, ptr %0, i64 112
  %69 = load ptr, ptr %68, align 8, !tbaa !16
  %.not13.7 = icmp eq ptr %69, null
  br i1 %.not13.7, label %75, label %70

70:                                               ; preds = %67
  %71 = getelementptr inbounds i8, ptr %69, i64 64
  %72 = load ptr, ptr %71, align 8, !tbaa !11
  %73 = load ptr, ptr %72, align 8, !tbaa !17
  %74 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, ptr noundef %73, i32 noundef 114688, i32 noundef 131071)
  br label %75

75:                                               ; preds = %70, %67
  %76 = getelementptr inbounds i8, ptr %0, i64 120
  %77 = load ptr, ptr %76, align 8, !tbaa !16
  %.not13.8 = icmp eq ptr %77, null
  br i1 %.not13.8, label %83, label %78

78:                                               ; preds = %75
  %79 = getelementptr inbounds i8, ptr %77, i64 64
  %80 = load ptr, ptr %79, align 8, !tbaa !11
  %81 = load ptr, ptr %80, align 8, !tbaa !17
  %82 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, ptr noundef %81, i32 noundef 131072, i32 noundef 147455)
  br label %83

83:                                               ; preds = %78, %75
  %84 = getelementptr inbounds i8, ptr %0, i64 128
  %85 = load ptr, ptr %84, align 8, !tbaa !16
  %.not13.9 = icmp eq ptr %85, null
  br i1 %.not13.9, label %91, label %86

86:                                               ; preds = %83
  %87 = getelementptr inbounds i8, ptr %85, i64 64
  %88 = load ptr, ptr %87, align 8, !tbaa !11
  %89 = load ptr, ptr %88, align 8, !tbaa !17
  %90 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, ptr noundef %89, i32 noundef 147456, i32 noundef 163839)
  br label %91

91:                                               ; preds = %86, %83
  %92 = getelementptr inbounds i8, ptr %0, i64 136
  %93 = load ptr, ptr %92, align 8, !tbaa !16
  %.not13.10 = icmp eq ptr %93, null
  br i1 %.not13.10, label %99, label %94

94:                                               ; preds = %91
  %95 = getelementptr inbounds i8, ptr %93, i64 64
  %96 = load ptr, ptr %95, align 8, !tbaa !11
  %97 = load ptr, ptr %96, align 8, !tbaa !17
  %98 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, ptr noundef %97, i32 noundef 163840, i32 noundef 180223)
  br label %99

99:                                               ; preds = %94, %91
  %100 = getelementptr inbounds i8, ptr %0, i64 144
  %101 = load ptr, ptr %100, align 8, !tbaa !16
  %.not13.11 = icmp eq ptr %101, null
  br i1 %.not13.11, label %107, label %102

102:                                              ; preds = %99
  %103 = getelementptr inbounds i8, ptr %101, i64 64
  %104 = load ptr, ptr %103, align 8, !tbaa !11
  %105 = load ptr, ptr %104, align 8, !tbaa !17
  %106 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, ptr noundef %105, i32 noundef 180224, i32 noundef 196607)
  br label %107

107:                                              ; preds = %102, %99
  %108 = getelementptr inbounds i8, ptr %0, i64 152
  %109 = load ptr, ptr %108, align 8, !tbaa !16
  %.not13.12 = icmp eq ptr %109, null
  br i1 %.not13.12, label %115, label %110

110:                                              ; preds = %107
  %111 = getelementptr inbounds i8, ptr %109, i64 64
  %112 = load ptr, ptr %111, align 8, !tbaa !11
  %113 = load ptr, ptr %112, align 8, !tbaa !17
  %114 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, ptr noundef %113, i32 noundef 196608, i32 noundef 212991)
  br label %115

115:                                              ; preds = %110, %107
  %116 = getelementptr inbounds i8, ptr %0, i64 160
  %117 = load ptr, ptr %116, align 8, !tbaa !16
  %.not13.13 = icmp eq ptr %117, null
  br i1 %.not13.13, label %123, label %118

118:                                              ; preds = %115
  %119 = getelementptr inbounds i8, ptr %117, i64 64
  %120 = load ptr, ptr %119, align 8, !tbaa !11
  %121 = load ptr, ptr %120, align 8, !tbaa !17
  %122 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, ptr noundef %121, i32 noundef 212992, i32 noundef 229375)
  br label %123

123:                                              ; preds = %118, %115
  %124 = getelementptr inbounds i8, ptr %0, i64 168
  %125 = load ptr, ptr %124, align 8, !tbaa !16
  %.not13.14 = icmp eq ptr %125, null
  br i1 %.not13.14, label %131, label %126

126:                                              ; preds = %123
  %127 = getelementptr inbounds i8, ptr %125, i64 64
  %128 = load ptr, ptr %127, align 8, !tbaa !11
  %129 = load ptr, ptr %128, align 8, !tbaa !17
  %130 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, ptr noundef %129, i32 noundef 229376, i32 noundef 245759)
  br label %131

131:                                              ; preds = %126, %123
  %132 = getelementptr inbounds i8, ptr %0, i64 176
  %133 = load ptr, ptr %132, align 8, !tbaa !16
  %.not13.15 = icmp eq ptr %133, null
  br i1 %.not13.15, label %139, label %134

134:                                              ; preds = %131
  %135 = getelementptr inbounds i8, ptr %133, i64 64
  %136 = load ptr, ptr %135, align 8, !tbaa !11
  %137 = load ptr, ptr %136, align 8, !tbaa !17
  %138 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, ptr noundef %137, i32 noundef 245760, i32 noundef 262143)
  br label %139

139:                                              ; preds = %134, %131
  ret void
}

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

attributes #0 = { nofree 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 = { 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" }

!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, !10, i64 48}
!6 = !{!"Membus", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !10, i64 48, !8, i64 56}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!12, !10, i64 64}
!12 = !{!"Mem", !13, i64 0, !10, i64 64, !8, i64 72, !10, i64 104, !10, i64 112, !10, i64 120}
!13 = !{!"Device", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56}
!14 = !{!15, !8, i64 128}
!15 = !{!"FMem", !8, i64 0, !8, i64 128, !8, i64 129, !8, i64 130}
!16 = !{!10, !10, i64 0}
!17 = !{!18, !10, i64 0}
!18 = !{!"CMem", !10, i64 0, !19, i64 8, !19, i64 12, !10, i64 16, !7, i64 24, !19, i64 32, !8, i64 36, !8, i64 37, !8, i64 38, !8, i64 39, !8, i64 40, !8, i64 41}
!19 = !{!"int", !8, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass