; LLVM IR from VT-ICAM/cfem :: cfem (cf_get_corners)

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

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [60 x i8], align 1

; 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
define dso_local i32 @cf_get_corners(ptr noundef %0, i32 noundef %1, ptr noundef align 8 dereferenceable(24) %2, ptr noundef align 8 dereferenceable(24) %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %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
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  store i32 0, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.cf_mesh_s, ptr %14, i32 0, i32 2
  %16 = load i32, ptr %15, align 8, !tbaa !11
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.cf_mesh_s, ptr %17, i32 0, i32 3
  %19 = load i32, ptr %18, align 4, !tbaa !13
  %20 = mul nsw i32 %16, %19
  store i32 %20, ptr %13, align 4, !tbaa !9
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %74, %4
  %22 = load i32, ptr %9, align 4, !tbaa !9
  %23 = icmp slt i32 %22, 3
  br i1 %23, label %24, label %77

24:                                               ; preds = %21
  %25 = load i32, ptr %6, align 4, !tbaa !9
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.cf_mesh_s, ptr %26, i32 0, i32 3
  %28 = load i32, ptr %27, align 4, !tbaa !13
  %29 = mul nsw i32 %25, %28
  %30 = load i32, ptr %9, align 4, !tbaa !9
  %31 = add nsw i32 %29, %30
  store i32 %31, ptr %11, align 4, !tbaa !9
  %32 = load i32, ptr %11, align 4, !tbaa !9
  %33 = load i32, ptr %13, align 4, !tbaa !9
  %34 = icmp sge i32 %32, %33
  br i1 %34, label %35, label %40

35:                                               ; preds = %24
  %36 = load ptr, ptr @stderr, align 8, !tbaa !5
  %37 = load i32, ptr %11, align 4, !tbaa !9
  %38 = load i32, ptr %13, align 4, !tbaa !9
  %39 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef @.str, i32 noundef %37, i32 noundef %38) #3
  store i32 0, ptr %11, align 4, !tbaa !9
  store i32 1, ptr %12, align 4, !tbaa !9
  br label %40

40:                                               ; preds = %35, %24
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.cf_mesh_s, ptr %41, i32 0, i32 4
  %43 = load ptr, ptr %42, align 8, !tbaa !14
  %44 = load i32, ptr %11, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds i32, ptr %43, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !9
  store i32 %47, ptr %10, align 4, !tbaa !9
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.cf_mesh_s, ptr %48, i32 0, i32 1
  %50 = load ptr, ptr %49, align 8, !tbaa !15
  %51 = load i32, ptr %10, align 4, !tbaa !9
  %52 = mul nsw i32 %51, 2
  %53 = add nsw i32 %52, 0
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds double, ptr %50, i64 %54
  %56 = load double, ptr %55, align 8, !tbaa !16
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = load i32, ptr %9, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds double, ptr %57, i64 %59
  store double %56, ptr %60, align 8, !tbaa !16
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.cf_mesh_s, ptr %61, i32 0, i32 1
  %63 = load ptr, ptr %62, align 8, !tbaa !15
  %64 = load i32, ptr %10, align 4, !tbaa !9
  %65 = mul nsw i32 %64, 2
  %66 = add nsw i32 %65, 1
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds double, ptr %63, i64 %67
  %69 = load double, ptr %68, align 8, !tbaa !16
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = load i32, ptr %9, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds double, ptr %70, i64 %72
  store double %69, ptr %73, align 8, !tbaa !16
  br label %74

74:                                               ; preds = %40
  %75 = load i32, ptr %9, align 4, !tbaa !9
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %9, align 4, !tbaa !9
  br label %21, !llvm.loop !18

77:                                               ; preds = %21
  %78 = load i32, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret i32 %78
}

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

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 "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 = !{!"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 16}
!12 = !{!"", !10, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !6, i64 24}
!13 = !{!12, !10, i64 20}
!14 = !{!12, !6, i64 24}
!15 = !{!12, !6, i64 8}
!16 = !{!17, !17, i64 0}
!17 = !{!"double", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [60 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local range(i32 0, 2) i32 @cf_get_corners(ptr nocapture noundef readonly %0, i32 noundef %1, ptr nocapture noundef writeonly align 8 dereferenceable(24) %2, ptr nocapture noundef writeonly align 8 dereferenceable(24) %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 20
  %8 = load i32, ptr %7, align 4, !tbaa !11
  %9 = mul nsw i32 %8, %6
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = mul nsw i32 %8, %1
  %.not = icmp slt i32 %12, %9
  br i1 %.not, label %16, label %13

13:                                               ; preds = %4
  %14 = load ptr, ptr @stderr, align 8, !tbaa !12
  %15 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str, i32 noundef %12, i32 noundef %9) #2
  %.pre = load i32, ptr %7, align 4, !tbaa !11
  %.pre34 = mul nsw i32 %.pre, %1
  br label %16

16:                                               ; preds = %13, %4
  %.pre-phi = phi i32 [ %.pre34, %13 ], [ %12, %4 ]
  %.022 = phi i32 [ 0, %13 ], [ %12, %4 ]
  %.1 = phi i32 [ 1, %13 ], [ 0, %4 ]
  %17 = load ptr, ptr %10, align 8, !tbaa !13
  %18 = sext i32 %.022 to i64
  %19 = getelementptr inbounds i32, ptr %17, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !14
  %21 = load ptr, ptr %11, align 8, !tbaa !15
  %22 = shl nsw i32 %20, 1
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds double, ptr %21, i64 %23
  %25 = load double, ptr %24, align 8, !tbaa !16
  store double %25, ptr %2, align 8, !tbaa !16
  %26 = or disjoint i32 %22, 1
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds double, ptr %21, i64 %27
  %29 = load double, ptr %28, align 8, !tbaa !16
  store double %29, ptr %3, align 8, !tbaa !16
  %30 = add nsw i32 %.pre-phi, 1
  %.not.1 = icmp slt i32 %30, %9
  br i1 %.not.1, label %34, label %31

31:                                               ; preds = %16
  %32 = load ptr, ptr @stderr, align 8, !tbaa !12
  %33 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef nonnull @.str, i32 noundef %30, i32 noundef %9) #2
  %.pre29 = load ptr, ptr %10, align 8, !tbaa !13
  %.pre30 = load ptr, ptr %11, align 8, !tbaa !15
  %.pre31 = load i32, ptr %7, align 4, !tbaa !11
  %.pre35 = mul nsw i32 %.pre31, %1
  br label %34

34:                                               ; preds = %31, %16
  %.pre-phi36 = phi i32 [ %.pre35, %31 ], [ %.pre-phi, %16 ]
  %35 = phi ptr [ %.pre30, %31 ], [ %21, %16 ]
  %36 = phi ptr [ %.pre29, %31 ], [ %17, %16 ]
  %.022.1 = phi i32 [ 0, %31 ], [ %30, %16 ]
  %.1.1 = phi i32 [ 1, %31 ], [ %.1, %16 ]
  %37 = sext i32 %.022.1 to i64
  %38 = getelementptr inbounds i32, ptr %36, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !14
  %40 = shl nsw i32 %39, 1
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds double, ptr %35, i64 %41
  %43 = load double, ptr %42, align 8, !tbaa !16
  %44 = getelementptr inbounds i8, ptr %2, i64 8
  store double %43, ptr %44, align 8, !tbaa !16
  %45 = or disjoint i32 %40, 1
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds double, ptr %35, i64 %46
  %48 = load double, ptr %47, align 8, !tbaa !16
  %49 = getelementptr inbounds i8, ptr %3, i64 8
  store double %48, ptr %49, align 8, !tbaa !16
  %50 = add nsw i32 %.pre-phi36, 2
  %.not.2 = icmp slt i32 %50, %9
  br i1 %.not.2, label %54, label %51

51:                                               ; preds = %34
  %52 = load ptr, ptr @stderr, align 8, !tbaa !12
  %53 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %52, ptr noundef nonnull @.str, i32 noundef %50, i32 noundef %9) #2
  %.pre32 = load ptr, ptr %10, align 8, !tbaa !13
  %.pre33 = load ptr, ptr %11, align 8, !tbaa !15
  br label %54

54:                                               ; preds = %51, %34
  %55 = phi ptr [ %.pre33, %51 ], [ %35, %34 ]
  %56 = phi ptr [ %.pre32, %51 ], [ %36, %34 ]
  %.022.2 = phi i32 [ 0, %51 ], [ %50, %34 ]
  %.1.2 = phi i32 [ 1, %51 ], [ %.1.1, %34 ]
  %57 = sext i32 %.022.2 to i64
  %58 = getelementptr inbounds i32, ptr %56, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !14
  %60 = shl nsw i32 %59, 1
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds double, ptr %55, i64 %61
  %63 = load double, ptr %62, align 8, !tbaa !16
  %64 = getelementptr inbounds i8, ptr %2, i64 16
  store double %63, ptr %64, align 8, !tbaa !16
  %65 = or disjoint i32 %60, 1
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds double, ptr %55, i64 %66
  %68 = load double, ptr %67, align 8, !tbaa !16
  %69 = getelementptr inbounds i8, ptr %3, i64 16
  store double %68, ptr %69, align 8, !tbaa !16
  ret i32 %.1.2
}

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

attributes #0 = { nofree 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 = { cold 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 16}
!6 = !{!"", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 20, !10, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 20}
!12 = !{!10, !10, i64 0}
!13 = !{!6, !10, i64 24}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !10, i64 8}
!16 = !{!17, !17, i64 0}
!17 = !{!"double", !8, i64 0}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass