; LLVM IR from TobiasKozel/VAE :: external/portaudio/qa (paqa_latency)

; 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.paTestData = type { [200 x float], i32, i32, [20 x i8], i32, i32, i32, double, double, %struct.PaStreamCallbackTimeInfo }
%struct.PaStreamCallbackTimeInfo = type { double, double, double }
%struct.PaStreamParameters = type { i32, i32, i64, double, ptr }
%struct.PaStreamInfo = type { i32, double, double, double }

@.str = external hidden unnamed_addr constant [47 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [39 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @paqaCheckLatency(ptr noundef %0, ptr noundef %1, double noundef %2, i64 noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca double, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store double %2, ptr %8, align 8, !tbaa !9
  store i64 %3, ptr %9, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.paTestData, ptr %14, i32 0, i32 4
  store i32 9999999, ptr %15, align 4, !tbaa !13
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.paTestData, ptr %16, i32 0, i32 5
  store i32 0, ptr %17, align 8, !tbaa !17
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.paTestData, ptr %18, i32 0, i32 7
  store double 0x416312CFE0000000, ptr %19, align 8, !tbaa !18
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.paTestData, ptr %20, i32 0, i32 8
  store double 0.000000e+00, ptr %21, align 8, !tbaa !19
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.paTestData, ptr %22, i32 0, i32 6
  store i32 0, ptr %23, align 4, !tbaa !20
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.PaStreamParameters, ptr %24, i32 0, i32 3
  %26 = load double, ptr %25, align 8, !tbaa !21
  %27 = call i32 (ptr, ...) @printf(ptr noundef @.str, double noundef %26)
  %28 = load i64, ptr %9, align 8, !tbaa !11
  %29 = icmp eq i64 %28, 0
  br i1 %29, label %30, label %32

30:                                               ; preds = %4
  %31 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %35

32:                                               ; preds = %4
  %33 = load i64, ptr %9, align 8, !tbaa !11
  %34 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %33)
  br label %35

35:                                               ; preds = %32, %30
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = load double, ptr %8, align 8, !tbaa !9
  %38 = load i64, ptr %9, align 8, !tbaa !11
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = call i32 @Pa_OpenStream(ptr noundef %11, ptr noundef null, ptr noundef %36, double noundef %37, i64 noundef %38, i64 noundef 1, ptr noundef @patestCallback, ptr noundef %39)
  store i32 %40, ptr %10, align 4, !tbaa !23
  %41 = load i32, ptr %10, align 4, !tbaa !23
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %44

43:                                               ; preds = %35
  br label %91

44:                                               ; preds = %35
  %45 = load ptr, ptr %11, align 8, !tbaa !5
  %46 = call ptr @Pa_GetStreamInfo(ptr noundef %45)
  store ptr %46, ptr %12, align 8, !tbaa !5
  %47 = load ptr, ptr %12, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.PaStreamInfo, ptr %47, i32 0, i32 1
  %49 = load double, ptr %48, align 8, !tbaa !24
  %50 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, double noundef %49)
  %51 = load ptr, ptr %12, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.PaStreamInfo, ptr %51, i32 0, i32 2
  %53 = load double, ptr %52, align 8, !tbaa !26
  %54 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, double noundef %53)
  %55 = load ptr, ptr %11, align 8, !tbaa !5
  %56 = call i32 @Pa_StartStream(ptr noundef %55)
  store i32 %56, ptr %10, align 4, !tbaa !23
  %57 = load i32, ptr %10, align 4, !tbaa !23
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %60

59:                                               ; preds = %44
  br label %88

60:                                               ; preds = %44
  %61 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i32 noundef 5)
  call void @Pa_Sleep(i64 noundef 5000)
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.paTestData, ptr %62, i32 0, i32 4
  %64 = load i32, ptr %63, align 4, !tbaa !13
  %65 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, i32 noundef %64)
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.paTestData, ptr %66, i32 0, i32 5
  %68 = load i32, ptr %67, align 8, !tbaa !17
  %69 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i32 noundef %68)
  %70 = load ptr, ptr %7, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.paTestData, ptr %70, i32 0, i32 7
  %72 = load double, ptr %71, align 8, !tbaa !18
  %73 = call i32 (ptr, ...) @printf(ptr noundef @.str.8, double noundef %72)
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.paTestData, ptr %74, i32 0, i32 8
  %76 = load double, ptr %75, align 8, !tbaa !19
  %77 = call i32 (ptr, ...) @printf(ptr noundef @.str.9, double noundef %76)
  %78 = load ptr, ptr %11, align 8, !tbaa !5
  %79 = call i32 @Pa_StopStream(ptr noundef %78)
  store i32 %79, ptr %10, align 4, !tbaa !23
  %80 = load i32, ptr %10, align 4, !tbaa !23
  %81 = icmp ne i32 %80, 0
  br i1 %81, label %82, label %83

82:                                               ; preds = %60
  br label %88

83:                                               ; preds = %60
  %84 = load ptr, ptr %11, align 8, !tbaa !5
  %85 = call i32 @Pa_CloseStream(ptr noundef %84)
  store i32 %85, ptr %10, align 4, !tbaa !23
  call void @Pa_Sleep(i64 noundef 1000)
  %86 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  %87 = load i32, ptr %10, align 4, !tbaa !23
  store i32 %87, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %94

88:                                               ; preds = %82, %59
  %89 = load ptr, ptr %11, align 8, !tbaa !5
  %90 = call i32 @Pa_CloseStream(ptr noundef %89)
  br label %91

91:                                               ; preds = %88, %43
  %92 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  %93 = load i32, ptr %10, align 4, !tbaa !23
  store i32 %93, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %94

94:                                               ; preds = %91, %83
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %95 = load i32, ptr %5, align 4
  ret i32 %95
}

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

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

declare i32 @Pa_OpenStream(ptr noundef, ptr noundef, ptr noundef, double noundef, i64 noundef, i64 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @patestCallback(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef) #0

declare ptr @Pa_GetStreamInfo(ptr noundef) #2

declare i32 @Pa_StartStream(ptr noundef) #2

declare void @Pa_Sleep(i64 noundef) #2

declare i32 @Pa_StopStream(ptr noundef) #2

declare i32 @Pa_CloseStream(ptr noundef) #2

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

!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, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !15, i64 828}
!14 = !{!"", !7, i64 0, !15, i64 800, !15, i64 804, !7, i64 808, !15, i64 828, !15, i64 832, !15, i64 836, !10, i64 840, !10, i64 848, !16, i64 856}
!15 = !{!"int", !7, i64 0}
!16 = !{!"PaStreamCallbackTimeInfo", !10, i64 0, !10, i64 8, !10, i64 16}
!17 = !{!14, !15, i64 832}
!18 = !{!14, !10, i64 840}
!19 = !{!14, !10, i64 848}
!20 = !{!14, !15, i64 836}
!21 = !{!22, !10, i64 16}
!22 = !{!"PaStreamParameters", !15, i64 0, !15, i64 4, !12, i64 8, !10, i64 16, !6, i64 24}
!23 = !{!15, !15, i64 0}
!24 = !{!25, !10, i64 8}
!25 = !{!"PaStreamInfo", !15, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!26 = !{!25, !10, i64 16}


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

@.str = external hidden unnamed_addr constant [47 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [39 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @paqaCheckLatency(ptr noundef %0, ptr noundef %1, double noundef %2, i64 noundef %3) local_unnamed_addr #0 {
  %5 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  %6 = getelementptr inbounds i8, ptr %1, i64 828
  store i32 9999999, ptr %6, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %1, i64 832
  store i32 0, ptr %7, align 8, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %1, i64 840
  %9 = getelementptr inbounds i8, ptr %1, i64 848
  store <2 x double> <double 0x416312CFE0000000, double 0.000000e+00>, ptr %8, align 8, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %1, i64 836
  store i32 0, ptr %10, align 4, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  %12 = load double, ptr %11, align 8, !tbaa !15
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %12)
  %14 = icmp eq i64 %3, 0
  br i1 %14, label %15, label %17

15:                                               ; preds = %4
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %19

17:                                               ; preds = %4
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %3)
  br label %19

19:                                               ; preds = %17, %15
  %20 = call i32 @Pa_OpenStream(ptr noundef nonnull %5, ptr noundef null, ptr noundef nonnull %0, double noundef %2, i64 noundef %3, i64 noundef 1, ptr noundef nonnull @patestCallback, ptr noundef nonnull %1) #4
  %.not = icmp eq i32 %20, 0
  br i1 %.not, label %21, label %50

21:                                               ; preds = %19
  %22 = load ptr, ptr %5, align 8, !tbaa !19
  %23 = call ptr @Pa_GetStreamInfo(ptr noundef %22) #4
  %24 = getelementptr inbounds i8, ptr %23, i64 8
  %25 = load double, ptr %24, align 8, !tbaa !20
  %26 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, double noundef %25)
  %27 = getelementptr inbounds i8, ptr %23, i64 16
  %28 = load double, ptr %27, align 8, !tbaa !22
  %29 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, double noundef %28)
  %30 = load ptr, ptr %5, align 8, !tbaa !19
  %31 = call i32 @Pa_StartStream(ptr noundef %30) #4
  %.not28 = icmp eq i32 %31, 0
  br i1 %.not28, label %32, label %47

32:                                               ; preds = %21
  %33 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef 5)
  call void @Pa_Sleep(i64 noundef 5000) #4
  %34 = load i32, ptr %6, align 4, !tbaa !5
  %35 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, i32 noundef %34)
  %36 = load i32, ptr %7, align 8, !tbaa !12
  %37 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, i32 noundef %36)
  %38 = load double, ptr %8, align 8, !tbaa !23
  %39 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8, double noundef %38)
  %40 = load double, ptr %9, align 8, !tbaa !24
  %41 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, double noundef %40)
  %42 = load ptr, ptr %5, align 8, !tbaa !19
  %43 = call i32 @Pa_StopStream(ptr noundef %42) #4
  %.not29 = icmp eq i32 %43, 0
  br i1 %.not29, label %44, label %47

44:                                               ; preds = %32
  %45 = load ptr, ptr %5, align 8, !tbaa !19
  %46 = call i32 @Pa_CloseStream(ptr noundef %45) #4
  call void @Pa_Sleep(i64 noundef 1000) #4
  br label %50

47:                                               ; preds = %32, %21
  %.023 = phi i32 [ %31, %21 ], [ %43, %32 ]
  %48 = load ptr, ptr %5, align 8, !tbaa !19
  %49 = call i32 @Pa_CloseStream(ptr noundef %48) #4
  br label %50

50:                                               ; preds = %47, %19, %44
  %.0 = phi i32 [ %46, %44 ], [ %20, %19 ], [ %.023, %47 ]
  %51 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  ret i32 %.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 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

declare i32 @Pa_OpenStream(ptr noundef, ptr noundef, ptr noundef, double noundef, i64 noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden i32 @patestCallback(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef) #0

declare ptr @Pa_GetStreamInfo(ptr noundef) local_unnamed_addr #3

declare i32 @Pa_StartStream(ptr noundef) local_unnamed_addr #3

declare void @Pa_Sleep(i64 noundef) local_unnamed_addr #3

declare i32 @Pa_StopStream(ptr noundef) local_unnamed_addr #3

declare i32 @Pa_CloseStream(ptr noundef) local_unnamed_addr #3

; 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 = { 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 = { "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 }

!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, !9, i64 828}
!6 = !{!"", !7, i64 0, !9, i64 800, !9, i64 804, !7, i64 808, !9, i64 828, !9, i64 832, !9, i64 836, !10, i64 840, !10, i64 848, !11, i64 856}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!"PaStreamCallbackTimeInfo", !10, i64 0, !10, i64 8, !10, i64 16}
!12 = !{!6, !9, i64 832}
!13 = !{!10, !10, i64 0}
!14 = !{!6, !9, i64 836}
!15 = !{!16, !10, i64 16}
!16 = !{!"PaStreamParameters", !9, i64 0, !9, i64 4, !17, i64 8, !10, i64 16, !18, i64 24}
!17 = !{!"long", !7, i64 0}
!18 = !{!"any pointer", !7, i64 0}
!19 = !{!18, !18, i64 0}
!20 = !{!21, !10, i64 8}
!21 = !{!"PaStreamInfo", !9, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!22 = !{!21, !10, i64 16}
!23 = !{!6, !10, i64 840}
!24 = !{!6, !10, i64 848}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass