; 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.defbuf = type { ptr, ptr, i32, i32, [1 x i8] }

; 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
declare ptr @strcpy(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind
declare void @free(ptr noundef) #1

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #3

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

14:                                               ; preds = %19, %3
  %15 = load ptr, ptr %9, align 8, !tbaa !5
  %16 = load i8, ptr %15, align 1, !tbaa !11
  %17 = sext i8 %16 to i32
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %26

19:                                               ; preds = %14
  %20 = load ptr, ptr %9, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %20, i32 1
  store ptr %21, ptr %9, align 8, !tbaa !5
  %22 = load i8, ptr %20, align 1, !tbaa !11
  %23 = sext i8 %22 to i32
  %24 = load i32, ptr %10, align 4, !tbaa !9
  %25 = add nsw i32 %24, %23
  store i32 %25, ptr %10, align 4, !tbaa !9
  br label %14, !llvm.loop !12

26:                                               ; preds = %14
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = ptrtoint ptr %27 to i64
  %30 = ptrtoint ptr %28 to i64
  %31 = sub i64 %29, %30
  store i64 %31, ptr %12, align 8, !tbaa !14
  %32 = load i64, ptr %12, align 8, !tbaa !14
  %33 = trunc i64 %32 to i32
  %34 = load i32, ptr %10, align 4, !tbaa !9
  %35 = add nsw i32 %34, %33
  store i32 %35, ptr %10, align 4, !tbaa !9
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.Global, ptr %36, i32 0, i32 35
  %38 = load i32, ptr %10, align 4, !tbaa !9
  %39 = srem i32 %38, 64
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [64 x ptr], ptr %37, i64 0, i64 %40
  store ptr %41, ptr %8, align 8, !tbaa !5
  br label %42

42:                                               ; preds = %79, %26
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = load ptr, ptr %43, align 8, !tbaa !5
  store ptr %44, ptr %7, align 8, !tbaa !5
  %45 = icmp ne ptr %44, null
  br i1 %45, label %46, label %82

46:                                               ; preds = %42
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.defbuf, ptr %47, i32 0, i32 2
  %49 = load i32, ptr %48, align 8, !tbaa !16
  %50 = load i32, ptr %10, align 4, !tbaa !9
  %51 = icmp eq i32 %49, %50
  br i1 %51, label %52, label %79

52:                                               ; preds = %46
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.defbuf, ptr %53, i32 0, i32 4
  %55 = getelementptr inbounds [1 x i8], ptr %54, i64 0, i64 0
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = call i32 @strcmp(ptr noundef %55, ptr noundef %56) #6
  store i32 %57, ptr %11, align 4, !tbaa !9
  %58 = icmp sge i32 %57, 0
  br i1 %58, label %59, label %79

59:                                               ; preds = %52
  %60 = load i32, ptr %11, align 4, !tbaa !9
  %61 = icmp sgt i32 %60, 0
  br i1 %61, label %62, label %63

62:                                               ; preds = %59
  store ptr null, ptr %7, align 8, !tbaa !5
  br label %78

63:                                               ; preds = %59
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.defbuf, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !18
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %66, ptr %67, align 8, !tbaa !5
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.defbuf, ptr %68, i32 0, i32 1
  %70 = load ptr, ptr %69, align 8, !tbaa !19
  %71 = icmp ne ptr %70, null
  br i1 %71, label %72, label %76

72:                                               ; preds = %63
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.defbuf, ptr %73, i32 0, i32 1
  %75 = load ptr, ptr %74, align 8, !tbaa !19
  call void @free(ptr noundef %75) #5
  br label %76

76:                                               ; preds = %72, %63
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  call void @free(ptr noundef %77) #5
  br label %78

78:                                               ; preds = %76, %62
  br label %82

79:                                               ; preds = %52, %46
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.defbuf, ptr %80, i32 0, i32 0
  store ptr %81, ptr %8, align 8, !tbaa !5
  br label %42, !llvm.loop !20

82:                                               ; preds = %78, %42
  %83 = load i32, ptr %6, align 4, !tbaa !9
  %84 = icmp ne i32 %83, 0
  br i1 %84, label %107, label %85

85:                                               ; preds = %82
  %86 = load i64, ptr %12, align 8, !tbaa !14
  %87 = add i64 32, %86
  %88 = call noalias ptr @malloc(i64 noundef %87) #7
  store ptr %88, ptr %7, align 8, !tbaa !5
  %89 = load ptr, ptr %8, align 8, !tbaa !5
  %90 = load ptr, ptr %89, align 8, !tbaa !5
  %91 = load ptr, ptr %7, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.defbuf, ptr %91, i32 0, i32 0
  store ptr %90, ptr %92, align 8, !tbaa !18
  %93 = load ptr, ptr %7, align 8, !tbaa !5
  %94 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %93, ptr %94, align 8, !tbaa !5
  %95 = load i32, ptr %10, align 4, !tbaa !9
  %96 = load ptr, ptr %7, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.defbuf, ptr %96, i32 0, i32 2
  store i32 %95, ptr %97, align 8, !tbaa !16
  %98 = load ptr, ptr %7, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.defbuf, ptr %98, i32 0, i32 1
  store ptr null, ptr %99, align 8, !tbaa !19
  %100 = load ptr, ptr %7, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.defbuf, ptr %100, i32 0, i32 3
  store i32 0, ptr %101, align 4, !tbaa !21
  %102 = load ptr, ptr %7, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.defbuf, ptr %102, i32 0, i32 4
  %104 = getelementptr inbounds [1 x i8], ptr %103, i64 0, i64 0
  %105 = load ptr, ptr %5, align 8, !tbaa !5
  %106 = call ptr @strcpy(ptr noundef %104, ptr noundef %105) #5
  br label %107

107:                                              ; preds = %85, %82
  %108 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret ptr %108
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 = { 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 #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 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }
attributes #7 = { 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 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!17, !10, i64 16}
!17 = !{!"defbuf", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !7, i64 24}
!18 = !{!17, !6, i64 0}
!19 = !{!17, !6, i64 8}
!20 = distinct !{!20, !13}
!21 = !{!17, !10, i64 20}


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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr 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: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local ptr @fpp_defendel(ptr nocapture noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #4 {
  %4 = load i8, ptr %1, align 1, !tbaa !5
  %.not50 = icmp eq i8 %4, 0
  br i1 %.not50, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3, %.lr.ph
  %5 = phi i8 [ %9, %.lr.ph ], [ %4, %3 ]
  %.03552 = phi i32 [ %8, %.lr.ph ], [ 0, %3 ]
  %.03651 = phi ptr [ %7, %.lr.ph ], [ %1, %3 ]
  %6 = sext i8 %5 to i32
  %7 = getelementptr inbounds i8, ptr %.03651, i64 1
  %8 = add nsw i32 %.03552, %6
  %9 = load i8, ptr %7, align 1, !tbaa !5
  %.not = icmp eq i8 %9, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !8

._crit_edge:                                      ; preds = %.lr.ph, %3
  %.036.lcssa = phi ptr [ %1, %3 ], [ %7, %.lr.ph ]
  %.035.lcssa = phi i32 [ 0, %3 ], [ %8, %.lr.ph ]
  %10 = ptrtoint ptr %.036.lcssa to i64
  %11 = ptrtoint ptr %1 to i64
  %12 = sub i64 %10, %11
  %13 = trunc i64 %12 to i32
  %14 = add nsw i32 %.035.lcssa, %13
  %15 = getelementptr inbounds i8, ptr %0, i64 2392
  %16 = srem i32 %14, 64
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [64 x ptr], ptr %15, i64 0, i64 %17
  %19 = load ptr, ptr %18, align 8, !tbaa !10
  %.not4254 = icmp eq ptr %19, null
  br i1 %.not4254, label %.loopexit, label %.lr.ph57

.lr.ph57:                                         ; preds = %._crit_edge, %35
  %20 = phi ptr [ %36, %35 ], [ %19, %._crit_edge ]
  %.03455 = phi ptr [ %20, %35 ], [ %18, %._crit_edge ]
  %21 = getelementptr inbounds i8, ptr %20, i64 16
  %22 = load i32, ptr %21, align 8, !tbaa !12
  %23 = icmp eq i32 %22, %14
  br i1 %23, label %24, label %35

24:                                               ; preds = %.lr.ph57
  %25 = getelementptr inbounds i8, ptr %20, i64 24
  %26 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %25, ptr noundef nonnull dereferenceable(1) %1) #5
  %27 = icmp sgt i32 %26, -1
  br i1 %27, label %28, label %35

28:                                               ; preds = %24
  %.not43 = icmp eq i32 %26, 0
  br i1 %.not43, label %29, label %.loopexit

29:                                               ; preds = %28
  %30 = load ptr, ptr %20, align 8, !tbaa !15
  store ptr %30, ptr %.03455, align 8, !tbaa !10
  %31 = getelementptr inbounds i8, ptr %20, i64 8
  %32 = load ptr, ptr %31, align 8, !tbaa !16
  %.not44 = icmp eq ptr %32, null
  br i1 %.not44, label %34, label %33

33:                                               ; preds = %29
  tail call void @free(ptr noundef nonnull %32) #6
  br label %34

34:                                               ; preds = %33, %29
  tail call void @free(ptr noundef nonnull %20) #6
  br label %.loopexit

35:                                               ; preds = %24, %.lr.ph57
  %36 = load ptr, ptr %20, align 8, !tbaa !10
  %.not42 = icmp eq ptr %36, null
  br i1 %.not42, label %.loopexit, label %.lr.ph57, !llvm.loop !17

.loopexit:                                        ; preds = %35, %._crit_edge, %28, %34
  %.03448 = phi ptr [ %.03455, %34 ], [ %.03455, %28 ], [ %18, %._crit_edge ], [ %20, %35 ]
  %.0 = phi ptr [ %20, %34 ], [ null, %28 ], [ null, %._crit_edge ], [ null, %35 ]
  %.not45 = icmp eq i32 %2, 0
  br i1 %.not45, label %37, label %46

37:                                               ; preds = %.loopexit
  %38 = add i64 %12, 32
  %39 = tail call noalias ptr @malloc(i64 noundef %38) #7
  %40 = load ptr, ptr %.03448, align 8, !tbaa !10
  store ptr %40, ptr %39, align 8, !tbaa !15
  store ptr %39, ptr %.03448, align 8, !tbaa !10
  %41 = getelementptr inbounds i8, ptr %39, i64 16
  store i32 %14, ptr %41, align 8, !tbaa !12
  %42 = getelementptr inbounds i8, ptr %39, i64 8
  store ptr null, ptr %42, align 8, !tbaa !16
  %43 = getelementptr inbounds i8, ptr %39, i64 20
  store i32 0, ptr %43, align 4, !tbaa !18
  %44 = getelementptr inbounds i8, ptr %39, i64 24
  %45 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %44, ptr noundef nonnull dereferenceable(1) %1) #6
  br label %46

46:                                               ; preds = %37, %.loopexit
  %.1 = phi ptr [ %.0, %.loopexit ], [ %39, %37 ]
  ret ptr %.1
}

attributes #0 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 nounwind willreturn allockind("free") memory(argmem: readwrite, 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 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 = { 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 #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 = { nounwind willreturn memory(read) }
attributes #6 = { nounwind }
attributes #7 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!12 = !{!13, !14, i64 16}
!13 = !{!"defbuf", !11, i64 0, !11, i64 8, !14, i64 16, !14, i64 20, !6, i64 24}
!14 = !{!"int", !6, i64 0}
!15 = !{!13, !11, i64 0}
!16 = !{!13, !11, i64 8}
!17 = distinct !{!17, !9}
!18 = !{!13, !14, i64 20}


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