; LLVM IR from libtcod/libtcod :: src/libtcod (path_c)

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

@.str.1 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [54 x i8], align 1
@__PRETTY_FUNCTION__.TCOD_dijkstra_new_using_function = external hidden unnamed_addr constant [91 x i8], align 1

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

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

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #3

declare ptr @TCOD_list_new() #4

; Function Attrs: nounwind uwtable
define dso_local ptr @TCOD_dijkstra_new_using_function(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, float noundef %4) #5 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca float, align 4
  %11 = alloca ptr, align 8
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !9
  store float %4, ptr %10, align 4, !tbaa !11
  %12 = load ptr, ptr %8, align 8, !tbaa !9
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %21

14:                                               ; preds = %5
  %15 = load i32, ptr %6, align 4, !tbaa !5
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %17, label %21

17:                                               ; preds = %14
  %18 = load i32, ptr %7, align 4, !tbaa !5
  %19 = icmp sgt i32 %18, 0
  br i1 %19, label %20, label %21

20:                                               ; preds = %17
  br label %22

21:                                               ; preds = %17, %14, %5
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 471, ptr noundef @__PRETTY_FUNCTION__.TCOD_dijkstra_new_using_function) #6
  unreachable

22:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %23 = call noalias ptr @malloc(i64 noundef 64) #8
  store ptr %23, ptr %11, align 8, !tbaa !9
  %24 = load ptr, ptr %11, align 8, !tbaa !9
  %25 = getelementptr inbounds %struct.TCOD_Dijkstra, ptr %24, i32 0, i32 4
  store ptr null, ptr %25, align 8, !tbaa !13
  %26 = load ptr, ptr %8, align 8, !tbaa !9
  %27 = load ptr, ptr %11, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct.TCOD_Dijkstra, ptr %27, i32 0, i32 5
  store ptr %26, ptr %28, align 8, !tbaa !15
  %29 = load ptr, ptr %9, align 8, !tbaa !9
  %30 = load ptr, ptr %11, align 8, !tbaa !9
  %31 = getelementptr inbounds %struct.TCOD_Dijkstra, ptr %30, i32 0, i32 6
  store ptr %29, ptr %31, align 8, !tbaa !16
  %32 = load i32, ptr %6, align 4, !tbaa !5
  %33 = load i32, ptr %7, align 4, !tbaa !5
  %34 = mul nsw i32 %32, %33
  %35 = sext i32 %34 to i64
  %36 = mul i64 %35, 4
  %37 = mul i64 %36, 4
  %38 = call noalias ptr @malloc(i64 noundef %37) #8
  %39 = load ptr, ptr %11, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct.TCOD_Dijkstra, ptr %39, i32 0, i32 7
  store ptr %38, ptr %40, align 8, !tbaa !17
  %41 = load i32, ptr %6, align 4, !tbaa !5
  %42 = load i32, ptr %7, align 4, !tbaa !5
  %43 = mul nsw i32 %41, %42
  %44 = sext i32 %43 to i64
  %45 = mul i64 %44, 4
  %46 = mul i64 %45, 4
  %47 = call noalias ptr @malloc(i64 noundef %46) #8
  %48 = load ptr, ptr %11, align 8, !tbaa !9
  %49 = getelementptr inbounds %struct.TCOD_Dijkstra, ptr %48, i32 0, i32 8
  store ptr %47, ptr %49, align 8, !tbaa !18
  %50 = load float, ptr %10, align 4, !tbaa !11
  %51 = call float @llvm.fmuladd.f32(float %50, float 1.000000e+02, float 0x3FB99999A0000000)
  %52 = fptosi float %51 to i32
  %53 = load ptr, ptr %11, align 8, !tbaa !9
  %54 = getelementptr inbounds %struct.TCOD_Dijkstra, ptr %53, i32 0, i32 0
  store i32 %52, ptr %54, align 8, !tbaa !19
  %55 = load i32, ptr %6, align 4, !tbaa !5
  %56 = load ptr, ptr %11, align 8, !tbaa !9
  %57 = getelementptr inbounds %struct.TCOD_Dijkstra, ptr %56, i32 0, i32 1
  store i32 %55, ptr %57, align 4, !tbaa !20
  %58 = load i32, ptr %7, align 4, !tbaa !5
  %59 = load ptr, ptr %11, align 8, !tbaa !9
  %60 = getelementptr inbounds %struct.TCOD_Dijkstra, ptr %59, i32 0, i32 2
  store i32 %58, ptr %60, align 8, !tbaa !21
  %61 = load i32, ptr %6, align 4, !tbaa !5
  %62 = load i32, ptr %7, align 4, !tbaa !5
  %63 = mul nsw i32 %61, %62
  %64 = load ptr, ptr %11, align 8, !tbaa !9
  %65 = getelementptr inbounds %struct.TCOD_Dijkstra, ptr %64, i32 0, i32 3
  store i32 %63, ptr %65, align 4, !tbaa !22
  %66 = call ptr @TCOD_list_new()
  %67 = load ptr, ptr %11, align 8, !tbaa !9
  %68 = getelementptr inbounds %struct.TCOD_Dijkstra, ptr %67, i32 0, i32 9
  store ptr %66, ptr %68, align 8, !tbaa !23
  %69 = load ptr, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  ret ptr %69
}

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { "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 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 #6 = { noreturn nounwind }
attributes #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }

!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, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !10, i64 16}
!14 = !{!"TCOD_Dijkstra", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56}
!15 = !{!14, !10, i64 24}
!16 = !{!14, !10, i64 32}
!17 = !{!14, !10, i64 40}
!18 = !{!14, !10, i64 48}
!19 = !{!14, !6, i64 0}
!20 = !{!14, !6, i64 4}
!21 = !{!14, !6, i64 8}
!22 = !{!14, !6, i64 12}
!23 = !{!14, !10, i64 56}


; 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.1 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [54 x i8], align 1
@__PRETTY_FUNCTION__.TCOD_dijkstra_new_using_function = external hidden unnamed_addr constant [91 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #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 speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

declare ptr @TCOD_list_new() local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @TCOD_dijkstra_new_using_function(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, float noundef %4) local_unnamed_addr #4 {
  %6 = icmp ne ptr %2, null
  %7 = icmp sgt i32 %0, 0
  %or.cond = and i1 %7, %6
  %8 = icmp sgt i32 %1, 0
  %or.cond3 = and i1 %8, %or.cond
  br i1 %or.cond3, label %10, label %9

9:                                                ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 471, ptr noundef nonnull @__PRETTY_FUNCTION__.TCOD_dijkstra_new_using_function) #5
  unreachable

10:                                               ; preds = %5
  %11 = tail call noalias dereferenceable_or_null(64) ptr @malloc(i64 noundef 64) #6
  %12 = getelementptr inbounds i8, ptr %11, i64 16
  store ptr null, ptr %12, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %11, i64 24
  store ptr %2, ptr %13, align 8, !tbaa !11
  %14 = getelementptr inbounds i8, ptr %11, i64 32
  store ptr %3, ptr %14, align 8, !tbaa !12
  %15 = mul nuw nsw i32 %1, %0
  %16 = zext nneg i32 %15 to i64
  %17 = shl nuw nsw i64 %16, 4
  %18 = tail call noalias ptr @malloc(i64 noundef %17) #6
  %19 = getelementptr inbounds i8, ptr %11, i64 40
  store ptr %18, ptr %19, align 8, !tbaa !13
  %20 = tail call noalias ptr @malloc(i64 noundef %17) #6
  %21 = getelementptr inbounds i8, ptr %11, i64 48
  store ptr %20, ptr %21, align 8, !tbaa !14
  %22 = tail call float @llvm.fmuladd.f32(float %4, float 1.000000e+02, float 0x3FB99999A0000000)
  %23 = fptosi float %22 to i32
  store i32 %23, ptr %11, align 8, !tbaa !15
  %24 = getelementptr inbounds i8, ptr %11, i64 4
  store i32 %0, ptr %24, align 4, !tbaa !16
  %25 = getelementptr inbounds i8, ptr %11, i64 8
  store i32 %1, ptr %25, align 8, !tbaa !17
  %26 = getelementptr inbounds i8, ptr %11, i64 12
  store i32 %15, ptr %26, align 4, !tbaa !18
  %27 = tail call ptr @TCOD_list_new() #7
  %28 = getelementptr inbounds i8, ptr %11, i64 56
  store ptr %27, ptr %28, align 8, !tbaa !19
  ret ptr %11
}

attributes #0 = { 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 #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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { "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 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 #5 = { noreturn nounwind }
attributes #6 = { nounwind allocsize(0) }
attributes #7 = { 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, !10, i64 16}
!6 = !{!"TCOD_Dijkstra", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 24}
!12 = !{!6, !10, i64 32}
!13 = !{!6, !10, i64 40}
!14 = !{!6, !10, i64 48}
!15 = !{!6, !7, i64 0}
!16 = !{!6, !7, i64 4}
!17 = !{!6, !7, i64 8}
!18 = !{!6, !7, i64 12}
!19 = !{!6, !10, i64 56}


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