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

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

; 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 i64 @readsimh(ptr noundef %0) #1 {
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  %4 = alloca [8 x i8], align 1
  %5 = alloca [2 x i64], align 16
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #3
  %7 = getelementptr inbounds [8 x i8], ptr %4, i64 0, i64 0
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = call i64 @fread(ptr noundef %7, i64 noundef 1, i64 noundef 8, ptr noundef %8)
  %10 = icmp ne i64 %9, 8
  br i1 %10, label %11, label %12

11:                                               ; preds = %1
  store i64 -1, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %60

12:                                               ; preds = %1
  %13 = getelementptr inbounds [8 x i8], ptr %4, i64 0, i64 3
  %14 = load i8, ptr %13, align 1, !tbaa !9
  %15 = zext i8 %14 to i32
  %16 = shl i32 %15, 24
  %17 = getelementptr inbounds [8 x i8], ptr %4, i64 0, i64 2
  %18 = load i8, ptr %17, align 1, !tbaa !9
  %19 = zext i8 %18 to i32
  %20 = shl i32 %19, 16
  %21 = or i32 %16, %20
  %22 = getelementptr inbounds [8 x i8], ptr %4, i64 0, i64 1
  %23 = load i8, ptr %22, align 1, !tbaa !9
  %24 = zext i8 %23 to i32
  %25 = shl i32 %24, 8
  %26 = or i32 %21, %25
  %27 = getelementptr inbounds [8 x i8], ptr %4, i64 0, i64 0
  %28 = load i8, ptr %27, align 1, !tbaa !9
  %29 = zext i8 %28 to i32
  %30 = or i32 %26, %29
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [2 x i64], ptr %5, i64 0, i64 0
  store i64 %31, ptr %32, align 16, !tbaa !10
  %33 = getelementptr inbounds [8 x i8], ptr %4, i64 0, i64 7
  %34 = load i8, ptr %33, align 1, !tbaa !9
  %35 = zext i8 %34 to i32
  %36 = shl i32 %35, 24
  %37 = getelementptr inbounds [8 x i8], ptr %4, i64 0, i64 6
  %38 = load i8, ptr %37, align 1, !tbaa !9
  %39 = zext i8 %38 to i32
  %40 = shl i32 %39, 16
  %41 = or i32 %36, %40
  %42 = getelementptr inbounds [8 x i8], ptr %4, i64 0, i64 5
  %43 = load i8, ptr %42, align 1, !tbaa !9
  %44 = zext i8 %43 to i32
  %45 = shl i32 %44, 8
  %46 = or i32 %41, %45
  %47 = getelementptr inbounds [8 x i8], ptr %4, i64 0, i64 4
  %48 = load i8, ptr %47, align 1, !tbaa !9
  %49 = zext i8 %48 to i32
  %50 = or i32 %46, %49
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [2 x i64], ptr %5, i64 0, i64 1
  store i64 %51, ptr %52, align 8, !tbaa !10
  %53 = getelementptr inbounds [2 x i64], ptr %5, i64 0, i64 0
  %54 = load i64, ptr %53, align 16, !tbaa !10
  %55 = shl i64 %54, 18
  %56 = getelementptr inbounds [2 x i64], ptr %5, i64 0, i64 1
  %57 = load i64, ptr %56, align 8, !tbaa !10
  %58 = or i64 %55, %57
  %59 = and i64 %58, 68719476735
  store i64 %59, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %60

60:                                               ; preds = %12, %11
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %61 = load i64, ptr %2, align 8
  ret i64 %61
}

declare i64 @fread(ptr noundef, i64 noundef, i64 noundef, 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !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"

; 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

; Function Attrs: nofree nounwind uwtable
define dso_local range(i64 -1, 68719476736) i64 @readsimh(ptr nocapture noundef %0) local_unnamed_addr #1 {
  %2 = alloca [8 x i8], align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  %3 = call i64 @fread(ptr noundef nonnull %2, i64 noundef 1, i64 noundef 8, ptr noundef %0)
  %.not = icmp eq i64 %3, 8
  br i1 %.not, label %4, label %13

4:                                                ; preds = %1
  %5 = load i32, ptr %2, align 4
  %6 = sext i32 %5 to i64
  %7 = getelementptr inbounds i8, ptr %2, i64 4
  %8 = load i32, ptr %7, align 4
  %9 = sext i32 %8 to i64
  %10 = shl nsw i64 %6, 18
  %11 = or i64 %10, %9
  %12 = and i64 %11, 68719476735
  br label %13

13:                                               ; preds = %1, %4
  %.0 = phi i64 [ %12, %4 ], [ -1, %1 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  ret i64 %.0
}

; Function Attrs: nofree nounwind
declare noundef i64 @fread(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #2

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


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