; LLVM IR from golems/ach :: src (ach-bench)

; 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.timespec = type { i64, i64 }

@stderr = external global ptr, align 8
@.str.8 = external hidden unnamed_addr constant [10 x i8], align 1
@fd = external dso_local global [2 x i32], align 4

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

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

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

; Function Attrs: nounwind uwtable
declare hidden { i64, i64 } @get_ticks() #0

; Function Attrs: nounwind uwtable
declare hidden double @ticks_delta(i64, i64, i64, i64) #0

; Function Attrs: noreturn nounwind
declare void @abort() #3

; Function Attrs: nounwind uwtable
declare hidden void @send_time(float noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @receiver_pipe(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca i64, align 8
  %4 = alloca %struct.timespec, align 8
  %5 = alloca i64, align 8
  %6 = alloca %struct.timespec, align 8
  %7 = alloca i64, align 8
  %8 = alloca %struct.timespec, align 8
  store i32 %0, ptr %2, align 4, !tbaa !5
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = load ptr, ptr @stderr, align 8, !tbaa !9
  %11 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef @.str.8) #5
  call void @make_realtime(i32 noundef 99)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  store i64 0, ptr %3, align 8, !tbaa !11
  br label %12

12:                                               ; preds = %22, %1
  %13 = load i64, ptr %3, align 8, !tbaa !11
  %14 = icmp ult i64 %13, 5
  br i1 %14, label %15, label %25

15:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 16, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %16 = load i32, ptr @fd, align 4, !tbaa !5
  %17 = call i64 @read(i32 noundef %16, ptr noundef %4, i64 noundef 16)
  store i64 %17, ptr %5, align 8, !tbaa !11
  %18 = load i64, ptr %5, align 8, !tbaa !11
  %19 = icmp ne i64 16, %18
  br i1 %19, label %20, label %21

20:                                               ; preds = %15
  call void @abort() #6
  unreachable

21:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %4) #5
  br label %22

22:                                               ; preds = %21
  %23 = load i64, ptr %3, align 8, !tbaa !11
  %24 = add i64 %23, 1
  store i64 %24, ptr %3, align 8, !tbaa !11
  br label %12, !llvm.loop !13

25:                                               ; preds = %12
  br label %26

26:                                               ; preds = %38, %25
  br label %27

27:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %28 = load i32, ptr @fd, align 4, !tbaa !5
  %29 = call i64 @read(i32 noundef %28, ptr noundef %6, i64 noundef 16)
  store i64 %29, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #5
  %30 = call { i64, i64 } @get_ticks()
  %31 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 0
  %32 = extractvalue { i64, i64 } %30, 0
  store i64 %32, ptr %31, align 8
  %33 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 1
  %34 = extractvalue { i64, i64 } %30, 1
  store i64 %34, ptr %33, align 8
  %35 = load i64, ptr %7, align 8, !tbaa !11
  %36 = icmp ne i64 16, %35
  br i1 %36, label %37, label %38

37:                                               ; preds = %27
  call void @abort() #6
  unreachable

38:                                               ; preds = %27
  %39 = getelementptr inbounds { i64, i64 }, ptr %6, i32 0, i32 0
  %40 = load i64, ptr %39, align 8
  %41 = getelementptr inbounds { i64, i64 }, ptr %6, i32 0, i32 1
  %42 = load i64, ptr %41, align 8
  %43 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 0
  %44 = load i64, ptr %43, align 8
  %45 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 1
  %46 = load i64, ptr %45, align 8
  %47 = call double @ticks_delta(i64 %40, i64 %42, i64 %44, i64 %46)
  %48 = fptrunc double %47 to float
  call void @send_time(float noundef %48)
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #5
  br label %26
}

declare i64 @read(i32 noundef, ptr noundef, i64 noundef) #4

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 "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 = { 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 #4 = { "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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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.timespec = type { i64, i64 }

@stderr = external local_unnamed_addr global ptr, align 8
@.str.8 = external hidden unnamed_addr constant [10 x i8], align 1
@fd = external dso_local local_unnamed_addr global [2 x i32], align 4

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) 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) #1

; Function Attrs: nounwind uwtable
declare hidden { i64, i64 } @get_ticks() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden double @ticks_delta(i64, i64, i64, i64) local_unnamed_addr #0

; Function Attrs: noreturn nounwind
declare void @abort() local_unnamed_addr #3

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

; Function Attrs: noreturn nounwind uwtable
define dso_local void @receiver_pipe(i32 noundef %0) local_unnamed_addr #4 {
  %2 = alloca %struct.timespec, align 8
  %3 = alloca %struct.timespec, align 8
  %4 = load ptr, ptr @stderr, align 8, !tbaa !5
  %5 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %4, ptr noundef nonnull @.str.8) #6
  tail call void @make_realtime(i32 noundef 99)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #7
  %6 = load i32, ptr @fd, align 4, !tbaa !9
  %7 = call i64 @read(i32 noundef %6, ptr noundef nonnull %2, i64 noundef 16) #7
  %.not5 = icmp eq i64 %7, 16
  br i1 %.not5, label %10, label %9

.lr.ph:                                           ; preds = %.preheader
  %8 = getelementptr inbounds i8, ptr %3, i64 8
  br label %25

9:                                                ; preds = %19, %16, %13, %10, %1
  tail call void @abort() #8
  unreachable

10:                                               ; preds = %1
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #7
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #7
  %11 = load i32, ptr @fd, align 4, !tbaa !9
  %12 = call i64 @read(i32 noundef %11, ptr noundef nonnull %2, i64 noundef 16) #7
  %.not5.1 = icmp eq i64 %12, 16
  br i1 %.not5.1, label %13, label %9

13:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #7
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #7
  %14 = load i32, ptr @fd, align 4, !tbaa !9
  %15 = call i64 @read(i32 noundef %14, ptr noundef nonnull %2, i64 noundef 16) #7
  %.not5.2 = icmp eq i64 %15, 16
  br i1 %.not5.2, label %16, label %9

16:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #7
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #7
  %17 = load i32, ptr @fd, align 4, !tbaa !9
  %18 = call i64 @read(i32 noundef %17, ptr noundef nonnull %2, i64 noundef 16) #7
  %.not5.3 = icmp eq i64 %18, 16
  br i1 %.not5.3, label %19, label %9

19:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #7
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #7
  %20 = load i32, ptr @fd, align 4, !tbaa !9
  %21 = call i64 @read(i32 noundef %20, ptr noundef nonnull %2, i64 noundef 16) #7
  %.not5.4 = icmp eq i64 %21, 16
  br i1 %.not5.4, label %.preheader, label %9

.preheader:                                       ; preds = %19
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #7
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #7
  %22 = load i32, ptr @fd, align 4, !tbaa !9
  %23 = call i64 @read(i32 noundef %22, ptr noundef nonnull %3, i64 noundef 16) #7
  %24 = tail call { i64, i64 } @get_ticks()
  %.not7 = icmp eq i64 %23, 16
  br i1 %.not7, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %25, %.preheader
  tail call void @abort() #8
  unreachable

25:                                               ; preds = %.lr.ph, %25
  %26 = phi { i64, i64 } [ %24, %.lr.ph ], [ %35, %25 ]
  %27 = extractvalue { i64, i64 } %26, 1
  %28 = extractvalue { i64, i64 } %26, 0
  %29 = load i64, ptr %3, align 8
  %30 = load i64, ptr %8, align 8
  %31 = tail call double @ticks_delta(i64 %29, i64 %30, i64 %28, i64 %27)
  %32 = fptrunc double %31 to float
  tail call void @send_time(float noundef %32)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #7
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #7
  %33 = load i32, ptr @fd, align 4, !tbaa !9
  %34 = call i64 @read(i32 noundef %33, ptr noundef nonnull %3, i64 noundef 16) #7
  %35 = tail call { i64, i64 } @get_ticks()
  %.not = icmp eq i64 %34, 16
  br i1 %.not, label %25, label %._crit_edge
}

; Function Attrs: nofree
declare noundef i64 @read(i32 noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #5

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 = { 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 = { 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 #4 = { noreturn 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 = { 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 #6 = { cold nounwind }
attributes #7 = { nounwind }
attributes #8 = { 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 = !{!"int", !7, i64 0}


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