; LLVM IR from ivan-pi/periodic-lbm :: third-party (dugks_cavity)

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

@ux = external dso_local global [32 x [32 x double]], align 16
@uy = external dso_local global [32 x [32 x double]], align 16
@rho = external dso_local global [32 x [32 x double]], align 16
@f = external dso_local global [32 x [32 x [3 x [3 x double]]]], align 16

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

; Function Attrs: nounwind uwtable
define dso_local void @gks_ini() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %5

5:                                                ; preds = %87, %0
  %6 = load i32, ptr %2, align 4, !tbaa !5
  %7 = icmp sle i32 %6, 30
  br i1 %7, label %8, label %90

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

9:                                                ; preds = %83, %8
  %10 = load i32, ptr %1, align 4, !tbaa !5
  %11 = icmp sle i32 %10, 30
  br i1 %11, label %12, label %86

12:                                               ; preds = %9
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [32 x [32 x double]], ptr @uy, i64 0, i64 %14
  %16 = load i32, ptr %1, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [32 x double], ptr %15, i64 0, i64 %17
  store double 0.000000e+00, ptr %18, align 8, !tbaa !9
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [32 x [32 x double]], ptr @ux, i64 0, i64 %20
  %22 = load i32, ptr %1, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [32 x double], ptr %21, i64 0, i64 %23
  store double 0.000000e+00, ptr %24, align 8, !tbaa !9
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [32 x [32 x double]], ptr @rho, i64 0, i64 %26
  %28 = load i32, ptr %1, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [32 x double], ptr %27, i64 0, i64 %29
  store double 1.000000e+00, ptr %30, align 8, !tbaa !9
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %79, %12
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = icmp slt i32 %32, 3
  br i1 %33, label %34, label %82

34:                                               ; preds = %31
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %75, %34
  %36 = load i32, ptr %4, align 4, !tbaa !5
  %37 = icmp slt i32 %36, 3
  br i1 %37, label %38, label %78

38:                                               ; preds = %35
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [32 x [32 x double]], ptr @ux, i64 0, i64 %42
  %44 = load i32, ptr %1, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [32 x double], ptr %43, i64 0, i64 %45
  %47 = load double, ptr %46, align 8, !tbaa !9
  %48 = load i32, ptr %2, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [32 x [32 x double]], ptr @uy, i64 0, i64 %49
  %51 = load i32, ptr %1, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [32 x double], ptr %50, i64 0, i64 %52
  %54 = load double, ptr %53, align 8, !tbaa !9
  %55 = load i32, ptr %2, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [32 x [32 x double]], ptr @rho, i64 0, i64 %56
  %58 = load i32, ptr %1, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [32 x double], ptr %57, i64 0, i64 %59
  %61 = load double, ptr %60, align 8, !tbaa !9
  %62 = call double @feq(i32 noundef %39, i32 noundef %40, double noundef %47, double noundef %54, double noundef %61)
  %63 = load i32, ptr %2, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [32 x [32 x [3 x [3 x double]]]], ptr @f, i64 0, i64 %64
  %66 = load i32, ptr %1, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [32 x [3 x [3 x double]]], ptr %65, i64 0, i64 %67
  %69 = load i32, ptr %3, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [3 x [3 x double]], ptr %68, i64 0, i64 %70
  %72 = load i32, ptr %4, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [3 x double], ptr %71, i64 0, i64 %73
  store double %62, ptr %74, align 8, !tbaa !9
  br label %75

75:                                               ; preds = %38
  %76 = load i32, ptr %4, align 4, !tbaa !5
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %4, align 4, !tbaa !5
  br label %35, !llvm.loop !11

78:                                               ; preds = %35
  br label %79

79:                                               ; preds = %78
  %80 = load i32, ptr %3, align 4, !tbaa !5
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %3, align 4, !tbaa !5
  br label %31, !llvm.loop !13

82:                                               ; preds = %31
  br label %83

83:                                               ; preds = %82
  %84 = load i32, ptr %1, align 4, !tbaa !5
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %1, align 4, !tbaa !5
  br label %9, !llvm.loop !14

86:                                               ; preds = %9
  br label %87

87:                                               ; preds = %86
  %88 = load i32, ptr %2, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %2, align 4, !tbaa !5
  br label %5, !llvm.loop !15

90:                                               ; preds = %5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #2
  ret void
}

; 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 @feq(i32 noundef, i32 noundef, double noundef, double noundef, double noundef) #1

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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !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"

@ux = external dso_local local_unnamed_addr global [32 x [32 x double]], align 16
@uy = external dso_local local_unnamed_addr global [32 x [32 x double]], align 16
@rho = external dso_local local_unnamed_addr global [32 x [32 x double]], align 16
@f = external dso_local local_unnamed_addr global [32 x [32 x [3 x [3 x double]]]], align 16

; Function Attrs: nounwind uwtable
define dso_local void @gks_ini() local_unnamed_addr #0 {
  br label %.preheader29

.preheader29:                                     ; preds = %0, %46
  %indvars.iv37 = phi i64 [ 1, %0 ], [ %indvars.iv.next38, %46 ]
  br label %.preheader

.preheader:                                       ; preds = %.preheader29, %.preheader
  %indvars.iv = phi i64 [ 1, %.preheader29 ], [ %indvars.iv.next, %.preheader ]
  %1 = getelementptr inbounds [32 x [32 x double]], ptr @uy, i64 0, i64 %indvars.iv37, i64 %indvars.iv
  store double 0.000000e+00, ptr %1, align 8, !tbaa !5
  %2 = getelementptr inbounds [32 x [32 x double]], ptr @ux, i64 0, i64 %indvars.iv37, i64 %indvars.iv
  store double 0.000000e+00, ptr %2, align 8, !tbaa !5
  %3 = getelementptr inbounds [32 x [32 x double]], ptr @rho, i64 0, i64 %indvars.iv37, i64 %indvars.iv
  store double 1.000000e+00, ptr %3, align 8, !tbaa !5
  %4 = tail call double @feq(i32 noundef 0, i32 noundef 0, double noundef 0.000000e+00, double noundef 0.000000e+00, double noundef 1.000000e+00)
  %5 = getelementptr inbounds [32 x [32 x [3 x [3 x double]]]], ptr @f, i64 0, i64 %indvars.iv37, i64 %indvars.iv, i64 0, i64 0
  store double %4, ptr %5, align 8, !tbaa !5
  %6 = load double, ptr %2, align 8, !tbaa !5
  %7 = load double, ptr %1, align 8, !tbaa !5
  %8 = load double, ptr %3, align 8, !tbaa !5
  %9 = tail call double @feq(i32 noundef 0, i32 noundef 1, double noundef %6, double noundef %7, double noundef %8)
  %10 = getelementptr inbounds [32 x [32 x [3 x [3 x double]]]], ptr @f, i64 0, i64 %indvars.iv37, i64 %indvars.iv, i64 0, i64 1
  store double %9, ptr %10, align 8, !tbaa !5
  %11 = load double, ptr %2, align 8, !tbaa !5
  %12 = load double, ptr %1, align 8, !tbaa !5
  %13 = load double, ptr %3, align 8, !tbaa !5
  %14 = tail call double @feq(i32 noundef 0, i32 noundef 2, double noundef %11, double noundef %12, double noundef %13)
  %15 = getelementptr inbounds [32 x [32 x [3 x [3 x double]]]], ptr @f, i64 0, i64 %indvars.iv37, i64 %indvars.iv, i64 0, i64 2
  store double %14, ptr %15, align 8, !tbaa !5
  %16 = load double, ptr %2, align 8, !tbaa !5
  %17 = load double, ptr %1, align 8, !tbaa !5
  %18 = load double, ptr %3, align 8, !tbaa !5
  %19 = tail call double @feq(i32 noundef 1, i32 noundef 0, double noundef %16, double noundef %17, double noundef %18)
  %20 = getelementptr inbounds [32 x [32 x [3 x [3 x double]]]], ptr @f, i64 0, i64 %indvars.iv37, i64 %indvars.iv, i64 1, i64 0
  store double %19, ptr %20, align 8, !tbaa !5
  %21 = load double, ptr %2, align 8, !tbaa !5
  %22 = load double, ptr %1, align 8, !tbaa !5
  %23 = load double, ptr %3, align 8, !tbaa !5
  %24 = tail call double @feq(i32 noundef 1, i32 noundef 1, double noundef %21, double noundef %22, double noundef %23)
  %25 = getelementptr inbounds [32 x [32 x [3 x [3 x double]]]], ptr @f, i64 0, i64 %indvars.iv37, i64 %indvars.iv, i64 1, i64 1
  store double %24, ptr %25, align 8, !tbaa !5
  %26 = load double, ptr %2, align 8, !tbaa !5
  %27 = load double, ptr %1, align 8, !tbaa !5
  %28 = load double, ptr %3, align 8, !tbaa !5
  %29 = tail call double @feq(i32 noundef 1, i32 noundef 2, double noundef %26, double noundef %27, double noundef %28)
  %30 = getelementptr inbounds [32 x [32 x [3 x [3 x double]]]], ptr @f, i64 0, i64 %indvars.iv37, i64 %indvars.iv, i64 1, i64 2
  store double %29, ptr %30, align 8, !tbaa !5
  %31 = load double, ptr %2, align 8, !tbaa !5
  %32 = load double, ptr %1, align 8, !tbaa !5
  %33 = load double, ptr %3, align 8, !tbaa !5
  %34 = tail call double @feq(i32 noundef 2, i32 noundef 0, double noundef %31, double noundef %32, double noundef %33)
  %35 = getelementptr inbounds [32 x [32 x [3 x [3 x double]]]], ptr @f, i64 0, i64 %indvars.iv37, i64 %indvars.iv, i64 2, i64 0
  store double %34, ptr %35, align 8, !tbaa !5
  %36 = load double, ptr %2, align 8, !tbaa !5
  %37 = load double, ptr %1, align 8, !tbaa !5
  %38 = load double, ptr %3, align 8, !tbaa !5
  %39 = tail call double @feq(i32 noundef 2, i32 noundef 1, double noundef %36, double noundef %37, double noundef %38)
  %40 = getelementptr inbounds [32 x [32 x [3 x [3 x double]]]], ptr @f, i64 0, i64 %indvars.iv37, i64 %indvars.iv, i64 2, i64 1
  store double %39, ptr %40, align 8, !tbaa !5
  %41 = load double, ptr %2, align 8, !tbaa !5
  %42 = load double, ptr %1, align 8, !tbaa !5
  %43 = load double, ptr %3, align 8, !tbaa !5
  %44 = tail call double @feq(i32 noundef 2, i32 noundef 2, double noundef %41, double noundef %42, double noundef %43)
  %45 = getelementptr inbounds [32 x [32 x [3 x [3 x double]]]], ptr @f, i64 0, i64 %indvars.iv37, i64 %indvars.iv, i64 2, i64 2
  store double %44, ptr %45, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 31
  br i1 %exitcond.not, label %46, label %.preheader, !llvm.loop !9

46:                                               ; preds = %.preheader
  %indvars.iv.next38 = add nuw nsw i64 %indvars.iv37, 1
  %exitcond40.not = icmp eq i64 %indvars.iv.next38, 31
  br i1 %exitcond40.not, label %47, label %.preheader29, !llvm.loop !11

47:                                               ; preds = %46
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local double @feq(i32 noundef, i32 noundef, double noundef, double noundef, double noundef) local_unnamed_addr #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, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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