; LLVM IR from TobiasKozel/VAE :: external/portaudio/src/common (pa_front)

; 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.PaStreamParameters = type { i32, i32, i64, double, ptr }
%struct.PaUtilHostApiRepresentation = type { %struct.PaUtilPrivatePaFrontHostApiInfo, %struct.PaHostApiInfo, ptr, ptr, ptr, ptr }
%struct.PaUtilPrivatePaFrontHostApiInfo = type { i64 }
%struct.PaHostApiInfo = type { i32, i32, ptr, i32, i32, i32 }

@initializationCount_ = external hidden global i32, align 4

; 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
declare hidden i32 @ValidateOpenStreamParameters(ptr noundef, ptr noundef, double noundef, i64 noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @Pa_OpenStream(ptr noundef %0, ptr noundef %1, ptr noundef %2, double noundef %3, i64 noundef %4, i64 noundef %5, ptr noundef %6, ptr noundef %7) #1 {
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca double, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca %struct.PaStreamParameters, align 8
  %23 = alloca %struct.PaStreamParameters, align 8
  %24 = alloca ptr, align 8
  %25 = alloca ptr, align 8
  %26 = alloca i32, align 4
  store ptr %0, ptr %10, align 8, !tbaa !5
  store ptr %1, ptr %11, align 8, !tbaa !5
  store ptr %2, ptr %12, align 8, !tbaa !5
  store double %3, ptr %13, align 8, !tbaa !9
  store i64 %4, ptr %14, align 8, !tbaa !11
  store i64 %5, ptr %15, align 8, !tbaa !11
  store ptr %6, ptr %16, align 8, !tbaa !5
  store ptr %7, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #2
  store ptr null, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #2
  store i32 -1, ptr %20, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #2
  store i32 -1, ptr %21, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 32, ptr %22) #2
  call void @llvm.lifetime.start.p0(i64 32, ptr %23) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #2
  %27 = load i32, ptr @initializationCount_, align 4, !tbaa !13
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %31, label %29

29:                                               ; preds = %8
  store i32 -10000, ptr %18, align 4, !tbaa !13
  %30 = load i32, ptr %18, align 4, !tbaa !13
  store i32 %30, ptr %9, align 4
  store i32 1, ptr %26, align 4
  br label %115

31:                                               ; preds = %8
  %32 = load ptr, ptr %10, align 8, !tbaa !5
  %33 = icmp eq ptr %32, null
  br i1 %33, label %34, label %36

34:                                               ; preds = %31
  store i32 -9988, ptr %18, align 4, !tbaa !13
  %35 = load i32, ptr %18, align 4, !tbaa !13
  store i32 %35, ptr %9, align 4
  store i32 1, ptr %26, align 4
  br label %115

36:                                               ; preds = %31
  %37 = load ptr, ptr %11, align 8, !tbaa !5
  %38 = load ptr, ptr %12, align 8, !tbaa !5
  %39 = load double, ptr %13, align 8, !tbaa !9
  %40 = load i64, ptr %14, align 8, !tbaa !11
  %41 = load i64, ptr %15, align 8, !tbaa !11
  %42 = load ptr, ptr %16, align 8, !tbaa !5
  %43 = call i32 @ValidateOpenStreamParameters(ptr noundef %37, ptr noundef %38, double noundef %39, i64 noundef %40, i64 noundef %41, ptr noundef %42, ptr noundef %19, ptr noundef %20, ptr noundef %21)
  store i32 %43, ptr %18, align 4, !tbaa !13
  %44 = load i32, ptr %18, align 4, !tbaa !13
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %46, label %48

46:                                               ; preds = %36
  %47 = load i32, ptr %18, align 4, !tbaa !13
  store i32 %47, ptr %9, align 4
  store i32 1, ptr %26, align 4
  br label %115

48:                                               ; preds = %36
  %49 = load ptr, ptr %11, align 8, !tbaa !5
  %50 = icmp ne ptr %49, null
  br i1 %50, label %51, label %70

51:                                               ; preds = %48
  %52 = load i32, ptr %20, align 4, !tbaa !13
  %53 = getelementptr inbounds %struct.PaStreamParameters, ptr %22, i32 0, i32 0
  store i32 %52, ptr %53, align 8, !tbaa !15
  %54 = load ptr, ptr %11, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.PaStreamParameters, ptr %54, i32 0, i32 1
  %56 = load i32, ptr %55, align 4, !tbaa !17
  %57 = getelementptr inbounds %struct.PaStreamParameters, ptr %22, i32 0, i32 1
  store i32 %56, ptr %57, align 4, !tbaa !17
  %58 = load ptr, ptr %11, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.PaStreamParameters, ptr %58, i32 0, i32 2
  %60 = load i64, ptr %59, align 8, !tbaa !18
  %61 = getelementptr inbounds %struct.PaStreamParameters, ptr %22, i32 0, i32 2
  store i64 %60, ptr %61, align 8, !tbaa !18
  %62 = load ptr, ptr %11, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.PaStreamParameters, ptr %62, i32 0, i32 3
  %64 = load double, ptr %63, align 8, !tbaa !19
  %65 = getelementptr inbounds %struct.PaStreamParameters, ptr %22, i32 0, i32 3
  store double %64, ptr %65, align 8, !tbaa !19
  %66 = load ptr, ptr %11, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.PaStreamParameters, ptr %66, i32 0, i32 4
  %68 = load ptr, ptr %67, align 8, !tbaa !20
  %69 = getelementptr inbounds %struct.PaStreamParameters, ptr %22, i32 0, i32 4
  store ptr %68, ptr %69, align 8, !tbaa !20
  store ptr %22, ptr %24, align 8, !tbaa !5
  br label %71

70:                                               ; preds = %48
  store ptr null, ptr %24, align 8, !tbaa !5
  br label %71

71:                                               ; preds = %70, %51
  %72 = load ptr, ptr %12, align 8, !tbaa !5
  %73 = icmp ne ptr %72, null
  br i1 %73, label %74, label %93

74:                                               ; preds = %71
  %75 = load i32, ptr %21, align 4, !tbaa !13
  %76 = getelementptr inbounds %struct.PaStreamParameters, ptr %23, i32 0, i32 0
  store i32 %75, ptr %76, align 8, !tbaa !15
  %77 = load ptr, ptr %12, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.PaStreamParameters, ptr %77, i32 0, i32 1
  %79 = load i32, ptr %78, align 4, !tbaa !17
  %80 = getelementptr inbounds %struct.PaStreamParameters, ptr %23, i32 0, i32 1
  store i32 %79, ptr %80, align 4, !tbaa !17
  %81 = load ptr, ptr %12, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.PaStreamParameters, ptr %81, i32 0, i32 2
  %83 = load i64, ptr %82, align 8, !tbaa !18
  %84 = getelementptr inbounds %struct.PaStreamParameters, ptr %23, i32 0, i32 2
  store i64 %83, ptr %84, align 8, !tbaa !18
  %85 = load ptr, ptr %12, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.PaStreamParameters, ptr %85, i32 0, i32 3
  %87 = load double, ptr %86, align 8, !tbaa !19
  %88 = getelementptr inbounds %struct.PaStreamParameters, ptr %23, i32 0, i32 3
  store double %87, ptr %88, align 8, !tbaa !19
  %89 = load ptr, ptr %12, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.PaStreamParameters, ptr %89, i32 0, i32 4
  %91 = load ptr, ptr %90, align 8, !tbaa !20
  %92 = getelementptr inbounds %struct.PaStreamParameters, ptr %23, i32 0, i32 4
  store ptr %91, ptr %92, align 8, !tbaa !20
  store ptr %23, ptr %25, align 8, !tbaa !5
  br label %94

93:                                               ; preds = %71
  store ptr null, ptr %25, align 8, !tbaa !5
  br label %94

94:                                               ; preds = %93, %74
  %95 = load ptr, ptr %19, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.PaUtilHostApiRepresentation, ptr %95, i32 0, i32 4
  %97 = load ptr, ptr %96, align 8, !tbaa !21
  %98 = load ptr, ptr %19, align 8, !tbaa !5
  %99 = load ptr, ptr %10, align 8, !tbaa !5
  %100 = load ptr, ptr %24, align 8, !tbaa !5
  %101 = load ptr, ptr %25, align 8, !tbaa !5
  %102 = load double, ptr %13, align 8, !tbaa !9
  %103 = load i64, ptr %14, align 8, !tbaa !11
  %104 = load i64, ptr %15, align 8, !tbaa !11
  %105 = load ptr, ptr %16, align 8, !tbaa !5
  %106 = load ptr, ptr %17, align 8, !tbaa !5
  %107 = call i32 %97(ptr noundef %98, ptr noundef %99, ptr noundef %100, ptr noundef %101, double noundef %102, i64 noundef %103, i64 noundef %104, ptr noundef %105, ptr noundef %106)
  store i32 %107, ptr %18, align 4, !tbaa !13
  %108 = load i32, ptr %18, align 4, !tbaa !13
  %109 = icmp eq i32 %108, 0
  br i1 %109, label %110, label %113

110:                                              ; preds = %94
  %111 = load ptr, ptr %10, align 8, !tbaa !5
  %112 = load ptr, ptr %111, align 8, !tbaa !5
  call void @AddOpenStream(ptr noundef %112)
  br label %113

113:                                              ; preds = %110, %94
  %114 = load i32, ptr %18, align 4, !tbaa !13
  store i32 %114, ptr %9, align 4
  store i32 1, ptr %26, align 4
  br label %115

115:                                              ; preds = %113, %46, %34, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #2
  call void @llvm.lifetime.end.p0(i64 32, ptr %23) #2
  call void @llvm.lifetime.end.p0(i64 32, ptr %22) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #2
  %116 = load i32, ptr %9, align 4
  ret i32 %116
}

; Function Attrs: nounwind uwtable
declare hidden void @AddOpenStream(ptr noundef) #1

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 = { 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, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !14, i64 0}
!16 = !{!"PaStreamParameters", !14, i64 0, !14, i64 4, !12, i64 8, !10, i64 16, !6, i64 24}
!17 = !{!16, !14, i64 4}
!18 = !{!16, !12, i64 8}
!19 = !{!16, !10, i64 16}
!20 = !{!16, !6, i64 24}
!21 = !{!22, !6, i64 56}
!22 = !{!"PaUtilHostApiRepresentation", !23, i64 0, !24, i64 8, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64}
!23 = !{!"PaUtilPrivatePaFrontHostApiInfo", !12, i64 0}
!24 = !{!"PaHostApiInfo", !14, i64 0, !14, i64 4, !6, i64 8, !14, i64 16, !14, i64 20, !14, i64 24}


; 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.PaStreamParameters = type { i32, i32, i64, double, ptr }

@initializationCount_ = external hidden local_unnamed_addr global i32, align 4

; 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: nounwind uwtable
declare hidden i32 @ValidateOpenStreamParameters(ptr noundef, ptr noundef, double noundef, i64 noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @Pa_OpenStream(ptr noundef %0, ptr noundef %1, ptr noundef %2, double noundef %3, i64 noundef %4, i64 noundef %5, ptr noundef %6, ptr noundef %7) local_unnamed_addr #1 {
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %struct.PaStreamParameters, align 8
  %13 = alloca %struct.PaStreamParameters, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #2
  store ptr null, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #2
  store i32 -1, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #2
  store i32 -1, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %12) #2
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %13) #2
  %14 = load i32, ptr @initializationCount_, align 4, !tbaa !9
  %.not = icmp eq i32 %14, 0
  br i1 %.not, label %57, label %15

15:                                               ; preds = %8
  %16 = icmp eq ptr %0, null
  br i1 %16, label %57, label %17

17:                                               ; preds = %15
  %18 = call i32 @ValidateOpenStreamParameters(ptr noundef %1, ptr noundef %2, double noundef %3, i64 noundef %4, i64 noundef %5, ptr noundef %6, ptr noundef nonnull %9, ptr noundef nonnull %10, ptr noundef nonnull %11)
  %.not38 = icmp eq i32 %18, 0
  br i1 %.not38, label %19, label %57

19:                                               ; preds = %17
  %.not39 = icmp eq ptr %1, null
  br i1 %.not39, label %34, label %20

20:                                               ; preds = %19
  %21 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %21, ptr %12, align 8, !tbaa !11
  %22 = getelementptr inbounds i8, ptr %1, i64 4
  %23 = load i32, ptr %22, align 4, !tbaa !15
  %24 = getelementptr inbounds i8, ptr %12, i64 4
  store i32 %23, ptr %24, align 4, !tbaa !15
  %25 = getelementptr inbounds i8, ptr %1, i64 8
  %26 = load i64, ptr %25, align 8, !tbaa !16
  %27 = getelementptr inbounds i8, ptr %12, i64 8
  store i64 %26, ptr %27, align 8, !tbaa !16
  %28 = getelementptr inbounds i8, ptr %1, i64 16
  %29 = load double, ptr %28, align 8, !tbaa !17
  %30 = getelementptr inbounds i8, ptr %12, i64 16
  store double %29, ptr %30, align 8, !tbaa !17
  %31 = getelementptr inbounds i8, ptr %1, i64 24
  %32 = load ptr, ptr %31, align 8, !tbaa !18
  %33 = getelementptr inbounds i8, ptr %12, i64 24
  store ptr %32, ptr %33, align 8, !tbaa !18
  br label %34

34:                                               ; preds = %19, %20
  %.032 = phi ptr [ %12, %20 ], [ null, %19 ]
  %.not40 = icmp eq ptr %2, null
  br i1 %.not40, label %49, label %35

35:                                               ; preds = %34
  %36 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %36, ptr %13, align 8, !tbaa !11
  %37 = getelementptr inbounds i8, ptr %2, i64 4
  %38 = load i32, ptr %37, align 4, !tbaa !15
  %39 = getelementptr inbounds i8, ptr %13, i64 4
  store i32 %38, ptr %39, align 4, !tbaa !15
  %40 = getelementptr inbounds i8, ptr %2, i64 8
  %41 = load i64, ptr %40, align 8, !tbaa !16
  %42 = getelementptr inbounds i8, ptr %13, i64 8
  store i64 %41, ptr %42, align 8, !tbaa !16
  %43 = getelementptr inbounds i8, ptr %2, i64 16
  %44 = load double, ptr %43, align 8, !tbaa !17
  %45 = getelementptr inbounds i8, ptr %13, i64 16
  store double %44, ptr %45, align 8, !tbaa !17
  %46 = getelementptr inbounds i8, ptr %2, i64 24
  %47 = load ptr, ptr %46, align 8, !tbaa !18
  %48 = getelementptr inbounds i8, ptr %13, i64 24
  store ptr %47, ptr %48, align 8, !tbaa !18
  br label %49

49:                                               ; preds = %34, %35
  %.0 = phi ptr [ %13, %35 ], [ null, %34 ]
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  %51 = getelementptr inbounds i8, ptr %50, i64 56
  %52 = load ptr, ptr %51, align 8, !tbaa !19
  %53 = call i32 %52(ptr noundef %50, ptr noundef nonnull %0, ptr noundef %.032, ptr noundef %.0, double noundef %3, i64 noundef %4, i64 noundef %5, ptr noundef %6, ptr noundef %7) #2
  %54 = icmp eq i32 %53, 0
  br i1 %54, label %55, label %57

55:                                               ; preds = %49
  %56 = load ptr, ptr %0, align 8, !tbaa !5
  call void @AddOpenStream(ptr noundef %56)
  br label %57

57:                                               ; preds = %49, %55, %17, %15, %8
  %.033 = phi i32 [ -10000, %8 ], [ -9988, %15 ], [ %18, %17 ], [ 0, %55 ], [ %53, %49 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %13) #2
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #2
  ret i32 %.033
}

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

attributes #0 = { mustprogress 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 = { 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}
!11 = !{!12, !10, i64 0}
!12 = !{!"PaStreamParameters", !10, i64 0, !10, i64 4, !13, i64 8, !14, i64 16, !6, i64 24}
!13 = !{!"long", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!12, !10, i64 4}
!16 = !{!12, !13, i64 8}
!17 = !{!12, !14, i64 16}
!18 = !{!12, !6, i64 24}
!19 = !{!20, !6, i64 56}
!20 = !{!"PaUtilHostApiRepresentation", !21, i64 0, !22, i64 8, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64}
!21 = !{!"PaUtilPrivatePaFrontHostApiInfo", !13, i64 0}
!22 = !{!"PaHostApiInfo", !10, i64 0, !10, i64 4, !6, i64 8, !10, i64 16, !10, i64 20, !10, i64 24}


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