; LLVM IR from kala13x/libxutils :: tools (xpass)

; 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.xpass_ctx_t = type { [256 x i8], [256 x i8], [256 x i8], [2048 x i8], [2048 x i8], [256 x i8], [2048 x i8], [2048 x i8], [2048 x i8], [256 x i8], i64, i64, i64, %struct.xjson_, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }
%struct.xjson_ = type { %struct.xjson_token_, i32, ptr, ptr, ptr, i64, i64 }
%struct.xjson_token_ = type { i32, ptr, i64 }

; Function Attrs: nounwind uwtable
declare dso_local void @XPass_InitCtx(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: 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 i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca %struct.xpass_ctx_t, align 8
  %7 = alloca i32, align 4
  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
  %8 = call i64 @time(ptr noundef null) #4
  %9 = trunc i64 %8 to i32
  call void @srand(i32 noundef %9) #4
  call void @XLog_Init(ptr noundef null, i16 noundef zeroext 203, i8 noundef zeroext 0)
  call void @XLog_FlagEnable(i32 noundef 4)
  call void @llvm.lifetime.start.p0(i64 11632, ptr %6) #4
  call void @XPass_InitCtx(ptr noundef %6)
  %10 = load i32, ptr %4, align 4, !tbaa !5
  %11 = load ptr, ptr %5, align 8, !tbaa !9
  %12 = call zeroext i8 @XPass_ParseArgs(ptr noundef %6, i32 noundef %10, ptr noundef %11)
  %13 = icmp ne i8 %12, 0
  br i1 %13, label %15, label %14

14:                                               ; preds = %2
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %47

15:                                               ; preds = %2
  %16 = getelementptr inbounds %struct.xpass_ctx_t, ptr %6, i32 0, i32 15
  %17 = load i8, ptr %16, align 1, !tbaa !11
  %18 = zext i8 %17 to i32
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %20, label %24

20:                                               ; preds = %15
  %21 = call zeroext i8 @XPass_InitConfigFile(ptr noundef %6)
  %22 = icmp ne i8 %21, 0
  br i1 %22, label %24, label %23

23:                                               ; preds = %20
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %47

24:                                               ; preds = %20, %15
  %25 = getelementptr inbounds %struct.xpass_ctx_t, ptr %6, i32 0, i32 15
  %26 = load i8, ptr %25, align 1, !tbaa !11
  %27 = icmp ne i8 %26, 0
  br i1 %27, label %32, label %28

28:                                               ; preds = %24
  %29 = call zeroext i8 @XPass_ParseConfig(ptr noundef %6)
  %30 = icmp ne i8 %29, 0
  br i1 %30, label %32, label %31

31:                                               ; preds = %28
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %47

32:                                               ; preds = %28, %24
  br label %33

33:                                               ; preds = %32
  br label %34

34:                                               ; preds = %33
  %35 = call zeroext i8 @XPass_ProcessDatabase(ptr noundef %6)
  %36 = icmp ne i8 %35, 0
  br i1 %36, label %39, label %37

37:                                               ; preds = %34
  %38 = getelementptr inbounds %struct.xpass_ctx_t, ptr %6, i32 0, i32 13
  call void @XJSON_Destroy(ptr noundef %38)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %47

39:                                               ; preds = %34
  %40 = getelementptr inbounds %struct.xpass_ctx_t, ptr %6, i32 0, i32 16
  %41 = load i8, ptr %40, align 2, !tbaa !16
  %42 = icmp ne i8 %41, 0
  br i1 %42, label %45, label %43

43:                                               ; preds = %39
  %44 = call zeroext i8 @XPass_WriteDatabase(ptr noundef %6)
  br label %45

45:                                               ; preds = %43, %39
  %46 = getelementptr inbounds %struct.xpass_ctx_t, ptr %6, i32 0, i32 13
  call void @XJSON_Destroy(ptr noundef %46)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %47

47:                                               ; preds = %45, %37, %31, %23, %14
  call void @llvm.lifetime.end.p0(i64 11632, ptr %6) #4
  %48 = load i32, ptr %3, align 4
  ret i32 %48
}

; Function Attrs: nounwind
declare void @srand(i32 noundef) #2

; Function Attrs: nounwind
declare i64 @time(ptr noundef) #2

declare void @XLog_Init(ptr noundef, i16 noundef zeroext, i8 noundef zeroext) #3

declare void @XLog_FlagEnable(i32 noundef) #3

; Function Attrs: nounwind uwtable
declare hidden zeroext i8 @XPass_ParseArgs(ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden zeroext i8 @XPass_InitConfigFile(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden zeroext i8 @XPass_ParseConfig(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden zeroext i8 @XPass_ProcessDatabase(ptr noundef) #0

declare void @XJSON_Destroy(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden zeroext i8 @XPass_WriteDatabase(ptr noundef) #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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 }

!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, !7, i64 11617}
!12 = !{!"", !7, i64 0, !7, i64 256, !7, i64 512, !7, i64 768, !7, i64 2816, !7, i64 4864, !7, i64 5120, !7, i64 7168, !7, i64 9216, !7, i64 11264, !13, i64 11520, !13, i64 11528, !13, i64 11536, !14, i64 11544, !7, i64 11616, !7, i64 11617, !7, i64 11618, !7, i64 11619, !7, i64 11620, !7, i64 11621, !7, i64 11622, !7, i64 11623, !7, i64 11624, !7, i64 11625}
!13 = !{!"long", !7, i64 0}
!14 = !{!"xjson_", !15, i64 0, !6, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !13, i64 56, !13, i64 64}
!15 = !{!"xjson_token_", !6, i64 0, !10, i64 8, !13, i64 16}
!16 = !{!12, !7, i64 11618}


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

%struct.xpass_ctx_t = type { [256 x i8], [256 x i8], [256 x i8], [2048 x i8], [2048 x i8], [256 x i8], [2048 x i8], [2048 x i8], [2048 x i8], [256 x i8], i64, i64, i64, %struct.xjson_, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }
%struct.xjson_ = type { %struct.xjson_token_, i32, ptr, ptr, ptr, i64, i64 }
%struct.xjson_token_ = type { i32, ptr, i64 }

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

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

; Function Attrs: mustprogress 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 range(i32 -1, 1) i32 @main(i32 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca %struct.xpass_ctx_t, align 8
  %4 = tail call i64 @time(ptr noundef null) #4
  %5 = trunc i64 %4 to i32
  tail call void @srand(i32 noundef %5) #4
  tail call void @XLog_Init(ptr noundef null, i16 noundef zeroext 203, i8 noundef zeroext 0) #4
  tail call void @XLog_FlagEnable(i32 noundef 4) #4
  call void @llvm.lifetime.start.p0(i64 11632, ptr nonnull %3) #4
  call void @XPass_InitCtx(ptr noundef nonnull %3)
  %6 = call zeroext i8 @XPass_ParseArgs(ptr noundef nonnull %3, i32 noundef %0, ptr noundef %1)
  %.not = icmp eq i8 %6, 0
  br i1 %.not, label %22, label %7

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %3, i64 11617
  %9 = load i8, ptr %8, align 1, !tbaa !5
  %.not2 = icmp eq i8 %9, 0
  br i1 %.not2, label %.thread, label %10

10:                                               ; preds = %7
  %11 = call zeroext i8 @XPass_InitConfigFile(ptr noundef nonnull %3)
  %.not3 = icmp eq i8 %11, 0
  br i1 %.not3, label %22, label %12

12:                                               ; preds = %10
  %.pr = load i8, ptr %8, align 1, !tbaa !5
  %.not4 = icmp eq i8 %.pr, 0
  br i1 %.not4, label %.thread, label %14

.thread:                                          ; preds = %7, %12
  %13 = call zeroext i8 @XPass_ParseConfig(ptr noundef nonnull %3)
  %.not5 = icmp eq i8 %13, 0
  br i1 %.not5, label %22, label %14

14:                                               ; preds = %.thread, %12
  %15 = call zeroext i8 @XPass_ProcessDatabase(ptr noundef nonnull %3)
  %.not6 = icmp eq i8 %15, 0
  br i1 %.not6, label %.sink.split, label %16

16:                                               ; preds = %14
  %17 = getelementptr inbounds i8, ptr %3, i64 11618
  %18 = load i8, ptr %17, align 2, !tbaa !14
  %.not7 = icmp eq i8 %18, 0
  br i1 %.not7, label %19, label %.sink.split

19:                                               ; preds = %16
  %20 = call zeroext i8 @XPass_WriteDatabase(ptr noundef nonnull %3)
  br label %.sink.split

.sink.split:                                      ; preds = %16, %19, %14
  %.0.ph = phi i32 [ -1, %14 ], [ 0, %19 ], [ 0, %16 ]
  %21 = getelementptr inbounds i8, ptr %3, i64 11544
  call void @XJSON_Destroy(ptr noundef nonnull %21) #4
  br label %22

22:                                               ; preds = %.sink.split, %.thread, %10, %2
  %.0 = phi i32 [ -1, %2 ], [ -1, %10 ], [ -1, %.thread ], [ %.0.ph, %.sink.split ]
  call void @llvm.lifetime.end.p0(i64 11632, ptr nonnull %3) #4
  ret i32 %.0
}

; Function Attrs: nounwind
declare void @srand(i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare i64 @time(ptr noundef) local_unnamed_addr #2

declare void @XLog_Init(ptr noundef, i16 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #3

declare void @XLog_FlagEnable(i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden zeroext i8 @XPass_ParseArgs(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

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

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

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

declare void @XJSON_Destroy(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden zeroext i8 @XPass_WriteDatabase(ptr noundef) 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" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 }

!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, !7, i64 11617}
!6 = !{!"", !7, i64 0, !7, i64 256, !7, i64 512, !7, i64 768, !7, i64 2816, !7, i64 4864, !7, i64 5120, !7, i64 7168, !7, i64 9216, !7, i64 11264, !9, i64 11520, !9, i64 11528, !9, i64 11536, !10, i64 11544, !7, i64 11616, !7, i64 11617, !7, i64 11618, !7, i64 11619, !7, i64 11620, !7, i64 11621, !7, i64 11622, !7, i64 11623, !7, i64 11624, !7, i64 11625}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"long", !7, i64 0}
!10 = !{!"xjson_", !11, i64 0, !12, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !9, i64 56, !9, i64 64}
!11 = !{!"xjson_token_", !12, i64 0, !13, i64 8, !9, i64 16}
!12 = !{!"int", !7, i64 0}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!6, !7, i64 11618}


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