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

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

@.str = external hidden unnamed_addr constant [20 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [22 x i8], align 1
@gNumPassed = external hidden global i32, align 4
@.str.2 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [32 x i8], align 1
@gNumFailed = external hidden global i32, align 4
@.str.5 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [34 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 1, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 1, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %14 = load ptr, ptr %5, align 8, !tbaa !9
  %15 = getelementptr inbounds ptr, ptr %14, i64 0
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  store ptr %16, ptr %11, align 8, !tbaa !9
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %55, %2
  %18 = load i32, ptr %6, align 4, !tbaa !5
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %21, label %56

21:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %22 = load ptr, ptr %5, align 8, !tbaa !9
  %23 = load i32, ptr %6, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds ptr, ptr %22, i64 %24
  %26 = load ptr, ptr %25, align 8, !tbaa !9
  store ptr %26, ptr %12, align 8, !tbaa !9
  %27 = load ptr, ptr %12, align 8, !tbaa !9
  %28 = getelementptr inbounds i8, ptr %27, i64 0
  %29 = load i8, ptr %28, align 1, !tbaa !11
  %30 = sext i8 %29 to i32
  %31 = icmp eq i32 %30, 45
  br i1 %31, label %32, label %46

32:                                               ; preds = %21
  %33 = load ptr, ptr %12, align 8, !tbaa !9
  %34 = getelementptr inbounds i8, ptr %33, i64 1
  %35 = load i8, ptr %34, align 1, !tbaa !11
  %36 = sext i8 %35 to i32
  switch i32 %36, label %40 [
    i32 97, label %37
    i32 105, label %38
    i32 111, label %39
    i32 63, label %43
  ]

37:                                               ; preds = %32
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %45

38:                                               ; preds = %32
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %45

39:                                               ; preds = %32
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %45

40:                                               ; preds = %32
  %41 = load ptr, ptr %12, align 8, !tbaa !9
  %42 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef %41)
  br label %43

43:                                               ; preds = %40, %32
  %44 = load ptr, ptr %11, align 8, !tbaa !9
  call void @usage(ptr noundef %44)
  call void @exit(i32 noundef 1) #5
  unreachable

45:                                               ; preds = %39, %38, %37
  br label %50

46:                                               ; preds = %21
  %47 = load ptr, ptr %12, align 8, !tbaa !9
  %48 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, ptr noundef %47)
  %49 = load ptr, ptr %11, align 8, !tbaa !9
  call void @usage(ptr noundef %49)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %53

50:                                               ; preds = %45
  %51 = load i32, ptr %6, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %6, align 4, !tbaa !5
  store i32 0, ptr %13, align 4
  br label %53

53:                                               ; preds = %50, %46
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  %54 = load i32, ptr %13, align 4
  switch i32 %54, label %110 [
    i32 0, label %55
  ]

55:                                               ; preds = %53
  br label %17, !llvm.loop !12

56:                                               ; preds = %17
  br label %57

57:                                               ; preds = %56
  %58 = load i32, ptr @gNumPassed, align 4, !tbaa !5
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr @gNumPassed, align 4, !tbaa !5
  br label %60

60:                                               ; preds = %57
  br label %61

61:                                               ; preds = %60
  br label %62

62:                                               ; preds = %61
  %63 = load i32, ptr @gNumPassed, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr @gNumPassed, align 4, !tbaa !5
  br label %65

65:                                               ; preds = %62
  br label %66

66:                                               ; preds = %65
  br label %67

67:                                               ; preds = %66
  %68 = call i32 @Pa_Initialize()
  store i32 %68, ptr %7, align 4, !tbaa !5
  %69 = icmp eq i32 %68, 0
  br i1 %69, label %70, label %73

70:                                               ; preds = %67
  %71 = load i32, ptr @gNumPassed, align 4, !tbaa !5
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr @gNumPassed, align 4, !tbaa !5
  br label %86

73:                                               ; preds = %67
  %74 = load i32, ptr %7, align 4, !tbaa !5
  %75 = load i32, ptr %7, align 4, !tbaa !5
  %76 = icmp eq i32 %75, 0
  br i1 %76, label %77, label %78

77:                                               ; preds = %73
  br label %81

78:                                               ; preds = %73
  %79 = load i32, ptr %7, align 4, !tbaa !5
  %80 = call ptr @Pa_GetErrorText(i32 noundef %79)
  br label %81

81:                                               ; preds = %78, %77
  %82 = phi ptr [ @.str.3, %77 ], [ %80, %78 ]
  %83 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %74, ptr noundef %82, ptr noundef @.str.4)
  %84 = load i32, ptr @gNumFailed, align 4, !tbaa !5
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr @gNumFailed, align 4, !tbaa !5
  br label %101

86:                                               ; preds = %70
  br label %87

87:                                               ; preds = %86
  br label %88

88:                                               ; preds = %87
  %89 = load i32, ptr %9, align 4, !tbaa !5
  %90 = icmp ne i32 %89, 0
  br i1 %90, label %91, label %94

91:                                               ; preds = %88
  %92 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  %93 = load i32, ptr %8, align 4, !tbaa !5
  call void @TestDevices(i32 noundef 1, i32 noundef %93)
  br label %94

94:                                               ; preds = %91, %88
  %95 = load i32, ptr %10, align 4, !tbaa !5
  %96 = icmp ne i32 %95, 0
  br i1 %96, label %97, label %100

97:                                               ; preds = %94
  %98 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  %99 = load i32, ptr %8, align 4, !tbaa !5
  call void @TestDevices(i32 noundef 0, i32 noundef %99)
  br label %100

100:                                              ; preds = %97, %94
  br label %101

101:                                              ; preds = %100, %81
  %102 = call i32 @Pa_Terminate()
  %103 = load i32, ptr @gNumPassed, align 4, !tbaa !5
  %104 = load i32, ptr @gNumFailed, align 4, !tbaa !5
  %105 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i32 noundef %103, i32 noundef %104)
  %106 = load i32, ptr @gNumFailed, align 4, !tbaa !5
  %107 = icmp sgt i32 %106, 0
  %108 = zext i1 %107 to i64
  %109 = select i1 %107, i32 1, i32 0
  store i32 %109, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %110

110:                                              ; preds = %101, %53
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %111 = load i32, ptr %3, align 4
  ret i32 %111
}

; 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

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

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

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

declare i32 @Pa_Initialize() #2

declare ptr @Pa_GetErrorText(i32 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @TestDevices(i32 noundef, i32 noundef) #0

declare i32 @Pa_Terminate() #2

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 = { 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 = { nounwind }
attributes #5 = { 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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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"

@.str = external hidden unnamed_addr constant [20 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [22 x i8], align 1
@gNumPassed = external hidden local_unnamed_addr global i32, align 4
@.str.2 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [32 x i8], align 1
@gNumFailed = external hidden local_unnamed_addr global i32, align 4
@.str.5 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [34 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = load ptr, ptr %1, align 8, !tbaa !5
  %4 = icmp sgt i32 %0, 1
  br i1 %4, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %2
  %wide.trip.count = zext nneg i32 %0 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %17
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next, %17 ]
  %.02352 = phi i32 [ 1, %.lr.ph.preheader ], [ %.124, %17 ]
  %.02651 = phi i32 [ 1, %.lr.ph.preheader ], [ %.127, %17 ]
  %.02950 = phi i32 [ 0, %.lr.ph.preheader ], [ %.130, %17 ]
  %5 = getelementptr inbounds ptr, ptr %1, i64 %indvars.iv
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = load i8, ptr %6, align 1, !tbaa !9
  %8 = icmp eq i8 %7, 45
  br i1 %8, label %9, label %.thread

9:                                                ; preds = %.lr.ph
  %10 = getelementptr inbounds i8, ptr %6, i64 1
  %11 = load i8, ptr %10, align 1, !tbaa !9
  switch i8 %11, label %14 [
    i8 97, label %17
    i8 105, label %12
    i8 111, label %13
    i8 63, label %.loopexit
  ]

12:                                               ; preds = %9
  br label %17

13:                                               ; preds = %9
  br label %17

14:                                               ; preds = %9
  %15 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef nonnull %6)
  br label %.loopexit

.loopexit:                                        ; preds = %9, %14
  tail call void @usage(ptr noundef %3)
  tail call void @exit(i32 noundef 1) #4
  unreachable

.thread:                                          ; preds = %.lr.ph
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, ptr noundef nonnull %6)
  tail call void @usage(ptr noundef %3)
  br label %45

17:                                               ; preds = %13, %12, %9
  %.130 = phi i32 [ %.02950, %13 ], [ %.02950, %12 ], [ 1, %9 ]
  %.127 = phi i32 [ %.02651, %13 ], [ 0, %12 ], [ %.02651, %9 ]
  %.124 = phi i32 [ 0, %13 ], [ %.02352, %12 ], [ %.02352, %9 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !10

._crit_edge.loopexit:                             ; preds = %17
  %18 = icmp eq i32 %.127, 0
  %19 = icmp eq i32 %.124, 0
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %2
  %.029.lcssa = phi i32 [ 0, %2 ], [ %.130, %._crit_edge.loopexit ]
  %.026.lcssa = phi i1 [ false, %2 ], [ %18, %._crit_edge.loopexit ]
  %.023.lcssa = phi i1 [ false, %2 ], [ %19, %._crit_edge.loopexit ]
  %20 = load i32, ptr @gNumPassed, align 4, !tbaa !12
  %21 = add nsw i32 %20, 2
  store i32 %21, ptr @gNumPassed, align 4, !tbaa !12
  %22 = tail call i32 @Pa_Initialize() #5
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %24, label %27

24:                                               ; preds = %._crit_edge
  %25 = load i32, ptr @gNumPassed, align 4, !tbaa !12
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr @gNumPassed, align 4, !tbaa !12
  br i1 %.026.lcssa, label %34, label %32

27:                                               ; preds = %._crit_edge
  %28 = tail call ptr @Pa_GetErrorText(i32 noundef %22) #5
  %29 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %22, ptr noundef %28, ptr noundef nonnull @.str.4)
  %30 = load i32, ptr @gNumFailed, align 4, !tbaa !12
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr @gNumFailed, align 4, !tbaa !12
  br label %37

32:                                               ; preds = %24
  %33 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  tail call void @TestDevices(i32 noundef 1, i32 noundef %.029.lcssa)
  br label %34

34:                                               ; preds = %32, %24
  br i1 %.023.lcssa, label %37, label %35

35:                                               ; preds = %34
  %36 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  tail call void @TestDevices(i32 noundef 0, i32 noundef %.029.lcssa)
  br label %37

37:                                               ; preds = %34, %35, %27
  %38 = tail call i32 @Pa_Terminate() #5
  %39 = load i32, ptr @gNumPassed, align 4, !tbaa !12
  %40 = load i32, ptr @gNumFailed, align 4, !tbaa !12
  %41 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, i32 noundef %39, i32 noundef %40)
  %42 = load i32, ptr @gNumFailed, align 4, !tbaa !12
  %43 = icmp sgt i32 %42, 0
  %44 = zext i1 %43 to i32
  br label %45

45:                                               ; preds = %.thread, %37
  %.2 = phi i32 [ %44, %37 ], [ 1, %.thread ]
  ret i32 %.2
}

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

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

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

declare i32 @Pa_Initialize() local_unnamed_addr #3

declare ptr @Pa_GetErrorText(i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden void @TestDevices(i32 noundef, i32 noundef) local_unnamed_addr #0

declare i32 @Pa_Terminate() local_unnamed_addr #3

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 = { 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 #2 = { 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 #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 = { noreturn nounwind }
attributes #5 = { 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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}


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