; LLVM IR from ETH3D/dataset-pipeline :: thirdparty/cork/cork/isct (triangle)

; 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.mesh = type { %struct.memorypool, %struct.memorypool, %struct.memorypool, %struct.memorypool, %struct.memorypool, %struct.memorypool, %struct.memorypool, %struct.memorypool, [4096 x ptr], [4096 x ptr], [4096 x i32], i32, ptr, double, double, double, double, double, i32, i32, i32, i32, i32, i32, i64, i32, i32, i32, i64, i32, i32, i32, i32, i32, i32, i32, i32, i32, i64, i64, i64, i64, i64, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %struct.otri }
%struct.memorypool = type { ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i64, i64, i32, i32 }
%struct.otri = type { ptr, i32 }
%struct.behavior = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, double, double, double, double, [2048 x i8], [2048 x i8], [2048 x i8], [2048 x i8], [2048 x i8], [2048 x i8], [2048 x i8], [2048 x i8], [2048 x i8], [2048 x i8], [2048 x i8], [2048 x i8] }

@ccwerrboundA = external dso_local global double, align 8

; 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 dso_local double @counterclockwiseadapt(ptr noundef, ptr noundef, ptr noundef, double noundef) #1

; Function Attrs: nounwind uwtable
define dso_local double @counterclockwise(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #1 {
  %6 = alloca double, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #2
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.mesh, ptr %18, i32 0, i32 40
  %20 = load i64, ptr %19, align 8, !tbaa !9
  %21 = add nsw i64 %20, 1
  store i64 %21, ptr %19, align 8, !tbaa !9
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = getelementptr inbounds double, ptr %22, i64 0
  %24 = load double, ptr %23, align 8, !tbaa !16
  %25 = load ptr, ptr %11, align 8, !tbaa !5
  %26 = getelementptr inbounds double, ptr %25, i64 0
  %27 = load double, ptr %26, align 8, !tbaa !16
  %28 = fsub double %24, %27
  %29 = load ptr, ptr %10, align 8, !tbaa !5
  %30 = getelementptr inbounds double, ptr %29, i64 1
  %31 = load double, ptr %30, align 8, !tbaa !16
  %32 = load ptr, ptr %11, align 8, !tbaa !5
  %33 = getelementptr inbounds double, ptr %32, i64 1
  %34 = load double, ptr %33, align 8, !tbaa !16
  %35 = fsub double %31, %34
  %36 = fmul double %28, %35
  store double %36, ptr %12, align 8, !tbaa !16
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = getelementptr inbounds double, ptr %37, i64 1
  %39 = load double, ptr %38, align 8, !tbaa !16
  %40 = load ptr, ptr %11, align 8, !tbaa !5
  %41 = getelementptr inbounds double, ptr %40, i64 1
  %42 = load double, ptr %41, align 8, !tbaa !16
  %43 = fsub double %39, %42
  %44 = load ptr, ptr %10, align 8, !tbaa !5
  %45 = getelementptr inbounds double, ptr %44, i64 0
  %46 = load double, ptr %45, align 8, !tbaa !16
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  %48 = getelementptr inbounds double, ptr %47, i64 0
  %49 = load double, ptr %48, align 8, !tbaa !16
  %50 = fsub double %46, %49
  %51 = fmul double %43, %50
  store double %51, ptr %13, align 8, !tbaa !16
  %52 = load double, ptr %12, align 8, !tbaa !16
  %53 = load double, ptr %13, align 8, !tbaa !16
  %54 = fsub double %52, %53
  store double %54, ptr %14, align 8, !tbaa !16
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.behavior, ptr %55, i32 0, i32 21
  %57 = load i32, ptr %56, align 4, !tbaa !17
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %61

59:                                               ; preds = %5
  %60 = load double, ptr %14, align 8, !tbaa !16
  store double %60, ptr %6, align 8
  store i32 1, ptr %17, align 4
  br label %111

61:                                               ; preds = %5
  %62 = load double, ptr %12, align 8, !tbaa !16
  %63 = fcmp ogt double %62, 0.000000e+00
  br i1 %63, label %64, label %74

64:                                               ; preds = %61
  %65 = load double, ptr %13, align 8, !tbaa !16
  %66 = fcmp ole double %65, 0.000000e+00
  br i1 %66, label %67, label %69

67:                                               ; preds = %64
  %68 = load double, ptr %14, align 8, !tbaa !16
  store double %68, ptr %6, align 8
  store i32 1, ptr %17, align 4
  br label %111

69:                                               ; preds = %64
  %70 = load double, ptr %12, align 8, !tbaa !16
  %71 = load double, ptr %13, align 8, !tbaa !16
  %72 = fadd double %70, %71
  store double %72, ptr %15, align 8, !tbaa !16
  br label %73

73:                                               ; preds = %69
  br label %91

74:                                               ; preds = %61
  %75 = load double, ptr %12, align 8, !tbaa !16
  %76 = fcmp olt double %75, 0.000000e+00
  br i1 %76, label %77, label %88

77:                                               ; preds = %74
  %78 = load double, ptr %13, align 8, !tbaa !16
  %79 = fcmp oge double %78, 0.000000e+00
  br i1 %79, label %80, label %82

80:                                               ; preds = %77
  %81 = load double, ptr %14, align 8, !tbaa !16
  store double %81, ptr %6, align 8
  store i32 1, ptr %17, align 4
  br label %111

82:                                               ; preds = %77
  %83 = load double, ptr %12, align 8, !tbaa !16
  %84 = fneg double %83
  %85 = load double, ptr %13, align 8, !tbaa !16
  %86 = fsub double %84, %85
  store double %86, ptr %15, align 8, !tbaa !16
  br label %87

87:                                               ; preds = %82
  br label %90

88:                                               ; preds = %74
  %89 = load double, ptr %14, align 8, !tbaa !16
  store double %89, ptr %6, align 8
  store i32 1, ptr %17, align 4
  br label %111

90:                                               ; preds = %87
  br label %91

91:                                               ; preds = %90, %73
  %92 = load double, ptr @ccwerrboundA, align 8, !tbaa !16
  %93 = load double, ptr %15, align 8, !tbaa !16
  %94 = fmul double %92, %93
  store double %94, ptr %16, align 8, !tbaa !16
  %95 = load double, ptr %14, align 8, !tbaa !16
  %96 = load double, ptr %16, align 8, !tbaa !16
  %97 = fcmp oge double %95, %96
  br i1 %97, label %103, label %98

98:                                               ; preds = %91
  %99 = load double, ptr %14, align 8, !tbaa !16
  %100 = fneg double %99
  %101 = load double, ptr %16, align 8, !tbaa !16
  %102 = fcmp oge double %100, %101
  br i1 %102, label %103, label %105

103:                                              ; preds = %98, %91
  %104 = load double, ptr %14, align 8, !tbaa !16
  store double %104, ptr %6, align 8
  store i32 1, ptr %17, align 4
  br label %111

105:                                              ; preds = %98
  %106 = load ptr, ptr %9, align 8, !tbaa !5
  %107 = load ptr, ptr %10, align 8, !tbaa !5
  %108 = load ptr, ptr %11, align 8, !tbaa !5
  %109 = load double, ptr %15, align 8, !tbaa !16
  %110 = call double @counterclockwiseadapt(ptr noundef %106, ptr noundef %107, ptr noundef %108, double noundef %109)
  store double %110, ptr %6, align 8
  store i32 1, ptr %17, align 4
  br label %111

111:                                              ; preds = %105, %103, %88, %80, %67, %59
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  %112 = load double, ptr %6, align 8
  ret double %112
}

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, !13, i64 82792}
!10 = !{!"mesh", !11, i64 0, !11, i64 88, !11, i64 176, !11, i64 264, !11, i64 352, !11, i64 440, !11, i64 528, !11, i64 616, !7, i64 704, !7, i64 33472, !7, i64 66240, !12, i64 82624, !6, i64 82632, !14, i64 82640, !14, i64 82648, !14, i64 82656, !14, i64 82664, !14, i64 82672, !12, i64 82680, !12, i64 82684, !12, i64 82688, !12, i64 82692, !12, i64 82696, !12, i64 82700, !13, i64 82704, !12, i64 82712, !12, i64 82716, !12, i64 82720, !13, i64 82728, !12, i64 82736, !12, i64 82740, !12, i64 82744, !12, i64 82748, !12, i64 82752, !12, i64 82756, !12, i64 82760, !12, i64 82764, !12, i64 82768, !13, i64 82776, !13, i64 82784, !13, i64 82792, !13, i64 82800, !13, i64 82808, !13, i64 82816, !13, i64 82824, !6, i64 82832, !6, i64 82840, !6, i64 82848, !6, i64 82856, !6, i64 82864, !6, i64 82872, !6, i64 82880, !15, i64 82888}
!11 = !{!"memorypool", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60, !13, i64 64, !13, i64 72, !12, i64 80, !12, i64 84}
!12 = !{!"int", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!"otri", !6, i64 0, !12, i64 8}
!16 = !{!14, !14, i64 0}
!17 = !{!18, !12, i64 84}
!18 = !{!"behavior", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60, !12, i64 64, !12, i64 68, !12, i64 72, !12, i64 76, !12, i64 80, !12, i64 84, !12, i64 88, !12, i64 92, !12, i64 96, !12, i64 100, !12, i64 104, !12, i64 108, !12, i64 112, !12, i64 116, !12, i64 120, !12, i64 124, !12, i64 128, !12, i64 132, !14, i64 136, !14, i64 144, !14, i64 152, !14, i64 160, !7, i64 168, !7, i64 2216, !7, i64 4264, !7, i64 6312, !7, i64 8360, !7, i64 10408, !7, i64 12456, !7, i64 14504, !7, i64 16552, !7, i64 18600, !7, i64 20648, !7, i64 22696}


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

@ccwerrboundA = external dso_local local_unnamed_addr global double, align 8

; Function Attrs: nounwind uwtable
declare dso_local double @counterclockwiseadapt(ptr noundef, ptr noundef, ptr noundef, double noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local double @counterclockwise(ptr nocapture noundef %0, ptr nocapture noundef readonly %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = getelementptr inbounds i8, ptr %0, i64 82792
  %7 = load i64, ptr %6, align 8, !tbaa !5
  %8 = add nsw i64 %7, 1
  store i64 %8, ptr %6, align 8, !tbaa !5
  %9 = load <2 x double>, ptr %4, align 8, !tbaa !15
  %10 = load <2 x double>, ptr %2, align 8, !tbaa !15
  %11 = fsub <2 x double> %10, %9
  %12 = load <2 x double>, ptr %3, align 8, !tbaa !15
  %13 = fsub <2 x double> %12, %9
  %14 = shufflevector <2 x double> %13, <2 x double> poison, <2 x i32> <i32 1, i32 0>
  %15 = fmul <2 x double> %11, %14
  %16 = extractelement <2 x double> %15, i64 0
  %17 = extractelement <2 x double> %15, i64 1
  %18 = fsub double %16, %17
  %19 = getelementptr inbounds i8, ptr %1, i64 84
  %20 = load i32, ptr %19, align 4, !tbaa !16
  %.not = icmp eq i32 %20, 0
  br i1 %.not, label %21, label %41

21:                                               ; preds = %5
  %22 = fcmp ogt double %16, 0.000000e+00
  br i1 %22, label %23, label %27

23:                                               ; preds = %21
  %24 = fcmp ugt double %17, 0.000000e+00
  br i1 %24, label %25, label %41

25:                                               ; preds = %23
  %26 = fadd double %16, %17
  br label %33

27:                                               ; preds = %21
  %28 = fcmp olt double %16, 0.000000e+00
  %29 = fcmp ult double %17, 0.000000e+00
  %or.cond42 = select i1 %28, i1 %29, i1 false
  br i1 %or.cond42, label %30, label %41

30:                                               ; preds = %27
  %31 = fneg double %16
  %32 = fsub double %31, %17
  br label %33

33:                                               ; preds = %30, %25
  %.035 = phi double [ %26, %25 ], [ %32, %30 ]
  %34 = load double, ptr @ccwerrboundA, align 8, !tbaa !15
  %35 = fmul double %.035, %34
  %36 = fcmp ult double %18, %35
  %37 = fneg double %18
  %38 = fcmp ugt double %35, %37
  %or.cond = and i1 %36, %38
  br i1 %or.cond, label %39, label %41

39:                                               ; preds = %33
  %40 = tail call double @counterclockwiseadapt(ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4, double noundef %.035)
  br label %41

41:                                               ; preds = %33, %27, %23, %5, %39
  %.0 = phi double [ %40, %39 ], [ %18, %5 ], [ %18, %23 ], [ %18, %27 ], [ %18, %33 ]
  ret double %.0
}

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

!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, !12, i64 82792}
!6 = !{!"mesh", !7, i64 0, !7, i64 88, !7, i64 176, !7, i64 264, !7, i64 352, !7, i64 440, !7, i64 528, !7, i64 616, !9, i64 704, !9, i64 33472, !9, i64 66240, !11, i64 82624, !8, i64 82632, !13, i64 82640, !13, i64 82648, !13, i64 82656, !13, i64 82664, !13, i64 82672, !11, i64 82680, !11, i64 82684, !11, i64 82688, !11, i64 82692, !11, i64 82696, !11, i64 82700, !12, i64 82704, !11, i64 82712, !11, i64 82716, !11, i64 82720, !12, i64 82728, !11, i64 82736, !11, i64 82740, !11, i64 82744, !11, i64 82748, !11, i64 82752, !11, i64 82756, !11, i64 82760, !11, i64 82764, !11, i64 82768, !12, i64 82776, !12, i64 82784, !12, i64 82792, !12, i64 82800, !12, i64 82808, !12, i64 82816, !12, i64 82824, !8, i64 82832, !8, i64 82840, !8, i64 82848, !8, i64 82856, !8, i64 82864, !8, i64 82872, !8, i64 82880, !14, i64 82888}
!7 = !{!"memorypool", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !8, i64 40, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !12, i64 64, !12, i64 72, !11, i64 80, !11, i64 84}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"long", !9, i64 0}
!13 = !{!"double", !9, i64 0}
!14 = !{!"otri", !8, i64 0, !11, i64 8}
!15 = !{!13, !13, i64 0}
!16 = !{!17, !11, i64 84}
!17 = !{!"behavior", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !11, i64 72, !11, i64 76, !11, i64 80, !11, i64 84, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !11, i64 104, !11, i64 108, !11, i64 112, !11, i64 116, !11, i64 120, !11, i64 124, !11, i64 128, !11, i64 132, !13, i64 136, !13, i64 144, !13, i64 152, !13, i64 160, !9, i64 168, !9, i64 2216, !9, i64 4264, !9, i64 6312, !9, i64 8360, !9, i64 10408, !9, i64 12456, !9, i64 14504, !9, i64 16552, !9, i64 18600, !9, i64 20648, !9, i64 22696}


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