; LLVM IR from bkaradzic/bgfx :: 3rdparty/fcpp (cpp6)

; 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.Global = type { i32, i32, ptr, ptr, i32, i32, i32, ptr, i32, i32, i32, i32, [513 x i8], ptr, i8, i8, i8, i8, i8, [32 x i8], ptr, [20 x ptr], ptr, [20 x ptr], [20 x i8], i32, [5 x ptr], [5 x ptr], i8, ptr, [1025 x i8], ptr, [31 x ptr], i32, ptr, [64 x ptr], i32, ptr, ptr, ptr, ptr, ptr, ptr, i8, i8, i8, i8, i8, i8, i8, i8, ptr, i64, i8, i8, i8, i8, i8, i8, ptr, [20 x ptr], i32, i8, i8, i8, ptr }
%struct.fileinfo = type { ptr, i32, ptr, ptr, ptr, ptr, i32, [1 x i8] }

@.str.2 = external hidden unnamed_addr constant [8 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: 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 ptr @fpp_savestring(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local i32 @fpp_getfile(ptr noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i64 %1, ptr %7, align 8, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %12 = load ptr, ptr %8, align 8, !tbaa !5
  %13 = call i64 @strlen(ptr noundef %12) #5
  store i64 %13, ptr %10, align 8, !tbaa !9
  %14 = load i64, ptr %10, align 8, !tbaa !9
  %15 = icmp ne i64 %14, 0
  br i1 %15, label %19, label %16

16:                                               ; preds = %4
  store ptr @.str.2, ptr %8, align 8, !tbaa !5
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = call i64 @strlen(ptr noundef %17) #5
  store i64 %18, ptr %10, align 8, !tbaa !9
  br label %19

19:                                               ; preds = %16, %4
  %20 = load i64, ptr %7, align 8, !tbaa !9
  %21 = add i64 56, %20
  %22 = load i64, ptr %10, align 8, !tbaa !9
  %23 = add i64 %21, %22
  %24 = trunc i64 %23 to i32
  %25 = sext i32 %24 to i64
  %26 = call noalias ptr @malloc(i64 noundef %25) #6
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %26, ptr %27, align 8, !tbaa !5
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = load ptr, ptr %28, align 8, !tbaa !5
  %30 = icmp ne ptr %29, null
  br i1 %30, label %32, label %31

31:                                               ; preds = %19
  store i32 1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %87

32:                                               ; preds = %19
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.Global, ptr %33, i32 0, i32 7
  %35 = load ptr, ptr %34, align 8, !tbaa !11
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  %37 = load ptr, ptr %36, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.fileinfo, ptr %37, i32 0, i32 3
  store ptr %35, ptr %38, align 8, !tbaa !14
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = load ptr, ptr %39, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.fileinfo, ptr %40, i32 0, i32 2
  store ptr null, ptr %41, align 8, !tbaa !16
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = call ptr @fpp_savestring(ptr noundef %42, ptr noundef %43)
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = load ptr, ptr %45, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.fileinfo, ptr %46, i32 0, i32 4
  store ptr %44, ptr %47, align 8, !tbaa !17
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = load ptr, ptr %48, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.fileinfo, ptr %49, i32 0, i32 5
  store ptr null, ptr %50, align 8, !tbaa !18
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = load ptr, ptr %51, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.fileinfo, ptr %52, i32 0, i32 6
  store i32 0, ptr %53, align 8, !tbaa !19
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = load ptr, ptr %54, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.fileinfo, ptr %55, i32 0, i32 7
  %57 = getelementptr inbounds [1 x i8], ptr %56, i64 0, i64 0
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = load ptr, ptr %58, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.fileinfo, ptr %59, i32 0, i32 0
  store ptr %57, ptr %60, align 8, !tbaa !20
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = load ptr, ptr %61, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.fileinfo, ptr %62, i32 0, i32 7
  %64 = getelementptr inbounds [1 x i8], ptr %63, i64 0, i64 0
  store i8 0, ptr %64, align 4, !tbaa !21
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  %66 = load ptr, ptr %65, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.fileinfo, ptr %66, i32 0, i32 1
  store i32 0, ptr %67, align 8, !tbaa !22
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.Global, ptr %68, i32 0, i32 7
  %70 = load ptr, ptr %69, align 8, !tbaa !11
  %71 = icmp ne ptr %70, null
  br i1 %71, label %72, label %80

72:                                               ; preds = %32
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.Global, ptr %73, i32 0, i32 0
  %75 = load i32, ptr %74, align 8, !tbaa !23
  %76 = load ptr, ptr %6, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.Global, ptr %76, i32 0, i32 7
  %78 = load ptr, ptr %77, align 8, !tbaa !11
  %79 = getelementptr inbounds %struct.fileinfo, ptr %78, i32 0, i32 1
  store i32 %75, ptr %79, align 8, !tbaa !22
  br label %80

80:                                               ; preds = %72, %32
  %81 = load ptr, ptr %9, align 8, !tbaa !5
  %82 = load ptr, ptr %81, align 8, !tbaa !5
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.Global, ptr %83, i32 0, i32 7
  store ptr %82, ptr %84, align 8, !tbaa !11
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.Global, ptr %85, i32 0, i32 0
  store i32 1, ptr %86, align 8, !tbaa !23
  store i32 0, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %87

87:                                               ; preds = %80, %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %88 = load i32, ptr %5, align 4
  ret i32 %88
}

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 willreturn memory(read) "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 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 #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }
attributes #6 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 40}
!12 = !{!"Global", !13, i64 0, !13, i64 4, !6, i64 8, !6, i64 16, !13, i64 24, !13, i64 28, !13, i64 32, !6, i64 40, !13, i64 48, !13, i64 52, !13, i64 56, !13, i64 60, !7, i64 64, !6, i64 584, !7, i64 592, !7, i64 593, !7, i64 594, !7, i64 595, !7, i64 596, !7, i64 597, !6, i64 632, !7, i64 640, !6, i64 800, !7, i64 808, !7, i64 968, !13, i64 988, !7, i64 992, !7, i64 1032, !7, i64 1072, !6, i64 1080, !7, i64 1088, !6, i64 2120, !7, i64 2128, !13, i64 2376, !6, i64 2384, !7, i64 2392, !13, i64 2904, !6, i64 2912, !6, i64 2920, !6, i64 2928, !6, i64 2936, !6, i64 2944, !6, i64 2952, !7, i64 2960, !7, i64 2961, !7, i64 2962, !7, i64 2963, !7, i64 2964, !7, i64 2965, !7, i64 2966, !7, i64 2967, !6, i64 2968, !10, i64 2976, !7, i64 2984, !7, i64 2985, !7, i64 2986, !7, i64 2987, !7, i64 2988, !7, i64 2989, !6, i64 2992, !7, i64 3000, !13, i64 3160, !7, i64 3164, !7, i64 3165, !7, i64 3166, !6, i64 3168}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !6, i64 24}
!15 = !{!"fileinfo", !6, i64 0, !13, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !13, i64 48, !7, i64 52}
!16 = !{!15, !6, i64 16}
!17 = !{!15, !6, i64 32}
!18 = !{!15, !6, i64 40}
!19 = !{!15, !13, i64 48}
!20 = !{!15, !6, i64 0}
!21 = !{!7, !7, i64 0}
!22 = !{!15, !13, i64 8}
!23 = !{!12, !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"

@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @fpp_savestring(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @fpp_getfile(ptr noundef %0, i64 noundef %1, ptr noundef %2, ptr nocapture noundef %3) local_unnamed_addr #0 {
  %5 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %2) #3
  %.not = icmp eq i64 %5, 0
  br i1 %.not, label %6, label %8

6:                                                ; preds = %4
  %7 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) @.str.2) #3
  br label %8

8:                                                ; preds = %6, %4
  %.026 = phi ptr [ %2, %4 ], [ @.str.2, %6 ]
  %.0 = phi i64 [ %5, %4 ], [ %7, %6 ]
  %9 = add i64 %1, 56
  %10 = add i64 %9, %.0
  %sext = shl i64 %10, 32
  %11 = ashr exact i64 %sext, 32
  %12 = tail call noalias ptr @malloc(i64 noundef %11) #4
  store ptr %12, ptr %3, align 8, !tbaa !5
  %.not30 = icmp eq ptr %12, null
  br i1 %.not30, label %35, label %13

13:                                               ; preds = %8
  %14 = getelementptr inbounds i8, ptr %0, i64 40
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = getelementptr inbounds i8, ptr %12, i64 24
  store ptr %15, ptr %16, align 8, !tbaa !13
  %17 = getelementptr inbounds i8, ptr %12, i64 16
  store ptr null, ptr %17, align 8, !tbaa !15
  %18 = tail call ptr @fpp_savestring(ptr noundef %0, ptr noundef %.026)
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %19, i64 32
  store ptr %18, ptr %20, align 8, !tbaa !16
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %21, i64 40
  store ptr null, ptr %22, align 8, !tbaa !17
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %23, i64 48
  store i32 0, ptr %24, align 8, !tbaa !18
  %25 = getelementptr inbounds i8, ptr %23, i64 52
  store ptr %25, ptr %23, align 8, !tbaa !19
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %26, i64 52
  store i8 0, ptr %27, align 4, !tbaa !20
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %28, i64 8
  store i32 0, ptr %29, align 8, !tbaa !21
  %30 = load ptr, ptr %14, align 8, !tbaa !9
  %.not31 = icmp eq ptr %30, null
  br i1 %.not31, label %34, label %31

31:                                               ; preds = %13
  %32 = load i32, ptr %0, align 8, !tbaa !22
  %33 = getelementptr inbounds i8, ptr %30, i64 8
  store i32 %32, ptr %33, align 8, !tbaa !21
  br label %34

34:                                               ; preds = %31, %13
  store ptr %28, ptr %14, align 8, !tbaa !9
  store i32 1, ptr %0, align 8, !tbaa !22
  br label %35

35:                                               ; preds = %8, %34
  %.025 = phi i32 [ 0, %34 ], [ 1, %8 ]
  ret i32 %.025
}

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" }
attributes #1 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 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 #3 = { nounwind willreturn memory(read) }
attributes #4 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 40}
!10 = !{!"Global", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !6, i64 40, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !7, i64 64, !6, i64 584, !7, i64 592, !7, i64 593, !7, i64 594, !7, i64 595, !7, i64 596, !7, i64 597, !6, i64 632, !7, i64 640, !6, i64 800, !7, i64 808, !7, i64 968, !11, i64 988, !7, i64 992, !7, i64 1032, !7, i64 1072, !6, i64 1080, !7, i64 1088, !6, i64 2120, !7, i64 2128, !11, i64 2376, !6, i64 2384, !7, i64 2392, !11, i64 2904, !6, i64 2912, !6, i64 2920, !6, i64 2928, !6, i64 2936, !6, i64 2944, !6, i64 2952, !7, i64 2960, !7, i64 2961, !7, i64 2962, !7, i64 2963, !7, i64 2964, !7, i64 2965, !7, i64 2966, !7, i64 2967, !6, i64 2968, !12, i64 2976, !7, i64 2984, !7, i64 2985, !7, i64 2986, !7, i64 2987, !7, i64 2988, !7, i64 2989, !6, i64 2992, !7, i64 3000, !11, i64 3160, !7, i64 3164, !7, i64 3165, !7, i64 3166, !6, i64 3168}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !6, i64 24}
!14 = !{!"fileinfo", !6, i64 0, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !11, i64 48, !7, i64 52}
!15 = !{!14, !6, i64 16}
!16 = !{!14, !6, i64 32}
!17 = !{!14, !6, i64 40}
!18 = !{!14, !11, i64 48}
!19 = !{!14, !6, i64 0}
!20 = !{!7, !7, i64 0}
!21 = !{!14, !11, i64 8}
!22 = !{!10, !11, i64 0}


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