; LLVM IR from mwarning/KadNode :: src (conf)

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

@gconf = external dso_local global ptr, align 8

; 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
define dso_local zeroext i1 @conf_setup(i32 noundef %0, ptr noundef %1) #1 {
  %3 = alloca i1, align 1
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %10 = call ptr @conf_alloc()
  store ptr %10, ptr @gconf, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  store i64 1, ptr %8, align 8, !tbaa !11
  br label %11

11:                                               ; preds = %49, %2
  %12 = load i64, ptr %8, align 8, !tbaa !11
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = icmp ult i64 %12, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %11
  store i32 2, ptr %9, align 4
  br label %52

17:                                               ; preds = %11
  %18 = load ptr, ptr %5, align 8, !tbaa !9
  %19 = load i64, ptr %8, align 8, !tbaa !11
  %20 = getelementptr inbounds ptr, ptr %18, i64 %19
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  store ptr %21, ptr %6, align 8, !tbaa !9
  %22 = load ptr, ptr %5, align 8, !tbaa !9
  %23 = load i64, ptr %8, align 8, !tbaa !11
  %24 = add i64 %23, 1
  %25 = getelementptr inbounds ptr, ptr %22, i64 %24
  %26 = load ptr, ptr %25, align 8, !tbaa !9
  store ptr %26, ptr %7, align 8, !tbaa !9
  %27 = load ptr, ptr %7, align 8, !tbaa !9
  %28 = icmp ne ptr %27, null
  br i1 %28, label %29, label %43

29:                                               ; preds = %17
  %30 = load ptr, ptr %7, align 8, !tbaa !9
  %31 = getelementptr inbounds i8, ptr %30, i64 0
  %32 = load i8, ptr %31, align 1, !tbaa !13
  %33 = sext i8 %32 to i32
  %34 = icmp ne i32 %33, 45
  br i1 %34, label %35, label %43

35:                                               ; preds = %29
  %36 = load ptr, ptr %6, align 8, !tbaa !9
  %37 = load ptr, ptr %7, align 8, !tbaa !9
  %38 = call zeroext i1 @conf_set(ptr noundef %36, ptr noundef %37)
  br i1 %38, label %40, label %39

39:                                               ; preds = %35
  store i1 false, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %52

40:                                               ; preds = %35
  %41 = load i64, ptr %8, align 8, !tbaa !11
  %42 = add i64 %41, 1
  store i64 %42, ptr %8, align 8, !tbaa !11
  br label %48

43:                                               ; preds = %29, %17
  %44 = load ptr, ptr %6, align 8, !tbaa !9
  %45 = call zeroext i1 @conf_set(ptr noundef %44, ptr noundef null)
  br i1 %45, label %47, label %46

46:                                               ; preds = %43
  store i1 false, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %52

47:                                               ; preds = %43
  br label %48

48:                                               ; preds = %47, %40
  br label %49

49:                                               ; preds = %48
  %50 = load i64, ptr %8, align 8, !tbaa !11
  %51 = add i64 %50, 1
  store i64 %51, ptr %8, align 8, !tbaa !11
  br label %11, !llvm.loop !14

52:                                               ; preds = %46, %39, %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  %53 = load i32, ptr %9, align 4
  switch i32 %53, label %67 [
    i32 2, label %54
  ]

54:                                               ; preds = %52
  %55 = load ptr, ptr @gconf, align 8, !tbaa !9
  %56 = getelementptr inbounds %struct.gconf_t, ptr %55, i32 0, i32 6
  %57 = load ptr, ptr %56, align 8, !tbaa !16
  %58 = icmp ne ptr %57, null
  br i1 %58, label %59, label %66

59:                                               ; preds = %54
  %60 = load ptr, ptr @gconf, align 8, !tbaa !9
  %61 = getelementptr inbounds %struct.gconf_t, ptr %60, i32 0, i32 6
  %62 = load ptr, ptr %61, align 8, !tbaa !16
  %63 = call zeroext i1 @conf_load_file(ptr noundef %62)
  br i1 %63, label %65, label %64

64:                                               ; preds = %59
  store i1 false, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %67

65:                                               ; preds = %59
  br label %66

66:                                               ; preds = %65, %54
  call void @conf_set_defaults()
  store i1 true, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %67

67:                                               ; preds = %66, %64, %52
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  %68 = load i1, ptr %3, align 1
  ret i1 %68
}

; Function Attrs: nounwind uwtable
declare hidden ptr @conf_alloc() #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @conf_set(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @conf_load_file(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @conf_set_defaults() #1

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 }

!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 = !{!"long", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !10, i64 48}
!17 = !{!"gconf_t", !12, i64 0, !12, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !18, i64 56, !18, i64 57, !6, i64 60, !6, i64 64, !6, i64 68, !6, i64 72, !10, i64 80, !7, i64 88, !7, i64 89, !12, i64 104, !12, i64 112, !12, i64 120, !7, i64 128, !7, i64 160}
!18 = !{!"_Bool", !7, 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"

@gconf = external dso_local local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @conf_setup(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = tail call ptr @conf_alloc()
  store ptr %3, ptr @gconf, align 8, !tbaa !5
  %4 = sext i32 %0 to i64
  %.not2022 = icmp ugt i32 %0, 1
  br i1 %.not2022, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %2, %16
  %.01423 = phi i64 [ %.pre-phi, %16 ], [ 1, %2 ]
  %5 = getelementptr inbounds ptr, ptr %1, i64 %.01423
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = add nuw i64 %.01423, 1
  %8 = getelementptr inbounds ptr, ptr %1, i64 %7
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %.not = icmp eq ptr %9, null
  br i1 %.not, label %14, label %10

10:                                               ; preds = %.lr.ph
  %11 = load i8, ptr %9, align 1, !tbaa !9
  %.not19 = icmp eq i8 %11, 45
  br i1 %.not19, label %14, label %12

12:                                               ; preds = %10
  %13 = tail call zeroext i1 @conf_set(ptr noundef %6, ptr noundef nonnull %9)
  br i1 %13, label %._crit_edge, label %.loopexit

._crit_edge:                                      ; preds = %12
  %.pre24 = add i64 %.01423, 2
  br label %16

14:                                               ; preds = %10, %.lr.ph
  %15 = tail call zeroext i1 @conf_set(ptr noundef %6, ptr noundef null)
  br i1 %15, label %16, label %.loopexit

16:                                               ; preds = %._crit_edge, %14
  %.pre-phi = phi i64 [ %.pre24, %._crit_edge ], [ %7, %14 ]
  %.not20 = icmp ult i64 %.pre-phi, %4
  br i1 %.not20, label %.lr.ph, label %.critedge.loopexit, !llvm.loop !10

.critedge.loopexit:                               ; preds = %16
  %.pre = load ptr, ptr @gconf, align 8, !tbaa !5
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %2
  %17 = phi ptr [ %.pre, %.critedge.loopexit ], [ %3, %2 ]
  %18 = getelementptr inbounds i8, ptr %17, i64 48
  %19 = load ptr, ptr %18, align 8, !tbaa !12
  %.not21 = icmp eq ptr %19, null
  br i1 %.not21, label %22, label %20

20:                                               ; preds = %.critedge
  %21 = tail call zeroext i1 @conf_load_file(ptr noundef nonnull %19)
  br i1 %21, label %22, label %.loopexit

22:                                               ; preds = %20, %.critedge
  tail call void @conf_set_defaults()
  br label %.loopexit

.loopexit:                                        ; preds = %12, %14, %20, %22
  %.116 = phi i1 [ true, %22 ], [ false, %20 ], [ false, %14 ], [ false, %12 ]
  ret i1 %.116
}

; Function Attrs: nounwind uwtable
declare hidden ptr @conf_alloc() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @conf_set(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @conf_load_file(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @conf_set_defaults() local_unnamed_addr #0

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

!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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!13, !6, i64 48}
!13 = !{!"gconf_t", !14, i64 0, !14, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !15, i64 56, !15, i64 57, !16, i64 60, !16, i64 64, !16, i64 68, !16, i64 72, !6, i64 80, !7, i64 88, !7, i64 89, !14, i64 104, !14, i64 112, !14, i64 120, !7, i64 128, !7, i64 160}
!14 = !{!"long", !7, i64 0}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!"int", !7, i64 0}


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