; LLVM IR from kala13x/libxutils :: examples (jwt)

; 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.XJWT = type { ptr, i64, ptr, ptr, i64, ptr, ptr, i64, i32, i8 }

@.str = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [24 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca %struct.XJWT, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  store i32 0, ptr %1, align 4
  call void @XLog_Init(ptr noundef null, i16 noundef zeroext 203, i8 noundef zeroext 0)
  call void @XLog_FlagEnable(i32 noundef 255)
  call void @XLog_TimeFormatSet(i32 noundef 1)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  store ptr @.str, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  store ptr @.str.1, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = call i64 @strlen(ptr noundef %13) #7
  store i64 %14, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = call i64 @strlen(ptr noundef %15) #7
  store i64 %16, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  store i64 0, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 72, ptr %7) #6
  call void @XJWT_Init(ptr noundef %7, i32 noundef 1)
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = load i64, ptr %4, align 8, !tbaa !9
  %19 = call i32 @XJWT_AddPayload(ptr noundef %7, ptr noundef %17, i64 noundef %18, i8 noundef zeroext 0)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = load i64, ptr %5, align 8, !tbaa !9
  %22 = call ptr @XJWT_Create(ptr noundef %7, ptr noundef %20, i64 noundef %21, ptr noundef %6)
  store ptr %22, ptr %8, align 8, !tbaa !5
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = icmp eq ptr %23, null
  br i1 %24, label %25, label %27

25:                                               ; preds = %0
  %26 = call ptr @XSTR_Error()
  call void (i32, i8, ptr, ...) @XLog_Display(i32 noundef 64, i8 noundef zeroext 1, ptr noundef @.str.2, ptr noundef %26)
  call void @XJWT_Destroy(ptr noundef %7)
  store i32 -1, ptr %1, align 4
  store i32 1, ptr %9, align 4
  br label %53

27:                                               ; preds = %0
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  call void (i32, i8, ptr, ...) @XLog_Display(i32 noundef 4, i8 noundef zeroext 1, ptr noundef @.str.3, ptr noundef %28)
  call void @XJWT_Destroy(ptr noundef %7)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = load i64, ptr %6, align 8, !tbaa !9
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = load i64, ptr %5, align 8, !tbaa !9
  %33 = call i32 @XJWT_Parse(ptr noundef %7, ptr noundef %29, i64 noundef %30, ptr noundef %31, i64 noundef %32)
  store i32 %33, ptr %10, align 4, !tbaa !11
  %34 = load i32, ptr %10, align 4, !tbaa !11
  %35 = icmp ne i32 %34, 1
  br i1 %35, label %36, label %44

36:                                               ; preds = %27
  %37 = getelementptr inbounds %struct.XJWT, ptr %7, i32 0, i32 9
  %38 = load i8, ptr %37, align 4, !tbaa !13
  %39 = icmp ne i8 %38, 0
  %40 = xor i1 %39, true
  %41 = zext i1 %40 to i64
  %42 = select i1 %40, ptr @.str.5, ptr @.str.6
  call void (i32, i8, ptr, ...) @XLog_Display(i32 noundef 64, i8 noundef zeroext 1, ptr noundef @.str.4, ptr noundef %42)
  call void @XJWT_Destroy(ptr noundef %7)
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  call void @free(ptr noundef %43) #6
  store i32 -1, ptr %1, align 4
  store i32 1, ptr %9, align 4
  br label %52

44:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %45 = call ptr @XJWT_GetHeader(ptr noundef %7, i8 noundef zeroext 1, ptr noundef null)
  store ptr %45, ptr %11, align 8, !tbaa !5
  %46 = load ptr, ptr %11, align 8, !tbaa !5
  call void (i32, i8, ptr, ...) @XLog_Display(i32 noundef 4, i8 noundef zeroext 1, ptr noundef @.str.7, ptr noundef %46)
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  call void @free(ptr noundef %47) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %48 = call ptr @XJWT_GetPayload(ptr noundef %7, i8 noundef zeroext 1, ptr noundef null)
  store ptr %48, ptr %12, align 8, !tbaa !5
  %49 = load ptr, ptr %12, align 8, !tbaa !5
  call void (i32, i8, ptr, ...) @XLog_Display(i32 noundef 4, i8 noundef zeroext 1, ptr noundef @.str.8, ptr noundef %49)
  %50 = load ptr, ptr %12, align 8, !tbaa !5
  call void @free(ptr noundef %50) #6
  call void @XJWT_Destroy(ptr noundef %7)
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  call void @free(ptr noundef %51) #6
  store i32 0, ptr %1, align 4
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %52

52:                                               ; preds = %44, %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %53

53:                                               ; preds = %52, %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 72, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  %54 = load i32, ptr %1, align 4
  ret i32 %54
}

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

declare void @XLog_FlagEnable(i32 noundef) #1

declare void @XLog_TimeFormatSet(i32 noundef) #1

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

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

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

declare i32 @XJWT_AddPayload(ptr noundef, ptr noundef, i64 noundef, i8 noundef zeroext) #1

declare ptr @XJWT_Create(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #1

declare void @XLog_Display(i32 noundef, i8 noundef zeroext, ptr noundef, ...) #1

declare void @XJWT_Destroy(ptr noundef) #1

declare i32 @XJWT_Parse(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef) #1

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

declare ptr @XJWT_GetHeader(ptr noundef, i8 noundef zeroext, ptr noundef) #1

declare ptr @XJWT_GetPayload(ptr noundef, i8 noundef zeroext, ptr noundef) #1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @XSTR_Error() #5

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 "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 = { inlinehint 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 #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(read) }

!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, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !7, i64 68}
!14 = !{!"XJWT", !6, i64 0, !10, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !6, i64 40, !6, i64 48, !10, i64 56, !12, i64 64, !7, i64 68}


; 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.XJWT = type { ptr, i64, ptr, ptr, i64, ptr, ptr, i64, i32, i8 }

@.str = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [24 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %2 = alloca %struct.XJWT, align 8
  tail call void @XLog_Init(ptr noundef null, i16 noundef zeroext 203, i8 noundef zeroext 0) #6
  tail call void @XLog_FlagEnable(i32 noundef 255) #6
  tail call void @XLog_TimeFormatSet(i32 noundef 1) #6
  %3 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) @.str) #7
  %4 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) @.str.1) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  store i64 0, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %2) #6
  call void @XJWT_Init(ptr noundef nonnull %2, i32 noundef 1) #6
  %5 = call i32 @XJWT_AddPayload(ptr noundef nonnull %2, ptr noundef nonnull @.str, i64 noundef %3, i8 noundef zeroext 0) #6
  %6 = call ptr @XJWT_Create(ptr noundef nonnull %2, ptr noundef nonnull @.str.1, i64 noundef %4, ptr noundef nonnull %1) #6
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %10

8:                                                ; preds = %0
  %9 = call ptr @XSTR_Error()
  call void (i32, i8, ptr, ...) @XLog_Display(i32 noundef 64, i8 noundef zeroext 1, ptr noundef nonnull @.str.2, ptr noundef %9) #6
  call void @XJWT_Destroy(ptr noundef nonnull %2) #6
  br label %20

10:                                               ; preds = %0
  call void (i32, i8, ptr, ...) @XLog_Display(i32 noundef 4, i8 noundef zeroext 1, ptr noundef nonnull @.str.3, ptr noundef nonnull %6) #6
  call void @XJWT_Destroy(ptr noundef nonnull %2) #6
  %11 = load i64, ptr %1, align 8, !tbaa !5
  %12 = call i32 @XJWT_Parse(ptr noundef nonnull %2, ptr noundef nonnull %6, i64 noundef %11, ptr noundef nonnull @.str.1, i64 noundef %4) #6
  %.not = icmp eq i32 %12, 1
  br i1 %.not, label %17, label %13

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %2, i64 68
  %15 = load i8, ptr %14, align 4, !tbaa !9
  %.not19 = icmp eq i8 %15, 0
  %16 = select i1 %.not19, ptr @.str.5, ptr @.str.6
  call void (i32, i8, ptr, ...) @XLog_Display(i32 noundef 64, i8 noundef zeroext 1, ptr noundef nonnull @.str.4, ptr noundef nonnull %16) #6
  call void @XJWT_Destroy(ptr noundef nonnull %2) #6
  call void @free(ptr noundef nonnull %6) #6
  br label %20

17:                                               ; preds = %10
  %18 = call ptr @XJWT_GetHeader(ptr noundef nonnull %2, i8 noundef zeroext 1, ptr noundef null) #6
  call void (i32, i8, ptr, ...) @XLog_Display(i32 noundef 4, i8 noundef zeroext 1, ptr noundef nonnull @.str.7, ptr noundef %18) #6
  call void @free(ptr noundef %18) #6
  %19 = call ptr @XJWT_GetPayload(ptr noundef nonnull %2, i8 noundef zeroext 1, ptr noundef null) #6
  call void (i32, i8, ptr, ...) @XLog_Display(i32 noundef 4, i8 noundef zeroext 1, ptr noundef nonnull @.str.8, ptr noundef %19) #6
  call void @free(ptr noundef %19) #6
  call void @XJWT_Destroy(ptr noundef nonnull %2) #6
  call void @free(ptr noundef nonnull %6) #6
  br label %20

20:                                               ; preds = %13, %17, %8
  %.1 = phi i32 [ -1, %8 ], [ -1, %13 ], [ 0, %17 ]
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  ret i32 %.1
}

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

declare void @XLog_FlagEnable(i32 noundef) local_unnamed_addr #1

declare void @XLog_TimeFormatSet(i32 noundef) local_unnamed_addr #1

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

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

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

declare i32 @XJWT_AddPayload(ptr noundef, ptr noundef, i64 noundef, i8 noundef zeroext) local_unnamed_addr #1

declare ptr @XJWT_Create(ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

declare void @XLog_Display(i32 noundef, i8 noundef zeroext, ptr noundef, ...) local_unnamed_addr #1

declare void @XJWT_Destroy(ptr noundef) local_unnamed_addr #1

declare i32 @XJWT_Parse(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

declare ptr @XJWT_GetHeader(ptr noundef, i8 noundef zeroext, ptr noundef) local_unnamed_addr #1

declare ptr @XJWT_GetPayload(ptr noundef, i8 noundef zeroext, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @XSTR_Error() local_unnamed_addr #5

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #5 = { inlinehint 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 #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(read) }

!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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !7, i64 68}
!10 = !{!"XJWT", !11, i64 0, !6, i64 8, !11, i64 16, !11, i64 24, !6, i64 32, !11, i64 40, !11, i64 48, !6, i64 56, !12, i64 64, !7, i64 68}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"int", !7, i64 0}


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