; LLVM IR from logicchains/LPATHBench :: c_fast (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.timeval = type { i64, i64 }

@.str.3 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [16 x i8], align 1
@__PRETTY_FUNCTION__.main = external hidden unnamed_addr constant [11 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [25 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: nounwind allocsize(0)
declare noalias ptr @malloc(i64 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
declare dso_local void @parse_graph(ptr noundef, ptr noundef) #2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @get_max_cost_small(ptr noundef, i32 noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @get_max_cost(ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca %struct.timeval, align 8
  %6 = alloca %struct.timeval, align 8
  %7 = alloca %struct.timeval, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  call void @parse_graph(ptr noundef %8, ptr noundef %9)
  %10 = call i32 @gettimeofday(ptr noundef %5, ptr noundef null) #6
  %11 = load i32, ptr %9, align 4, !tbaa !5
  %12 = icmp sgt i32 %11, 32
  br i1 %12, label %13, label %28

13:                                               ; preds = %0
  %14 = load i32, ptr %9, align 4, !tbaa !5
  %15 = ashr i32 %14, 5
  %16 = add nsw i32 %15, 1
  %17 = sext i32 %16 to i64
  %18 = mul i64 4, %17
  %19 = call noalias ptr @malloc(i64 noundef %18) #7
  store ptr %19, ptr %3, align 8, !tbaa !9
  %20 = load ptr, ptr %3, align 8, !tbaa !9
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %23

22:                                               ; preds = %13
  br label %24

23:                                               ; preds = %13
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.3, i32 noundef 168, ptr noundef @__PRETTY_FUNCTION__.main) #8
  unreachable

24:                                               ; preds = %22
  %25 = load ptr, ptr %8, align 8, !tbaa !9
  %26 = load ptr, ptr %3, align 8, !tbaa !9
  %27 = call i32 @get_max_cost(ptr noundef %25, i32 noundef 0, ptr noundef %26)
  store i32 %27, ptr %2, align 4, !tbaa !5
  br label %31

28:                                               ; preds = %0
  %29 = load ptr, ptr %8, align 8, !tbaa !9
  %30 = call i32 @get_max_cost_small(ptr noundef %29, i32 noundef 0, i32 noundef 0)
  store i32 %30, ptr %2, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %28, %24
  %32 = call i32 @gettimeofday(ptr noundef %6, ptr noundef null) #6
  br label %33

33:                                               ; preds = %31
  %34 = getelementptr inbounds %struct.timeval, ptr %6, i32 0, i32 0
  %35 = load i64, ptr %34, align 8, !tbaa !11
  %36 = getelementptr inbounds %struct.timeval, ptr %5, i32 0, i32 0
  %37 = load i64, ptr %36, align 8, !tbaa !11
  %38 = sub nsw i64 %35, %37
  %39 = getelementptr inbounds %struct.timeval, ptr %7, i32 0, i32 0
  store i64 %38, ptr %39, align 8, !tbaa !11
  %40 = getelementptr inbounds %struct.timeval, ptr %6, i32 0, i32 1
  %41 = load i64, ptr %40, align 8, !tbaa !14
  %42 = getelementptr inbounds %struct.timeval, ptr %5, i32 0, i32 1
  %43 = load i64, ptr %42, align 8, !tbaa !14
  %44 = sub nsw i64 %41, %43
  %45 = getelementptr inbounds %struct.timeval, ptr %7, i32 0, i32 1
  store i64 %44, ptr %45, align 8, !tbaa !14
  %46 = getelementptr inbounds %struct.timeval, ptr %7, i32 0, i32 1
  %47 = load i64, ptr %46, align 8, !tbaa !14
  %48 = icmp slt i64 %47, 0
  br i1 %48, label %49, label %56

49:                                               ; preds = %33
  %50 = getelementptr inbounds %struct.timeval, ptr %7, i32 0, i32 0
  %51 = load i64, ptr %50, align 8, !tbaa !11
  %52 = add nsw i64 %51, -1
  store i64 %52, ptr %50, align 8, !tbaa !11
  %53 = getelementptr inbounds %struct.timeval, ptr %7, i32 0, i32 1
  %54 = load i64, ptr %53, align 8, !tbaa !14
  %55 = add nsw i64 %54, 1000000
  store i64 %55, ptr %53, align 8, !tbaa !14
  br label %56

56:                                               ; preds = %49, %33
  br label %57

57:                                               ; preds = %56
  br label %58

58:                                               ; preds = %57
  %59 = getelementptr inbounds %struct.timeval, ptr %7, i32 0, i32 0
  %60 = load i64, ptr %59, align 8, !tbaa !11
  %61 = mul nsw i64 %60, 1000
  %62 = getelementptr inbounds %struct.timeval, ptr %7, i32 0, i32 1
  %63 = load i64, ptr %62, align 8, !tbaa !14
  %64 = sdiv i64 %63, 1000
  %65 = add nsw i64 %61, %64
  store i64 %65, ptr %4, align 8, !tbaa !15
  %66 = load i32, ptr %2, align 4, !tbaa !5
  %67 = load i64, ptr %4, align 8, !tbaa !15
  %68 = call i32 (ptr, ...) @printf(ptr noundef @.str.11, i32 noundef %66, i64 noundef %67)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  %69 = load i32, ptr %1, align 4
  ret i32 %69
}

; Function Attrs: nounwind
declare i32 @gettimeofday(ptr noundef, ptr noundef) #4

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(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 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 #3 = { 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 #4 = { 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 #5 = { "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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { 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 = !{!"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, !13, i64 0}
!12 = !{!"timeval", !13, i64 0, !13, i64 8}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !13, i64 8}
!15 = !{!13, !13, i64 0}


; 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.timeval = type { i64, i64 }

@.str.3 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [16 x i8], align 1
@__PRETTY_FUNCTION__.main = external hidden unnamed_addr constant [11 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [25 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 nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; 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 void @parse_graph(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @get_max_cost_small(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @get_max_cost(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca %struct.timeval, align 8
  %2 = alloca %struct.timeval, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  call void @parse_graph(ptr noundef nonnull %3, ptr noundef nonnull %4)
  %5 = call i32 @gettimeofday(ptr noundef nonnull %1, ptr noundef null) #5
  %6 = load i32, ptr %4, align 4, !tbaa !5
  %7 = icmp sgt i32 %6, 32
  br i1 %7, label %8, label %18

8:                                                ; preds = %0
  %9 = lshr i32 %6, 3
  %10 = and i32 %9, 268435452
  %11 = add nuw nsw i32 %10, 4
  %12 = zext nneg i32 %11 to i64
  %13 = call noalias ptr @malloc(i64 noundef %12) #6
  %.not = icmp eq ptr %13, null
  br i1 %.not, label %14, label %15

14:                                               ; preds = %8
  call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.3, i32 noundef 168, ptr noundef nonnull @__PRETTY_FUNCTION__.main) #7
  unreachable

15:                                               ; preds = %8
  %16 = load ptr, ptr %3, align 8, !tbaa !9
  %17 = call i32 @get_max_cost(ptr noundef %16, i32 noundef 0, ptr noundef nonnull %13)
  br label %21

18:                                               ; preds = %0
  %19 = load ptr, ptr %3, align 8, !tbaa !9
  %20 = call i32 @get_max_cost_small(ptr noundef %19, i32 noundef 0, i32 noundef 0)
  br label %21

21:                                               ; preds = %18, %15
  %.0 = phi i32 [ %17, %15 ], [ %20, %18 ]
  %22 = call i32 @gettimeofday(ptr noundef nonnull %2, ptr noundef null) #5
  %23 = load i64, ptr %2, align 8, !tbaa !11
  %24 = load i64, ptr %1, align 8, !tbaa !11
  %25 = sub i64 %23, %24
  %26 = getelementptr inbounds i8, ptr %2, i64 8
  %27 = load i64, ptr %26, align 8, !tbaa !14
  %28 = getelementptr inbounds i8, ptr %1, i64 8
  %29 = load i64, ptr %28, align 8, !tbaa !14
  %30 = sub nsw i64 %27, %29
  %31 = icmp slt i64 %30, 0
  %32 = add nsw i64 %30, 1000000
  %.sroa.6.0 = select i1 %31, i64 %32, i64 %30
  %.lobit = ashr i64 %30, 63
  %.sroa.0.0 = add nsw i64 %25, %.lobit
  %33 = mul nsw i64 %.sroa.0.0, 1000
  %34 = sdiv i64 %.sroa.6.0, 1000
  %35 = add nsw i64 %33, %34
  %36 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, i32 noundef %.0, i64 noundef %35)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #5
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @gettimeofday(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #4

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 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 #3 = { 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }
attributes #7 = { 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 = !{!"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, !13, i64 0}
!12 = !{!"timeval", !13, i64 0, !13, i64 8}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !13, i64 8}


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