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

; 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 global ptr, align 8
@g_pidfile_written = external hidden global i8, align 1
@stderr = external global ptr, align 8
@stdout = external global ptr, align 8
@stdin = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [45 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @main_run() #0

declare void @log_print(i32 noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  %6 = load i32, ptr %4, align 4, !tbaa !5
  %7 = load ptr, ptr %5, align 8, !tbaa !9
  %8 = call zeroext i1 @conf_setup(i32 noundef %6, ptr noundef %7)
  br i1 %8, label %10, label %9

9:                                                ; preds = %2
  store i32 1, ptr %3, align 4
  br label %44

10:                                               ; preds = %2
  %11 = load ptr, ptr @gconf, align 8, !tbaa !9
  %12 = getelementptr inbounds %struct.gconf_t, ptr %11, i32 0, i32 7
  %13 = load i8, ptr %12, align 8, !tbaa !11, !range !15, !noundef !16
  %14 = trunc i8 %13 to i1
  br i1 %14, label %15, label %31

15:                                               ; preds = %10
  %16 = load ptr, ptr @gconf, align 8, !tbaa !9
  %17 = getelementptr inbounds %struct.gconf_t, ptr %16, i32 0, i32 10
  store i32 1, ptr %17, align 8, !tbaa !17
  %18 = load ptr, ptr @stderr, align 8, !tbaa !9
  %19 = call i32 @fclose(ptr noundef %18)
  %20 = load ptr, ptr @stdout, align 8, !tbaa !9
  %21 = call i32 @fclose(ptr noundef %20)
  %22 = load ptr, ptr @stdin, align 8, !tbaa !9
  %23 = call i32 @fclose(ptr noundef %22)
  call void @unix_fork()
  %24 = call i32 @chdir(ptr noundef @.str.1) #5
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %30

26:                                               ; preds = %15
  %27 = call ptr @__errno_location() #6
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = call ptr @strerror(i32 noundef %28) #5
  call void (i32, ptr, ...) @log_print(i32 noundef 3, ptr noundef @.str.2, ptr noundef %29)
  call void @exit(i32 noundef 1) #7
  unreachable

30:                                               ; preds = %15
  br label %32

31:                                               ; preds = %10
  call void @conf_info()
  br label %32

32:                                               ; preds = %31, %30
  call void @unix_signals()
  %33 = load ptr, ptr @gconf, align 8, !tbaa !9
  %34 = getelementptr inbounds %struct.gconf_t, ptr %33, i32 0, i32 4
  %35 = load ptr, ptr %34, align 8, !tbaa !18
  %36 = icmp ne ptr %35, null
  br i1 %36, label %37, label %42

37:                                               ; preds = %32
  %38 = call i32 @getpid() #5
  %39 = load ptr, ptr @gconf, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct.gconf_t, ptr %39, i32 0, i32 4
  %41 = load ptr, ptr %40, align 8, !tbaa !18
  call void @unix_write_pidfile(i32 noundef %38, ptr noundef %41)
  store i8 1, ptr @g_pidfile_written, align 1, !tbaa !19
  br label %42

42:                                               ; preds = %37, %32
  call void @unix_dropuid0()
  %43 = call i32 @main_run()
  store i32 %43, ptr %3, align 4
  br label %44

44:                                               ; preds = %42, %9
  %45 = load i32, ptr %3, align 4
  ret i32 %45
}

declare zeroext i1 @conf_setup(i32 noundef, ptr noundef) #1

declare i32 @fclose(ptr noundef) #1

declare void @unix_fork() #1

; Function Attrs: nounwind
declare i32 @chdir(ptr noundef) #2

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) #2

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #3

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #4

declare void @conf_info() #1

declare void @unix_signals() #1

declare void @unix_write_pidfile(i32 noundef, ptr noundef) #1

; Function Attrs: nounwind
declare i32 @getpid() #2

declare void @unix_dropuid0() #1

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 = { "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 "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(none) "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 = { 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 #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(none) }
attributes #7 = { 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, !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, !14, i64 56}
!12 = !{!"gconf_t", !13, i64 0, !13, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !14, i64 56, !14, i64 57, !6, i64 60, !6, i64 64, !6, i64 68, !6, i64 72, !10, i64 80, !7, i64 88, !7, i64 89, !13, i64 104, !13, i64 112, !13, i64 120, !7, i64 128, !7, i64 160}
!13 = !{!"long", !7, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!12, !6, i64 64}
!18 = !{!12, !10, i64 32}
!19 = !{!14, !14, 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 local_unnamed_addr global ptr, align 8
@g_pidfile_written = external hidden local_unnamed_addr global i8, align 1
@stderr = external local_unnamed_addr global ptr, align 8
@stdout = external local_unnamed_addr global ptr, align 8
@stdin = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [45 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @main_run() local_unnamed_addr #0

declare void @log_print(i32 noundef, ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = tail call zeroext i1 @conf_setup(i32 noundef %0, ptr noundef %1) #6
  br i1 %3, label %4, label %34

4:                                                ; preds = %2
  %5 = load ptr, ptr @gconf, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 56
  %7 = load i8, ptr %6, align 8, !tbaa !9, !range !14, !noundef !15
  %8 = trunc nuw i8 %7 to i1
  br i1 %8, label %9, label %22

9:                                                ; preds = %4
  %10 = getelementptr inbounds i8, ptr %5, i64 64
  store i32 1, ptr %10, align 8, !tbaa !16
  %11 = load ptr, ptr @stderr, align 8, !tbaa !5
  %12 = tail call i32 @fclose(ptr noundef %11)
  %13 = load ptr, ptr @stdout, align 8, !tbaa !5
  %14 = tail call i32 @fclose(ptr noundef %13)
  %15 = load ptr, ptr @stdin, align 8, !tbaa !5
  %16 = tail call i32 @fclose(ptr noundef %15)
  tail call void @unix_fork() #6
  %17 = tail call i32 @chdir(ptr noundef nonnull @.str.1) #6
  %.not = icmp eq i32 %17, 0
  br i1 %.not, label %23, label %18

18:                                               ; preds = %9
  %19 = tail call ptr @__errno_location() #7
  %20 = load i32, ptr %19, align 4, !tbaa !17
  %21 = tail call ptr @strerror(i32 noundef %20) #6
  tail call void (i32, ptr, ...) @log_print(i32 noundef 3, ptr noundef nonnull @.str.2, ptr noundef %21) #6
  tail call void @exit(i32 noundef 1) #8
  unreachable

22:                                               ; preds = %4
  tail call void @conf_info() #6
  br label %23

23:                                               ; preds = %9, %22
  tail call void @unix_signals() #6
  %24 = load ptr, ptr @gconf, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %24, i64 32
  %26 = load ptr, ptr %25, align 8, !tbaa !18
  %.not2 = icmp eq ptr %26, null
  br i1 %.not2, label %32, label %27

27:                                               ; preds = %23
  %28 = tail call i32 @getpid() #6
  %29 = load ptr, ptr @gconf, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %29, i64 32
  %31 = load ptr, ptr %30, align 8, !tbaa !18
  tail call void @unix_write_pidfile(i32 noundef %28, ptr noundef %31) #6
  store i8 1, ptr @g_pidfile_written, align 1, !tbaa !19
  br label %32

32:                                               ; preds = %27, %23
  tail call void @unix_dropuid0() #6
  %33 = tail call i32 @main_run()
  br label %34

34:                                               ; preds = %2, %32
  %.0 = phi i32 [ %33, %32 ], [ 1, %2 ]
  ret i32 %.0
}

declare zeroext i1 @conf_setup(i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #2

declare void @unix_fork() local_unnamed_addr #1

; Function Attrs: nounwind
declare i32 @chdir(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #4

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #5

declare void @conf_info() local_unnamed_addr #1

declare void @unix_signals() local_unnamed_addr #1

declare void @unix_write_pidfile(i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare i32 @getpid() local_unnamed_addr #3

declare void @unix_dropuid0() local_unnamed_addr #1

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 = { "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 = { nofree 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 #3 = { 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 #4 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 "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 = { nounwind }
attributes #7 = { nounwind willreturn memory(none) }
attributes #8 = { 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !12, i64 56}
!10 = !{!"gconf_t", !11, i64 0, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !12, i64 56, !12, i64 57, !13, i64 60, !13, i64 64, !13, i64 68, !13, i64 72, !6, i64 80, !7, i64 88, !7, i64 89, !11, i64 104, !11, i64 112, !11, i64 120, !7, i64 128, !7, i64 160}
!11 = !{!"long", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!10, !13, i64 64}
!17 = !{!13, !13, i64 0}
!18 = !{!10, !6, i64 32}
!19 = !{!12, !12, i64 0}


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