; LLVM IR from aap/pdp6 :: fe6/6 (emu6)

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

@fd6 = external hidden global i32, align 4
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [12 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

declare i64 @write(i32 noundef, ptr noundef, i64 noundef) #1

declare i32 @readn(i32 noundef, ptr noundef, i32 noundef) #1

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

declare void @quit() #1

; 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 i32 @readreg(i32 noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca [11 x i8], align 1
  %4 = alloca i16, align 2
  %5 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 11, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 2, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %6 = getelementptr inbounds [11 x i8], ptr %3, i64 0, i64 0
  store i8 0, ptr %6, align 1, !tbaa !9
  %7 = getelementptr inbounds [11 x i8], ptr %3, i64 0, i64 1
  store i8 5, ptr %7, align 1, !tbaa !9
  %8 = getelementptr inbounds [11 x i8], ptr %3, i64 0, i64 2
  store i8 2, ptr %8, align 1, !tbaa !9
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = trunc i32 %9 to i8
  %11 = getelementptr inbounds [11 x i8], ptr %3, i64 0, i64 3
  store i8 %10, ptr %11, align 1, !tbaa !9
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = lshr i32 %12, 8
  %14 = trunc i32 %13 to i8
  %15 = getelementptr inbounds [11 x i8], ptr %3, i64 0, i64 4
  store i8 %14, ptr %15, align 1, !tbaa !9
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = lshr i32 %16, 16
  %18 = trunc i32 %17 to i8
  %19 = getelementptr inbounds [11 x i8], ptr %3, i64 0, i64 5
  store i8 %18, ptr %19, align 1, !tbaa !9
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = lshr i32 %20, 24
  %22 = trunc i32 %21 to i8
  %23 = getelementptr inbounds [11 x i8], ptr %3, i64 0, i64 6
  store i8 %22, ptr %23, align 1, !tbaa !9
  %24 = load i32, ptr @fd6, align 4, !tbaa !5
  %25 = getelementptr inbounds [11 x i8], ptr %3, i64 0, i64 0
  %26 = getelementptr inbounds [11 x i8], ptr %3, i64 0, i64 1
  %27 = load i8, ptr %26, align 1, !tbaa !9
  %28 = zext i8 %27 to i32
  %29 = add nsw i32 %28, 2
  %30 = sext i32 %29 to i64
  %31 = call i64 @write(i32 noundef %24, ptr noundef %25, i64 noundef %30)
  %32 = load i32, ptr @fd6, align 4, !tbaa !5
  %33 = getelementptr inbounds [11 x i8], ptr %3, i64 0, i64 0
  %34 = call i32 @readn(i32 noundef %32, ptr noundef %33, i32 noundef 2)
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %38

36:                                               ; preds = %1
  %37 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  call void @quit()
  br label %38

38:                                               ; preds = %36, %1
  %39 = getelementptr inbounds [11 x i8], ptr %3, i64 0, i64 0
  %40 = load i8, ptr %39, align 1, !tbaa !9
  %41 = zext i8 %40 to i32
  %42 = shl i32 %41, 8
  %43 = getelementptr inbounds [11 x i8], ptr %3, i64 0, i64 1
  %44 = load i8, ptr %43, align 1, !tbaa !9
  %45 = zext i8 %44 to i32
  %46 = or i32 %42, %45
  %47 = trunc i32 %46 to i16
  store i16 %47, ptr %4, align 2, !tbaa !10
  %48 = load i16, ptr %4, align 2, !tbaa !10
  %49 = zext i16 %48 to i32
  %50 = icmp ne i32 %49, 5
  br i1 %50, label %51, label %55

51:                                               ; preds = %38
  %52 = load i16, ptr %4, align 2, !tbaa !10
  %53 = zext i16 %52 to i32
  %54 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %53)
  call void @quit()
  br label %55

55:                                               ; preds = %51, %38
  %56 = load i32, ptr @fd6, align 4, !tbaa !5
  %57 = getelementptr inbounds [11 x i8], ptr %3, i64 0, i64 0
  %58 = load i16, ptr %4, align 2, !tbaa !10
  %59 = zext i16 %58 to i32
  %60 = call i32 @readn(i32 noundef %56, ptr noundef %57, i32 noundef %59)
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %62, label %64

62:                                               ; preds = %55
  %63 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  call void @quit()
  br label %64

64:                                               ; preds = %62, %55
  %65 = getelementptr inbounds [11 x i8], ptr %3, i64 0, i64 0
  %66 = load i8, ptr %65, align 1, !tbaa !9
  %67 = zext i8 %66 to i32
  %68 = icmp ne i32 %67, 3
  br i1 %68, label %69, label %74

69:                                               ; preds = %64
  %70 = getelementptr inbounds [11 x i8], ptr %3, i64 0, i64 0
  %71 = load i8, ptr %70, align 1, !tbaa !9
  %72 = zext i8 %71 to i32
  %73 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %72)
  call void @quit()
  br label %74

74:                                               ; preds = %69, %64
  %75 = getelementptr inbounds [11 x i8], ptr %3, i64 0, i64 1
  %76 = load i8, ptr %75, align 1, !tbaa !9
  %77 = zext i8 %76 to i32
  %78 = getelementptr inbounds [11 x i8], ptr %3, i64 0, i64 2
  %79 = load i8, ptr %78, align 1, !tbaa !9
  %80 = zext i8 %79 to i32
  %81 = shl i32 %80, 8
  %82 = or i32 %77, %81
  %83 = getelementptr inbounds [11 x i8], ptr %3, i64 0, i64 3
  %84 = load i8, ptr %83, align 1, !tbaa !9
  %85 = zext i8 %84 to i32
  %86 = shl i32 %85, 16
  %87 = or i32 %82, %86
  %88 = getelementptr inbounds [11 x i8], ptr %3, i64 0, i64 4
  %89 = load i8, ptr %88, align 1, !tbaa !9
  %90 = zext i8 %89 to i32
  %91 = shl i32 %90, 24
  %92 = or i32 %87, %91
  store i32 %92, ptr %5, align 4, !tbaa !5
  %93 = load i32, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 11, ptr %3) #3
  ret i32 %93
}

attributes #0 = { 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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"short", !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"

@fd6 = external hidden local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [12 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: nofree
declare noundef i64 @write(i32 noundef, ptr nocapture noundef readonly, i64 noundef) local_unnamed_addr #1

declare i32 @readn(i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

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

declare void @quit() local_unnamed_addr #2

; Function Attrs: mustprogress 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 i32 @readreg(i32 noundef %0) local_unnamed_addr #4 {
  %2 = alloca [11 x i8], align 1
  call void @llvm.lifetime.start.p0(i64 11, ptr nonnull %2) #5
  store i8 0, ptr %2, align 1, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %2, i64 1
  store i8 5, ptr %3, align 1, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %2, i64 2
  store i8 2, ptr %4, align 1, !tbaa !5
  %5 = trunc i32 %0 to i8
  %6 = getelementptr inbounds i8, ptr %2, i64 3
  store i8 %5, ptr %6, align 1, !tbaa !5
  %7 = lshr i32 %0, 8
  %8 = trunc i32 %7 to i8
  %9 = getelementptr inbounds i8, ptr %2, i64 4
  store i8 %8, ptr %9, align 1, !tbaa !5
  %10 = lshr i32 %0, 16
  %11 = trunc i32 %10 to i8
  %12 = getelementptr inbounds i8, ptr %2, i64 5
  store i8 %11, ptr %12, align 1, !tbaa !5
  %13 = lshr i32 %0, 24
  %14 = trunc nuw i32 %13 to i8
  %15 = getelementptr inbounds i8, ptr %2, i64 6
  store i8 %14, ptr %15, align 1, !tbaa !5
  %16 = load i32, ptr @fd6, align 4, !tbaa !8
  %17 = call i64 @write(i32 noundef %16, ptr noundef nonnull %2, i64 noundef 7) #5
  %18 = load i32, ptr @fd6, align 4, !tbaa !8
  %19 = call i32 @readn(i32 noundef %18, ptr noundef nonnull %2, i32 noundef 2) #5
  %.not = icmp eq i32 %19, 0
  br i1 %.not, label %22, label %20

20:                                               ; preds = %1
  %21 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  call void @quit() #5
  br label %22

22:                                               ; preds = %20, %1
  %23 = load i8, ptr %2, align 1, !tbaa !5
  %24 = zext i8 %23 to i32
  %25 = shl nuw nsw i32 %24, 8
  %26 = load i8, ptr %3, align 1, !tbaa !5
  %27 = zext i8 %26 to i32
  %28 = or disjoint i32 %25, %27
  %.not9 = icmp eq i32 %28, 5
  br i1 %.not9, label %31, label %29

29:                                               ; preds = %22
  %30 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %28)
  call void @quit() #5
  br label %31

31:                                               ; preds = %29, %22
  %32 = load i32, ptr @fd6, align 4, !tbaa !8
  %33 = call i32 @readn(i32 noundef %32, ptr noundef nonnull %2, i32 noundef %28) #5
  %.not10 = icmp eq i32 %33, 0
  br i1 %.not10, label %36, label %34

34:                                               ; preds = %31
  %35 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  call void @quit() #5
  br label %36

36:                                               ; preds = %34, %31
  %37 = load i8, ptr %2, align 1, !tbaa !5
  %.not11 = icmp eq i8 %37, 3
  br i1 %.not11, label %41, label %38

38:                                               ; preds = %36
  %39 = zext i8 %37 to i32
  %40 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %39)
  call void @quit() #5
  br label %41

41:                                               ; preds = %38, %36
  %42 = load i32, ptr %3, align 1
  call void @llvm.lifetime.end.p0(i64 11, ptr nonnull %2) #5
  ret i32 %42
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nofree "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 = { 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 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 #5 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}


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