; LLVM IR from kroitor/gjk.c :: gjk (main)

; 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._vec2 = type { float, float }

@iter_count = external dso_local global i32, align 4
@__const.main.vertices1 = external hidden unnamed_addr constant [3 x %struct._vec2], align 16
@__const.main.vertices2 = external hidden unnamed_addr constant [3 x %struct._vec2], align 16
@.str = external hidden unnamed_addr constant [82 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [30 x i8], align 1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #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 i32 @gjk(ptr noundef, i64 noundef, ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local <2 x float> @Jostle(<2 x float>) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca [3 x %struct._vec2], align 16
  %7 = alloca [3 x %struct._vec2], align 16
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca [3 x %struct._vec2], align 16
  %11 = alloca [3 x %struct._vec2], align 16
  %12 = alloca i64, align 8
  %13 = alloca %struct._vec2, align 4
  %14 = alloca i64, align 8
  %15 = alloca %struct._vec2, align 4
  %16 = 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 24, ptr %6) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %6, ptr align 16 @__const.main.vertices1, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %7, ptr align 16 @__const.main.vertices2, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store i64 3, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store i64 3, ptr %9, align 8, !tbaa !11
  br label %17

17:                                               ; preds = %110, %2
  br label %18

18:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  store i64 0, ptr %12, align 8, !tbaa !11
  br label %19

19:                                               ; preds = %31, %18
  %20 = load i64, ptr %12, align 8, !tbaa !11
  %21 = load i64, ptr %8, align 8, !tbaa !11
  %22 = icmp ult i64 %20, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %34

24:                                               ; preds = %19
  %25 = load i64, ptr %12, align 8, !tbaa !11
  %26 = getelementptr inbounds [3 x %struct._vec2], ptr %10, i64 0, i64 %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %27 = load i64, ptr %12, align 8, !tbaa !11
  %28 = getelementptr inbounds [3 x %struct._vec2], ptr %6, i64 0, i64 %27
  %29 = load <2 x float>, ptr %28, align 8
  %30 = call <2 x float> @Jostle(<2 x float> %29)
  store <2 x float> %30, ptr %13, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %26, ptr align 4 %13, i64 8, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  br label %31

31:                                               ; preds = %24
  %32 = load i64, ptr %12, align 8, !tbaa !11
  %33 = add i64 %32, 1
  store i64 %33, ptr %12, align 8, !tbaa !11
  br label %19, !llvm.loop !16

34:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  store i64 0, ptr %14, align 8, !tbaa !11
  br label %35

35:                                               ; preds = %47, %34
  %36 = load i64, ptr %14, align 8, !tbaa !11
  %37 = load i64, ptr %9, align 8, !tbaa !11
  %38 = icmp ult i64 %36, %37
  br i1 %38, label %40, label %39

39:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  br label %50

40:                                               ; preds = %35
  %41 = load i64, ptr %14, align 8, !tbaa !11
  %42 = getelementptr inbounds [3 x %struct._vec2], ptr %11, i64 0, i64 %41
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %43 = load i64, ptr %14, align 8, !tbaa !11
  %44 = getelementptr inbounds [3 x %struct._vec2], ptr %7, i64 0, i64 %43
  %45 = load <2 x float>, ptr %44, align 8
  %46 = call <2 x float> @Jostle(<2 x float> %45)
  store <2 x float> %46, ptr %15, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %42, ptr align 4 %15, i64 8, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  br label %47

47:                                               ; preds = %40
  %48 = load i64, ptr %14, align 8, !tbaa !11
  %49 = add i64 %48, 1
  store i64 %49, ptr %14, align 8, !tbaa !11
  br label %35, !llvm.loop !18

50:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %51 = getelementptr inbounds [3 x %struct._vec2], ptr %10, i64 0, i64 0
  %52 = load i64, ptr %8, align 8, !tbaa !11
  %53 = getelementptr inbounds [3 x %struct._vec2], ptr %11, i64 0, i64 0
  %54 = load i64, ptr %9, align 8, !tbaa !11
  %55 = call i32 @gjk(ptr noundef %51, i64 noundef %52, ptr noundef %53, i64 noundef %54)
  store i32 %55, ptr %16, align 4, !tbaa !5
  %56 = load i32, ptr %16, align 4, !tbaa !5
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %108, label %58

58:                                               ; preds = %50
  %59 = getelementptr inbounds [3 x %struct._vec2], ptr %10, i64 0, i64 0
  %60 = getelementptr inbounds %struct._vec2, ptr %59, i32 0, i32 0
  %61 = load float, ptr %60, align 16, !tbaa !19
  %62 = fpext float %61 to double
  %63 = getelementptr inbounds [3 x %struct._vec2], ptr %10, i64 0, i64 0
  %64 = getelementptr inbounds %struct._vec2, ptr %63, i32 0, i32 1
  %65 = load float, ptr %64, align 4, !tbaa !21
  %66 = fpext float %65 to double
  %67 = getelementptr inbounds [3 x %struct._vec2], ptr %10, i64 0, i64 1
  %68 = getelementptr inbounds %struct._vec2, ptr %67, i32 0, i32 0
  %69 = load float, ptr %68, align 8, !tbaa !19
  %70 = fpext float %69 to double
  %71 = getelementptr inbounds [3 x %struct._vec2], ptr %10, i64 0, i64 1
  %72 = getelementptr inbounds %struct._vec2, ptr %71, i32 0, i32 1
  %73 = load float, ptr %72, align 4, !tbaa !21
  %74 = fpext float %73 to double
  %75 = getelementptr inbounds [3 x %struct._vec2], ptr %10, i64 0, i64 2
  %76 = getelementptr inbounds %struct._vec2, ptr %75, i32 0, i32 0
  %77 = load float, ptr %76, align 16, !tbaa !19
  %78 = fpext float %77 to double
  %79 = getelementptr inbounds [3 x %struct._vec2], ptr %10, i64 0, i64 2
  %80 = getelementptr inbounds %struct._vec2, ptr %79, i32 0, i32 1
  %81 = load float, ptr %80, align 4, !tbaa !21
  %82 = fpext float %81 to double
  %83 = getelementptr inbounds [3 x %struct._vec2], ptr %11, i64 0, i64 0
  %84 = getelementptr inbounds %struct._vec2, ptr %83, i32 0, i32 0
  %85 = load float, ptr %84, align 16, !tbaa !19
  %86 = fpext float %85 to double
  %87 = getelementptr inbounds [3 x %struct._vec2], ptr %11, i64 0, i64 0
  %88 = getelementptr inbounds %struct._vec2, ptr %87, i32 0, i32 1
  %89 = load float, ptr %88, align 4, !tbaa !21
  %90 = fpext float %89 to double
  %91 = getelementptr inbounds [3 x %struct._vec2], ptr %11, i64 0, i64 1
  %92 = getelementptr inbounds %struct._vec2, ptr %91, i32 0, i32 0
  %93 = load float, ptr %92, align 8, !tbaa !19
  %94 = fpext float %93 to double
  %95 = getelementptr inbounds [3 x %struct._vec2], ptr %11, i64 0, i64 1
  %96 = getelementptr inbounds %struct._vec2, ptr %95, i32 0, i32 1
  %97 = load float, ptr %96, align 4, !tbaa !21
  %98 = fpext float %97 to double
  %99 = getelementptr inbounds [3 x %struct._vec2], ptr %11, i64 0, i64 2
  %100 = getelementptr inbounds %struct._vec2, ptr %99, i32 0, i32 0
  %101 = load float, ptr %100, align 16, !tbaa !19
  %102 = fpext float %101 to double
  %103 = getelementptr inbounds [3 x %struct._vec2], ptr %11, i64 0, i64 2
  %104 = getelementptr inbounds %struct._vec2, ptr %103, i32 0, i32 1
  %105 = load float, ptr %104, align 4, !tbaa !21
  %106 = fpext float %105 to double
  %107 = call i32 (ptr, ...) @printf(ptr noundef @.str, double noundef %62, double noundef %66, double noundef %70, double noundef %74, double noundef %78, double noundef %82, double noundef %86, double noundef %90, double noundef %94, double noundef %98, double noundef %102, double noundef %106)
  br label %110

108:                                              ; preds = %50
  %109 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %110

110:                                              ; preds = %108, %58
  store i32 0, ptr @iter_count, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #4
  br label %17
}

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

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="64" "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, !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 = !{i64 0, i64 4, !14, i64 4, i64 4, !14}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = !{!20, !15, i64 0}
!20 = !{!"_vec2", !15, i64 0, !15, i64 4}
!21 = !{!20, !15, i64 4}


; 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._vec2 = type { float, float }

@iter_count = external dso_local local_unnamed_addr global i32, align 4
@__const.main.vertices1 = external hidden unnamed_addr constant [3 x %struct._vec2], align 16
@__const.main.vertices2 = external hidden unnamed_addr constant [3 x %struct._vec2], align 16
@.str = external hidden unnamed_addr constant [82 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [30 x i8], align 1

; 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 dso_local i32 @gjk(ptr noundef, i64 noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local <2 x float> @Jostle(<2 x float>) local_unnamed_addr #1

; Function Attrs: noreturn nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #2 {
  %3 = alloca [3 x %struct._vec2], align 16
  %4 = alloca [3 x %struct._vec2], align 16
  %5 = getelementptr inbounds i8, ptr %3, i64 4
  %6 = getelementptr inbounds i8, ptr %3, i64 8
  %7 = getelementptr inbounds i8, ptr %3, i64 12
  %8 = getelementptr inbounds i8, ptr %3, i64 16
  %9 = getelementptr inbounds i8, ptr %3, i64 20
  %10 = getelementptr inbounds i8, ptr %4, i64 4
  %11 = getelementptr inbounds i8, ptr %4, i64 8
  %12 = getelementptr inbounds i8, ptr %4, i64 12
  %13 = getelementptr inbounds i8, ptr %4, i64 16
  %14 = getelementptr inbounds i8, ptr %4, i64 20
  %.pre = load <2 x float>, ptr @__const.main.vertices1, align 16
  %.pre17 = load <2 x float>, ptr getelementptr inbounds (i8, ptr @__const.main.vertices1, i64 8), align 8
  %.pre18 = load <2 x float>, ptr getelementptr inbounds (i8, ptr @__const.main.vertices1, i64 16), align 16
  %.pre19 = load <2 x float>, ptr @__const.main.vertices2, align 16
  %.pre20 = load <2 x float>, ptr getelementptr inbounds (i8, ptr @__const.main.vertices2, i64 8), align 8
  %.pre21 = load <2 x float>, ptr getelementptr inbounds (i8, ptr @__const.main.vertices2, i64 16), align 16
  br label %.preheader.preheader

.preheader.preheader:                             ; preds = %50, %2
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #4
  %15 = call <2 x float> @Jostle(<2 x float> %.pre)
  store <2 x float> %15, ptr %3, align 16
  %16 = call <2 x float> @Jostle(<2 x float> %.pre17)
  store <2 x float> %16, ptr %6, align 8
  %17 = call <2 x float> @Jostle(<2 x float> %.pre18)
  store <2 x float> %17, ptr %8, align 16
  %18 = call <2 x float> @Jostle(<2 x float> %.pre19)
  store <2 x float> %18, ptr %4, align 16
  %19 = call <2 x float> @Jostle(<2 x float> %.pre20)
  store <2 x float> %19, ptr %11, align 8
  %20 = call <2 x float> @Jostle(<2 x float> %.pre21)
  store <2 x float> %20, ptr %13, align 16
  %21 = call i32 @gjk(ptr noundef nonnull %3, i64 noundef 3, ptr noundef nonnull %4, i64 noundef 3)
  %.not = icmp eq i32 %21, 0
  br i1 %.not, label %22, label %48

22:                                               ; preds = %.preheader.preheader
  %23 = load float, ptr %3, align 16, !tbaa !5
  %24 = fpext float %23 to double
  %25 = load float, ptr %5, align 4, !tbaa !10
  %26 = fpext float %25 to double
  %27 = load float, ptr %6, align 8, !tbaa !5
  %28 = fpext float %27 to double
  %29 = load float, ptr %7, align 4, !tbaa !10
  %30 = fpext float %29 to double
  %31 = load float, ptr %8, align 16, !tbaa !5
  %32 = fpext float %31 to double
  %33 = load float, ptr %9, align 4, !tbaa !10
  %34 = fpext float %33 to double
  %35 = load float, ptr %4, align 16, !tbaa !5
  %36 = fpext float %35 to double
  %37 = load float, ptr %10, align 4, !tbaa !10
  %38 = fpext float %37 to double
  %39 = load float, ptr %11, align 8, !tbaa !5
  %40 = fpext float %39 to double
  %41 = load float, ptr %12, align 4, !tbaa !10
  %42 = fpext float %41 to double
  %43 = load float, ptr %13, align 16, !tbaa !5
  %44 = fpext float %43 to double
  %45 = load float, ptr %14, align 4, !tbaa !10
  %46 = fpext float %45 to double
  %47 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %24, double noundef %26, double noundef %28, double noundef %30, double noundef %32, double noundef %34, double noundef %36, double noundef %38, double noundef %40, double noundef %42, double noundef %44, double noundef %46)
  br label %50

48:                                               ; preds = %.preheader.preheader
  %49 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %50

50:                                               ; preds = %48, %22
  store i32 0, ptr @iter_count, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #4
  br label %.preheader.preheader
}

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="64" "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 uwtable "min-legal-vector-width"="64" "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 = { 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 #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, !7, i64 0}
!6 = !{!"_vec2", !7, i64 0, !7, i64 4}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !8, i64 0}


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