; LLVM IR from InductiveComputerScience/infracore :: examples/disk-demo1 (program)

; 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.NumberReference = type { double }
%struct.ByteArrayReference = type { ptr, i64 }

@.str = external hidden unnamed_addr constant [22 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [39 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @Program(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca %struct.NumberReference, align 8
  %4 = alloca %struct.NumberReference, align 8
  %5 = alloca i8, align 1
  %6 = alloca %struct.ByteArrayReference, align 8
  %7 = alloca i32, align 4
  %8 = alloca [100 x i8], align 16
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 100, ptr %8) #5
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  call void @Entries(ptr noundef %9, ptr noundef %3, ptr noundef %4)
  %10 = getelementptr inbounds %struct.NumberReference, ptr %3, i32 0, i32 0
  %11 = load double, ptr %10, align 8, !tbaa !9
  %12 = getelementptr inbounds %struct.NumberReference, ptr %4, i32 0, i32 0
  %13 = load double, ptr %12, align 8, !tbaa !9
  %14 = fmul double %11, %13
  %15 = fptosi double %14 to i64
  %16 = call i32 (ptr, ...) @printf(ptr noundef @.str, i64 noundef %15)
  %17 = getelementptr inbounds %struct.NumberReference, ptr %3, i32 0, i32 0
  %18 = load double, ptr %17, align 8, !tbaa !9
  %19 = getelementptr inbounds %struct.NumberReference, ptr %4, i32 0, i32 0
  %20 = load double, ptr %19, align 8, !tbaa !9
  %21 = fmul double %18, %20
  %22 = fptoui double %21 to i64
  %23 = getelementptr inbounds %struct.ByteArrayReference, ptr %6, i32 0, i32 1
  store i64 %22, ptr %23, align 8, !tbaa !12
  %24 = getelementptr inbounds %struct.ByteArrayReference, ptr %6, i32 0, i32 1
  %25 = load i64, ptr %24, align 8, !tbaa !12
  %26 = call noalias ptr @malloc(i64 noundef %25) #6
  %27 = getelementptr inbounds %struct.ByteArrayReference, ptr %6, i32 0, i32 0
  store ptr %26, ptr %27, align 8, !tbaa !15
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = call zeroext i1 @Read(ptr noundef %28, double noundef 0.000000e+00, ptr noundef %6)
  %30 = zext i1 %29 to i8
  store i8 %30, ptr %5, align 1, !tbaa !16
  store i32 0, ptr %7, align 4, !tbaa !18
  br label %31

31:                                               ; preds = %44, %1
  %32 = load i32, ptr %7, align 4, !tbaa !18
  %33 = icmp slt i32 %32, 13
  br i1 %33, label %34, label %47

34:                                               ; preds = %31
  %35 = getelementptr inbounds %struct.ByteArrayReference, ptr %6, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  %37 = load i32, ptr %7, align 4, !tbaa !18
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i8, ptr %36, i64 %38
  %40 = load i8, ptr %39, align 1, !tbaa !20
  %41 = load i32, ptr %7, align 4, !tbaa !18
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [100 x i8], ptr %8, i64 0, i64 %42
  store i8 %40, ptr %43, align 1, !tbaa !20
  br label %44

44:                                               ; preds = %34
  %45 = load i32, ptr %7, align 4, !tbaa !18
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %7, align 4, !tbaa !18
  br label %31, !llvm.loop !21

47:                                               ; preds = %31
  %48 = load i32, ptr %7, align 4, !tbaa !18
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [100 x i8], ptr %8, i64 0, i64 %49
  store i8 0, ptr %50, align 1, !tbaa !20
  %51 = getelementptr inbounds [100 x i8], ptr %8, i64 0, i64 0
  %52 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, ptr noundef %51)
  %53 = getelementptr inbounds %struct.ByteArrayReference, ptr %6, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !15
  call void @free(ptr noundef %54) #5
  call void @llvm.lifetime.end.p0(i64 100, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret void
}

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

declare void @Entries(ptr noundef, ptr noundef, ptr noundef) #2

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

declare zeroext i1 @Read(ptr noundef, double noundef, ptr noundef) #2

; Function Attrs: nounwind
declare void @free(ptr noundef) #4

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

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 = { "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 allocsize(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 "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 }
attributes #6 = { nounwind allocsize(0) }

!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 = !{!"NumberReference", !11, i64 0}
!11 = !{!"double", !7, i64 0}
!12 = !{!13, !14, i64 8}
!13 = !{!"ByteArrayReference", !6, i64 0, !14, i64 8}
!14 = !{!"long", !7, i64 0}
!15 = !{!13, !6, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"_Bool", !7, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"int", !7, i64 0}
!20 = !{!7, !7, i64 0}
!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"

%struct.NumberReference = type { double }
%struct.ByteArrayReference = type { ptr, i64 }

@.str = external hidden unnamed_addr constant [22 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [39 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @Program(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca %struct.NumberReference, align 8
  %3 = alloca %struct.NumberReference, align 8
  %4 = alloca %struct.ByteArrayReference, align 8
  %5 = alloca [100 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 100, ptr nonnull %5) #6
  call void @Entries(ptr noundef %0, ptr noundef nonnull %2, ptr noundef nonnull %3) #6
  %6 = load double, ptr %2, align 8, !tbaa !5
  %7 = load double, ptr %3, align 8, !tbaa !5
  %8 = fmul double %6, %7
  %9 = fptosi double %8 to i64
  %10 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef %9)
  %11 = load double, ptr %2, align 8, !tbaa !5
  %12 = load double, ptr %3, align 8, !tbaa !5
  %13 = fmul double %11, %12
  %14 = fptoui double %13 to i64
  %15 = getelementptr inbounds i8, ptr %4, i64 8
  store i64 %14, ptr %15, align 8, !tbaa !10
  %16 = call noalias ptr @malloc(i64 noundef %14) #7
  store ptr %16, ptr %4, align 8, !tbaa !14
  %17 = call zeroext i1 @Read(ptr noundef %0, double noundef 0.000000e+00, ptr noundef nonnull %4) #6
  %18 = load ptr, ptr %4, align 8, !tbaa !14
  %19 = load <8 x i8>, ptr %18, align 1, !tbaa !15
  store <8 x i8> %19, ptr %5, align 16, !tbaa !15
  %20 = getelementptr inbounds i8, ptr %18, i64 8
  %21 = getelementptr inbounds i8, ptr %5, i64 8
  %22 = load <4 x i8>, ptr %20, align 1, !tbaa !15
  store <4 x i8> %22, ptr %21, align 8, !tbaa !15
  %23 = getelementptr inbounds i8, ptr %18, i64 12
  %24 = load i8, ptr %23, align 1, !tbaa !15
  %25 = getelementptr inbounds i8, ptr %5, i64 12
  store i8 %24, ptr %25, align 4, !tbaa !15
  %26 = getelementptr inbounds i8, ptr %5, i64 13
  store i8 0, ptr %26, align 1, !tbaa !15
  %27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, ptr noundef nonnull %5)
  %28 = load ptr, ptr %4, align 8, !tbaa !14
  call void @free(ptr noundef %28) #6
  call void @llvm.lifetime.end.p0(i64 100, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  ret void
}

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

declare void @Entries(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #4

declare zeroext i1 @Read(ptr noundef, double noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #5

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

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 = { mustprogress nocallback nofree nosync 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 = { 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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!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 = !{!"NumberReference", !7, i64 0}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !13, i64 8}
!11 = !{!"ByteArrayReference", !12, i64 0, !13, i64 8}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"long", !8, i64 0}
!14 = !{!11, !12, i64 0}
!15 = !{!8, !8, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass