; 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_Path = type { i32, i32, i32, i32, ptr, i32, i32, ptr, ptr, ptr, float, 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_path_new_using_function = external hidden unnamed_addr constant [84 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: nounwind uwtable
declare hidden ptr @TCOD_path_new_intern(i32 noundef, i32 noundef) #2

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

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

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

19:                                               ; preds = %16
  %20 = load i32, ptr %8, align 4, !tbaa !5
  %21 = icmp sgt i32 %20, 0
  br i1 %21, label %22, label %23

22:                                               ; preds = %19
  br label %24

23:                                               ; preds = %19, %16, %5
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 255, ptr noundef @__PRETTY_FUNCTION__.TCOD_path_new_using_function) #3
  unreachable

24:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %25 = load i32, ptr %7, align 4, !tbaa !5
  %26 = load i32, ptr %8, align 4, !tbaa !5
  %27 = call ptr @TCOD_path_new_intern(i32 noundef %25, i32 noundef %26)
  store ptr %27, ptr %12, align 8, !tbaa !9
  %28 = load ptr, ptr %12, align 8, !tbaa !9
  %29 = icmp ne ptr %28, null
  br i1 %29, label %31, label %30

30:                                               ; preds = %24
  store ptr null, ptr %6, align 8
  store i32 1, ptr %13, align 4
  br label %42

31:                                               ; preds = %24
  %32 = load ptr, ptr %9, align 8, !tbaa !9
  %33 = load ptr, ptr %12, align 8, !tbaa !9
  %34 = getelementptr inbounds %struct.TCOD_Path, ptr %33, i32 0, i32 13
  store ptr %32, ptr %34, align 8, !tbaa !13
  %35 = load ptr, ptr %10, align 8, !tbaa !9
  %36 = load ptr, ptr %12, align 8, !tbaa !9
  %37 = getelementptr inbounds %struct.TCOD_Path, ptr %36, i32 0, i32 14
  store ptr %35, ptr %37, align 8, !tbaa !15
  %38 = load float, ptr %11, align 4, !tbaa !11
  %39 = load ptr, ptr %12, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct.TCOD_Path, ptr %39, i32 0, i32 10
  store float %38, ptr %40, align 8, !tbaa !16
  %41 = load ptr, ptr %12, align 8, !tbaa !9
  store ptr %41, ptr %6, align 8
  store i32 1, ptr %13, align 4
  br label %42

42:                                               ; preds = %31, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  %43 = load ptr, ptr %6, align 8
  ret ptr %43
}

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 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 }
attributes #4 = { 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, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !10, i64 80}
!14 = !{!"TCOD_Path", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !10, i64 16, !6, i64 24, !6, i64 28, !10, i64 32, !10, i64 40, !10, i64 48, !12, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88}
!15 = !{!14, !10, i64 88}
!16 = !{!14, !12, 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_path_new_using_function = external hidden unnamed_addr constant [84 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: nounwind uwtable
declare hidden ptr @TCOD_path_new_intern(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @TCOD_path_new_using_function(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, float noundef %4) local_unnamed_addr #1 {
  %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 255, ptr noundef nonnull @__PRETTY_FUNCTION__.TCOD_path_new_using_function) #2
  unreachable

10:                                               ; preds = %5
  %11 = tail call ptr @TCOD_path_new_intern(i32 noundef %0, i32 noundef %1)
  %.not = icmp eq ptr %11, null
  br i1 %.not, label %16, label %12

12:                                               ; preds = %10
  %13 = getelementptr inbounds i8, ptr %11, i64 80
  store ptr %2, ptr %13, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %11, i64 88
  store ptr %3, ptr %14, align 8, !tbaa !12
  %15 = getelementptr inbounds i8, ptr %11, i64 56
  store float %4, ptr %15, align 8, !tbaa !13
  br label %16

16:                                               ; preds = %10, %12
  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 = { 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 = { 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, !10, i64 80}
!6 = !{!"TCOD_Path", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !7, i64 24, !7, i64 28, !10, i64 32, !10, i64 40, !10, i64 48, !11, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!6, !10, i64 88}
!13 = !{!6, !11, i64 56}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass