; LLVM IR from jordan4ibanez/tinyphysicsengine :: old (test)

; 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.TPE_Vec4 = type { i32, i32, i32, i32 }

@.str = external hidden unnamed_addr constant [66 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @TPE_vec4Set(ptr noundef, i32 noundef, i32 noundef, i32 noundef, 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare dso_local void @TPE_rotationToQuaternion(i64, i64, i32 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @tolerance(i32 noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @testRotToQuat(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6, i32 noundef %7) #0 {
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca %struct.TPE_Vec4, align 4
  %19 = alloca %struct.TPE_Vec4, align 4
  %20 = alloca i32, align 4
  store i32 %0, ptr %10, align 4, !tbaa !5
  store i32 %1, ptr %11, align 4, !tbaa !5
  store i32 %2, ptr %12, align 4, !tbaa !5
  store i32 %3, ptr %13, align 4, !tbaa !5
  store i32 %4, ptr %14, align 4, !tbaa !5
  store i32 %5, ptr %15, align 4, !tbaa !5
  store i32 %6, ptr %16, align 4, !tbaa !5
  store i32 %7, ptr %17, align 4, !tbaa !5
  %21 = load i32, ptr %10, align 4, !tbaa !5
  %22 = load i32, ptr %11, align 4, !tbaa !5
  %23 = load i32, ptr %12, align 4, !tbaa !5
  %24 = load i32, ptr %13, align 4, !tbaa !5
  %25 = load i32, ptr %14, align 4, !tbaa !5
  %26 = load i32, ptr %15, align 4, !tbaa !5
  %27 = load i32, ptr %16, align 4, !tbaa !5
  %28 = load i32, ptr %17, align 4, !tbaa !5
  %29 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %21, i32 noundef %22, i32 noundef %23, i32 noundef %24, i32 noundef %25, i32 noundef %26, i32 noundef %27, i32 noundef %28)
  call void @llvm.lifetime.start.p0(i64 16, ptr %18) #3
  call void @llvm.lifetime.start.p0(i64 16, ptr %19) #3
  %30 = load i32, ptr %10, align 4, !tbaa !5
  %31 = load i32, ptr %11, align 4, !tbaa !5
  %32 = load i32, ptr %12, align 4, !tbaa !5
  call void @TPE_vec4Set(ptr noundef %19, i32 noundef %30, i32 noundef %31, i32 noundef %32, i32 noundef 0)
  %33 = load i32, ptr %13, align 4, !tbaa !5
  %34 = getelementptr inbounds { i64, i64 }, ptr %19, i32 0, i32 0
  %35 = load i64, ptr %34, align 4
  %36 = getelementptr inbounds { i64, i64 }, ptr %19, i32 0, i32 1
  %37 = load i64, ptr %36, align 4
  call void @TPE_rotationToQuaternion(i64 %35, i64 %37, i32 noundef %33, ptr noundef %18)
  %38 = getelementptr inbounds %struct.TPE_Vec4, ptr %18, i32 0, i32 0
  %39 = load i32, ptr %38, align 4, !tbaa !9
  %40 = load i32, ptr %14, align 4, !tbaa !5
  %41 = call i32 @tolerance(i32 noundef %39, i32 noundef %40)
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %61

43:                                               ; preds = %8
  %44 = getelementptr inbounds %struct.TPE_Vec4, ptr %18, i32 0, i32 1
  %45 = load i32, ptr %44, align 4, !tbaa !11
  %46 = load i32, ptr %15, align 4, !tbaa !5
  %47 = call i32 @tolerance(i32 noundef %45, i32 noundef %46)
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %49, label %61

49:                                               ; preds = %43
  %50 = getelementptr inbounds %struct.TPE_Vec4, ptr %18, i32 0, i32 2
  %51 = load i32, ptr %50, align 4, !tbaa !12
  %52 = load i32, ptr %16, align 4, !tbaa !5
  %53 = call i32 @tolerance(i32 noundef %51, i32 noundef %52)
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %61

55:                                               ; preds = %49
  %56 = getelementptr inbounds %struct.TPE_Vec4, ptr %18, i32 0, i32 3
  %57 = load i32, ptr %56, align 4, !tbaa !13
  %58 = load i32, ptr %17, align 4, !tbaa !5
  %59 = call i32 @tolerance(i32 noundef %57, i32 noundef %58)
  %60 = icmp ne i32 %59, 0
  br i1 %60, label %71, label %61

61:                                               ; preds = %55, %49, %43, %8
  %62 = getelementptr inbounds %struct.TPE_Vec4, ptr %18, i32 0, i32 0
  %63 = load i32, ptr %62, align 4, !tbaa !9
  %64 = getelementptr inbounds %struct.TPE_Vec4, ptr %18, i32 0, i32 1
  %65 = load i32, ptr %64, align 4, !tbaa !11
  %66 = getelementptr inbounds %struct.TPE_Vec4, ptr %18, i32 0, i32 2
  %67 = load i32, ptr %66, align 4, !tbaa !12
  %68 = getelementptr inbounds %struct.TPE_Vec4, ptr %18, i32 0, i32 3
  %69 = load i32, ptr %68, align 4, !tbaa !13
  %70 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %63, i32 noundef %65, i32 noundef %67, i32 noundef %69)
  store i32 0, ptr %9, align 4
  store i32 1, ptr %20, align 4
  br label %73

71:                                               ; preds = %55
  %72 = call i32 @puts(ptr noundef @.str.2)
  store i32 1, ptr %9, align 4
  store i32 1, ptr %20, align 4
  br label %73

73:                                               ; preds = %71, %61
  call void @llvm.lifetime.end.p0(i64 16, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %18) #3
  %74 = load i32, ptr %9, align 4
  ret i32 %74
}

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

declare i32 @puts(ptr noundef) #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 = { 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, !6, i64 0}
!10 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!11 = !{!10, !6, i64 4}
!12 = !{!10, !6, i64 8}
!13 = !{!10, !6, i64 12}


; 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.TPE_Vec4 = type { i32, i32, i32, i32 }

@.str = external hidden unnamed_addr constant [66 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @TPE_vec4Set(ptr noundef, i32 noundef, i32 noundef, i32 noundef, 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: 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 dso_local void @TPE_rotationToQuaternion(i64, i64, i32 noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @testRotToQuat(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6, i32 noundef %7) local_unnamed_addr #0 {
  %9 = alloca %struct.TPE_Vec4, align 4
  %10 = alloca %struct.TPE_Vec4, align 8
  %11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6, i32 noundef %7)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %9) #3
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %10) #3
  call void @TPE_vec4Set(ptr noundef nonnull %10, i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef 0)
  %12 = load i64, ptr %10, align 8
  %13 = getelementptr inbounds i8, ptr %10, i64 8
  %14 = load i64, ptr %13, align 8
  call void @TPE_rotationToQuaternion(i64 %12, i64 %14, i32 noundef %3, ptr noundef nonnull %9)
  %15 = load i32, ptr %9, align 4, !tbaa !5
  %16 = call i32 @tolerance(i32 noundef %15, i32 noundef %4)
  %.not = icmp eq i32 %16, 0
  br i1 %.not, label %29, label %17

17:                                               ; preds = %8
  %18 = getelementptr inbounds i8, ptr %9, i64 4
  %19 = load i32, ptr %18, align 4, !tbaa !10
  %20 = call i32 @tolerance(i32 noundef %19, i32 noundef %5)
  %.not17 = icmp eq i32 %20, 0
  br i1 %.not17, label %29, label %21

21:                                               ; preds = %17
  %22 = getelementptr inbounds i8, ptr %9, i64 8
  %23 = load i32, ptr %22, align 4, !tbaa !11
  %24 = call i32 @tolerance(i32 noundef %23, i32 noundef %6)
  %.not18 = icmp eq i32 %24, 0
  br i1 %.not18, label %29, label %25

25:                                               ; preds = %21
  %26 = getelementptr inbounds i8, ptr %9, i64 12
  %27 = load i32, ptr %26, align 4, !tbaa !12
  %28 = call i32 @tolerance(i32 noundef %27, i32 noundef %7)
  %.not19 = icmp eq i32 %28, 0
  br i1 %.not19, label %29, label %38

29:                                               ; preds = %25, %21, %17, %8
  %30 = load i32, ptr %9, align 4, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %9, i64 4
  %32 = load i32, ptr %31, align 4, !tbaa !10
  %33 = getelementptr inbounds i8, ptr %9, i64 8
  %34 = load i32, ptr %33, align 4, !tbaa !11
  %35 = getelementptr inbounds i8, ptr %9, i64 12
  %36 = load i32, ptr %35, align 4, !tbaa !12
  %37 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %30, i32 noundef %32, i32 noundef %34, i32 noundef %36)
  br label %40

38:                                               ; preds = %25
  %39 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %40

40:                                               ; preds = %38, %29
  %.0 = phi i32 [ 1, %38 ], [ 0, %29 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %10) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %9) #3
  ret i32 %.0
}

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

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #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 = { 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 = { 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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!6, !7, i64 8}
!12 = !{!6, !7, i64 12}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,TailCallElimPass