; LLVM IR from InductiveComputerScience/infracore :: drivers/puc-linux-processes (linux-processes-puc)

; 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.__jmp_buf_tag = type { [8 x i64], i32, %struct.__sigset_t }
%struct.__sigset_t = type { [16 x i64] }
%struct.ProcessingUnitControllerStructure = type { ptr }
%struct.ProcessingUnitControllerProcessesStructure = type { double, double, ptr, ptr }

@wasException = external hidden global i8, align 1
@sigbuf = external hidden global [1 x %struct.__jmp_buf_tag], align 16

; Function Attrs: nounwind uwtable
define dso_local void @CreateProcessingUnitControllerProcesses(ptr noundef %0, double noundef %1, ptr noundef %2, double noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca ptr, align 8
  %8 = alloca double, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store double %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store double %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  %12 = call noalias ptr @malloc(i64 noundef 8) #8
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %12, ptr %13, align 8, !tbaa !5
  %14 = call noalias ptr @malloc(i64 noundef 32) #8
  store ptr %14, ptr %9, align 8, !tbaa !5
  %15 = load ptr, ptr %9, align 8, !tbaa !5
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.ProcessingUnitControllerStructure, ptr %17, i32 0, i32 0
  store ptr %15, ptr %18, align 8, !tbaa !11
  %19 = load double, ptr %6, align 8, !tbaa !9
  %20 = load ptr, ptr %9, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.ProcessingUnitControllerProcessesStructure, ptr %20, i32 0, i32 0
  store double %19, ptr %21, align 8, !tbaa !13
  %22 = load double, ptr %8, align 8, !tbaa !9
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.ProcessingUnitControllerProcessesStructure, ptr %23, i32 0, i32 1
  store double %22, ptr %24, align 8, !tbaa !15
  %25 = load double, ptr %6, align 8, !tbaa !9
  %26 = fmul double %25, 4.000000e+00
  %27 = fptoui double %26 to i64
  %28 = call noalias ptr @malloc(i64 noundef %27) #8
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.ProcessingUnitControllerProcessesStructure, ptr %29, i32 0, i32 2
  store ptr %28, ptr %30, align 8, !tbaa !16
  %31 = load double, ptr %8, align 8, !tbaa !9
  %32 = fmul double %31, 4.000000e+00
  %33 = fptoui double %32 to i64
  %34 = call noalias ptr @malloc(i64 noundef %33) #8
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.ProcessingUnitControllerProcessesStructure, ptr %35, i32 0, i32 3
  store ptr %34, ptr %36, align 8, !tbaa !17
  store i32 0, ptr %11, align 4, !tbaa !18
  br label %37

37:                                               ; preds = %75, %4
  %38 = load i32, ptr %11, align 4, !tbaa !18
  %39 = sitofp i32 %38 to double
  %40 = load double, ptr %8, align 8, !tbaa !9
  %41 = fcmp olt double %39, %40
  br i1 %41, label %42, label %78

42:                                               ; preds = %37
  %43 = call i32 @fork() #7
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.ProcessingUnitControllerProcessesStructure, ptr %44, i32 0, i32 2
  %46 = load ptr, ptr %45, align 8, !tbaa !16
  %47 = load i32, ptr %11, align 4, !tbaa !18
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds i32, ptr %46, i64 %48
  store i32 %43, ptr %49, align 4, !tbaa !18
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.ProcessingUnitControllerProcessesStructure, ptr %50, i32 0, i32 2
  %52 = load ptr, ptr %51, align 8, !tbaa !16
  %53 = load i32, ptr %11, align 4, !tbaa !18
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds i32, ptr %52, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !18
  %57 = icmp eq i32 %56, 0
  br i1 %57, label %58, label %66

58:                                               ; preds = %42
  call void @SetExceptionHandler(ptr noundef @ProgramException)
  store i8 0, ptr @wasException, align 1, !tbaa !20
  %59 = call i32 @raise(i32 noundef 19) #7
  %60 = call i32 @__sigsetjmp(ptr noundef @sigbuf, i32 noundef 1) #9
  store i32 %60, ptr %10, align 4, !tbaa !18
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = load i32, ptr %11, align 4, !tbaa !18
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds ptr, ptr %61, i64 %63
  %65 = load ptr, ptr %64, align 8, !tbaa !5
  call void (...) %65()
  call void @exit(i32 noundef 0) #10
  unreachable

66:                                               ; preds = %42
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.ProcessingUnitControllerProcessesStructure, ptr %67, i32 0, i32 2
  %69 = load ptr, ptr %68, align 8, !tbaa !16
  %70 = load i32, ptr %11, align 4, !tbaa !18
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds i32, ptr %69, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !18
  %74 = call i32 @waitpid(i32 noundef %73, ptr noundef null, i32 noundef 2)
  br label %75

75:                                               ; preds = %66
  %76 = load i32, ptr %11, align 4, !tbaa !18
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %11, align 4, !tbaa !18
  br label %37, !llvm.loop !22

78:                                               ; preds = %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  ret void
}

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

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

; Function Attrs: nounwind
declare i32 @fork() #3

; Function Attrs: nounwind uwtable
declare hidden void @SetExceptionHandler(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @ProgramException(i32 noundef) #0

; Function Attrs: nounwind
declare i32 @raise(i32 noundef) #3

; Function Attrs: nounwind returns_twice
declare i32 @__sigsetjmp(ptr noundef, i32 noundef) #4

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #5

declare i32 @waitpid(i32 noundef, ptr noundef, i32 noundef) #6

; 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 = { 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 #3 = { 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 returns_twice "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 = { noreturn 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 #6 = { "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 #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }
attributes #9 = { nounwind returns_twice }
attributes #10 = { noreturn 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, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"ProcessingUnitControllerStructure", !6, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"ProcessingUnitControllerProcessesStructure", !10, i64 0, !10, i64 8, !6, i64 16, !6, i64 24}
!15 = !{!14, !10, i64 8}
!16 = !{!14, !6, i64 16}
!17 = !{!14, !6, i64 24}
!18 = !{!19, !19, i64 0}
!19 = !{!"int", !7, i64 0}
!20 = !{!21, !21, i64 0}
!21 = !{!"_Bool", !7, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"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.__jmp_buf_tag = type { [8 x i64], i32, %struct.__sigset_t }
%struct.__sigset_t = type { [16 x i64] }

@wasException = external hidden local_unnamed_addr global i8, align 1
@sigbuf = external hidden global [1 x %struct.__jmp_buf_tag], align 16

; Function Attrs: nounwind uwtable
define dso_local void @CreateProcessingUnitControllerProcesses(ptr nocapture noundef writeonly %0, double noundef %1, ptr nocapture noundef readonly %2, double noundef %3) local_unnamed_addr #0 {
  %5 = call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #7
  store ptr %5, ptr %0, align 8, !tbaa !5
  %6 = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #7
  store ptr %6, ptr %5, align 8, !tbaa !9
  store double %1, ptr %6, align 8, !tbaa !11
  %7 = getelementptr inbounds i8, ptr %6, i64 8
  store double %3, ptr %7, align 8, !tbaa !14
  %8 = fmul double %1, 4.000000e+00
  %9 = fptoui double %8 to i64
  %10 = call noalias ptr @malloc(i64 noundef %9) #7
  %11 = getelementptr inbounds i8, ptr %6, i64 16
  store ptr %10, ptr %11, align 8, !tbaa !15
  %12 = fmul double %3, 4.000000e+00
  %13 = fptoui double %12 to i64
  %14 = call noalias ptr @malloc(i64 noundef %13) #7
  %15 = getelementptr inbounds i8, ptr %6, i64 24
  store ptr %14, ptr %15, align 8, !tbaa !16
  %16 = fcmp ogt double %3, 0.000000e+00
  br i1 %16, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %4, %26
  %indvars.iv = phi i64 [ %indvars.iv.next, %26 ], [ 0, %4 ]
  %17 = call i32 @fork() #8
  %18 = load ptr, ptr %11, align 8, !tbaa !15
  %19 = getelementptr inbounds i32, ptr %18, i64 %indvars.iv
  store i32 %17, ptr %19, align 4, !tbaa !17
  %20 = icmp eq i32 %17, 0
  br i1 %20, label %21, label %26

21:                                               ; preds = %.lr.ph
  call void @SetExceptionHandler(ptr noundef nonnull @ProgramException)
  store i8 0, ptr @wasException, align 1, !tbaa !19
  %22 = call i32 @raise(i32 noundef 19) #8
  %23 = call i32 @__sigsetjmp(ptr noundef nonnull @sigbuf, i32 noundef 1) #9
  %24 = getelementptr inbounds ptr, ptr %2, i64 %indvars.iv
  %25 = load ptr, ptr %24, align 8, !tbaa !5
  call void (...) %25() #8
  call void @exit(i32 noundef 0) #10
  unreachable

26:                                               ; preds = %.lr.ph
  %27 = call i32 @waitpid(i32 noundef %17, ptr noundef null, i32 noundef 2) #8
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %28 = trunc nuw i64 %indvars.iv.next to i32
  %29 = uitofp nneg i32 %28 to double
  %30 = fcmp olt double %29, %3
  br i1 %30, label %.lr.ph, label %._crit_edge, !llvm.loop !21

._crit_edge:                                      ; preds = %26, %4
  ret void
}

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

; Function Attrs: nofree nounwind
declare i32 @fork() local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @SetExceptionHandler(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @ProgramException(i32 noundef) #0

; Function Attrs: nounwind
declare i32 @raise(i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind returns_twice
declare i32 @__sigsetjmp(ptr noundef, i32 noundef) local_unnamed_addr #4

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #5

declare i32 @waitpid(i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #6

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 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 #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 "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 returns_twice "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 = { noreturn 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 #6 = { "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 #7 = { nounwind allocsize(0) }
attributes #8 = { nounwind }
attributes #9 = { nounwind returns_twice }
attributes #10 = { noreturn 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 0}
!10 = !{!"ProcessingUnitControllerStructure", !6, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"ProcessingUnitControllerProcessesStructure", !13, i64 0, !13, i64 8, !6, i64 16, !6, i64 24}
!13 = !{!"double", !7, i64 0}
!14 = !{!12, !13, i64 8}
!15 = !{!12, !6, i64 16}
!16 = !{!12, !6, i64 24}
!17 = !{!18, !18, i64 0}
!18 = !{!"int", !7, i64 0}
!19 = !{!20, !20, i64 0}
!20 = !{!"_Bool", !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass