; LLVM IR from palatinuse/database-vertical-partitioning :: lib/metis/Programs (io)

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

@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [39 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

declare noalias ptr @fopen(ptr noundef, ptr noundef) #1

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #2

declare void @__errexit(ptr noundef, ...) #1

declare ptr @__idxmalloc(i32 noundef, ptr noundef) #1

declare i32 @fclose(ptr noundef) #1

; 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 ptr @ReadMesh(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #3 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %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 ptr, align 8
  %14 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  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) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = call noalias ptr @fopen(ptr noundef %15, ptr noundef @.str)
  store ptr %16, ptr %14, align 8, !tbaa !5
  %17 = icmp eq ptr %16, null
  br i1 %17, label %18, label %21

18:                                               ; preds = %4
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, ptr noundef %19)
  call void @exit(i32 noundef 0) #5
  unreachable

21:                                               ; preds = %4
  %22 = load ptr, ptr %14, align 8, !tbaa !5
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %22, ptr noundef @.str.32, ptr noundef %23, ptr noundef %24)
  %26 = icmp ne i32 %25, 2
  br i1 %26, label %27, label %29

27:                                               ; preds = %21
  %28 = call i32 (ptr, ...) @printf(ptr noundef @.str.33)
  call void @exit(i32 noundef 0) #5
  unreachable

29:                                               ; preds = %21
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = load i32, ptr %30, align 4, !tbaa !9
  switch i32 %31, label %36 [
    i32 1, label %32
    i32 2, label %33
    i32 3, label %34
    i32 4, label %35
  ]

32:                                               ; preds = %29
  store i32 3, ptr %12, align 4, !tbaa !9
  br label %39

33:                                               ; preds = %29
  store i32 4, ptr %12, align 4, !tbaa !9
  br label %39

34:                                               ; preds = %29
  store i32 8, ptr %12, align 4, !tbaa !9
  br label %39

35:                                               ; preds = %29
  store i32 4, ptr %12, align 4, !tbaa !9
  br label %39

36:                                               ; preds = %29
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = load i32, ptr %37, align 4, !tbaa !9
  call void (ptr, ...) @__errexit(ptr noundef @.str.34, i32 noundef %38)
  br label %39

39:                                               ; preds = %36, %35, %34, %33, %32
  %40 = load i32, ptr %12, align 4, !tbaa !9
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = load i32, ptr %41, align 4, !tbaa !9
  %43 = mul nsw i32 %40, %42
  %44 = call ptr @__idxmalloc(i32 noundef %43, ptr noundef @.str.35)
  store ptr %44, ptr %13, align 8, !tbaa !5
  %45 = load i32, ptr %12, align 4, !tbaa !9
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = load i32, ptr %46, align 4, !tbaa !9
  %48 = mul nsw i32 %45, %47
  store i32 %48, ptr %10, align 4, !tbaa !9
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %49

49:                                               ; preds = %77, %39
  %50 = load i32, ptr %9, align 4, !tbaa !9
  %51 = load i32, ptr %10, align 4, !tbaa !9
  %52 = icmp slt i32 %50, %51
  br i1 %52, label %53, label %80

53:                                               ; preds = %49
  %54 = load ptr, ptr %14, align 8, !tbaa !5
  %55 = load ptr, ptr %13, align 8, !tbaa !5
  %56 = load i32, ptr %9, align 4, !tbaa !9
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds i32, ptr %55, i64 %57
  %59 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %54, ptr noundef @.str.36, ptr noundef %58)
  %60 = icmp ne i32 %59, 1
  br i1 %60, label %61, label %70

61:                                               ; preds = %53
  %62 = load i32, ptr %9, align 4, !tbaa !9
  %63 = load i32, ptr %12, align 4, !tbaa !9
  %64 = srem i32 %62, %63
  %65 = add nsw i32 %64, 1
  %66 = load i32, ptr %9, align 4, !tbaa !9
  %67 = load i32, ptr %12, align 4, !tbaa !9
  %68 = sdiv i32 %66, %67
  %69 = call i32 (ptr, ...) @printf(ptr noundef @.str.37, i32 noundef %65, i32 noundef %68)
  call void @exit(i32 noundef 0) #5
  unreachable

70:                                               ; preds = %53
  %71 = load ptr, ptr %13, align 8, !tbaa !5
  %72 = load i32, ptr %9, align 4, !tbaa !9
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds i32, ptr %71, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !9
  %76 = add nsw i32 %75, -1
  store i32 %76, ptr %74, align 4, !tbaa !9
  br label %77

77:                                               ; preds = %70
  %78 = load i32, ptr %9, align 4, !tbaa !9
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %9, align 4, !tbaa !9
  br label %49, !llvm.loop !11

80:                                               ; preds = %49
  %81 = load ptr, ptr %14, align 8, !tbaa !5
  %82 = call i32 @fclose(ptr noundef %81)
  %83 = load ptr, ptr %13, align 8, !tbaa !5
  %84 = load i32, ptr %10, align 4, !tbaa !9
  %85 = load ptr, ptr %13, align 8, !tbaa !5
  %86 = call i32 @__idxamax(i32 noundef %84, ptr noundef %85)
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds i32, ptr %83, i64 %87
  %89 = load i32, ptr %88, align 4, !tbaa !9
  %90 = add nsw i32 %89, 1
  %91 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 %90, ptr %91, align 4, !tbaa !9
  %92 = load ptr, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  ret ptr %92
}

declare i32 @__isoc99_fscanf(ptr noundef, ptr noundef, ...) #1

declare i32 @__idxamax(i32 noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 "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 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 #4 = { nounwind }
attributes #5 = { noreturn 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 = distinct !{!11, !12}
!12 = !{!"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"

@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [39 x i8], align 1
@switch.table.ReadMesh = private unnamed_addr constant [4 x i32] [i32 3, i32 4, i32 8, i32 4], align 4

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #0

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #1

declare void @__errexit(ptr noundef, ...) local_unnamed_addr #2

declare ptr @__idxmalloc(i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @ReadMesh(ptr noundef %0, ptr noundef %1, ptr nocapture noundef writeonly %2, ptr noundef %3) local_unnamed_addr #3 {
  %5 = tail call noalias ptr @fopen(ptr noundef %0, ptr noundef nonnull @.str)
  %6 = icmp eq ptr %5, null
  br i1 %6, label %7, label %9

7:                                                ; preds = %4
  %8 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, ptr noundef %0)
  tail call void @exit(i32 noundef 0) #4
  unreachable

9:                                                ; preds = %4
  %10 = tail call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %5, ptr noundef nonnull @.str.32, ptr noundef %1, ptr noundef %3) #5
  %.not = icmp eq i32 %10, 2
  br i1 %.not, label %13, label %11

11:                                               ; preds = %9
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.33)
  tail call void @exit(i32 noundef 0) #4
  unreachable

13:                                               ; preds = %9
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %switch.tableidx = add i32 %14, -1
  %15 = icmp ult i32 %switch.tableidx, 4
  br i1 %15, label %switch.lookup, label %16

16:                                               ; preds = %13
  tail call void (ptr, ...) @__errexit(ptr noundef nonnull @.str.34, i32 noundef %14) #5
  br label %18

switch.lookup:                                    ; preds = %13
  %17 = zext nneg i32 %switch.tableidx to i64
  %switch.gep = getelementptr inbounds [4 x i32], ptr @switch.table.ReadMesh, i64 0, i64 %17
  %switch.load = load i32, ptr %switch.gep, align 4
  br label %18

18:                                               ; preds = %switch.lookup, %16
  %.028 = phi i32 [ undef, %16 ], [ %switch.load, %switch.lookup ]
  %19 = load i32, ptr %1, align 4, !tbaa !5
  %20 = mul nsw i32 %19, %.028
  %21 = tail call ptr @__idxmalloc(i32 noundef %20, ptr noundef nonnull @.str.35) #5
  %22 = load i32, ptr %1, align 4, !tbaa !5
  %23 = mul nsw i32 %22, %.028
  %24 = icmp sgt i32 %23, 0
  br i1 %24, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %18
  %wide.trip.count = zext nneg i32 %23 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %33
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %33 ]
  %25 = getelementptr inbounds i32, ptr %21, i64 %indvars.iv
  %26 = tail call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %5, ptr noundef nonnull @.str.36, ptr noundef %25) #5
  %.not31 = icmp eq i32 %26, 1
  br i1 %.not31, label %33, label %27

27:                                               ; preds = %.lr.ph
  %28 = trunc nuw nsw i64 %indvars.iv to i32
  %29 = srem i32 %28, %.028
  %30 = add nuw nsw i32 %29, 1
  %31 = sdiv i32 %28, %.028
  %32 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.37, i32 noundef %30, i32 noundef %31)
  tail call void @exit(i32 noundef 0) #4
  unreachable

33:                                               ; preds = %.lr.ph
  %34 = load i32, ptr %25, align 4, !tbaa !5
  %35 = add nsw i32 %34, -1
  store i32 %35, ptr %25, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %33, %18
  %36 = tail call i32 @fclose(ptr noundef nonnull %5)
  %37 = tail call i32 @__idxamax(i32 noundef %23, ptr noundef %21) #5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i32, ptr %21, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %2, align 4, !tbaa !5
  ret ptr %21
}

declare i32 @__isoc99_fscanf(ptr noundef, ptr noundef, ...) local_unnamed_addr #2

declare i32 @__idxamax(i32 noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { 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 #1 = { noreturn 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 = { "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 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 #4 = { noreturn nounwind }
attributes #5 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass