; LLVM IR from kala13x/libxutils :: src/data (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 }

; 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 ptr @XJWT_GetPayload(ptr noundef %0, i8 noundef zeroext %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i8 %1, ptr %6, align 1, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %13, label %12

12:                                               ; preds = %3
  store ptr null, ptr %4, align 8
  br label %73

13:                                               ; preds = %3
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %18

16:                                               ; preds = %13
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 0, ptr %17, align 8, !tbaa !10
  br label %18

18:                                               ; preds = %16, %13
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.XJWT, ptr %19, i32 0, i32 3
  %21 = load ptr, ptr %20, align 8, !tbaa !12
  %22 = icmp eq ptr %21, null
  br i1 %22, label %23, label %43

23:                                               ; preds = %18
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.XJWT, ptr %24, i32 0, i32 5
  %26 = load ptr, ptr %25, align 8, !tbaa !15
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.XJWT, ptr %27, i32 0, i32 4
  %29 = call ptr @XJSON_DumpObj(ptr noundef %26, i64 noundef 0, ptr noundef %28)
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.XJWT, ptr %30, i32 0, i32 3
  store ptr %29, ptr %31, align 8, !tbaa !12
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.XJWT, ptr %32, i32 0, i32 3
  %34 = load ptr, ptr %33, align 8, !tbaa !12
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %41

36:                                               ; preds = %23
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.XJWT, ptr %37, i32 0, i32 4
  %39 = load i64, ptr %38, align 8, !tbaa !16
  %40 = icmp ne i64 %39, 0
  br i1 %40, label %42, label %41

41:                                               ; preds = %36, %23
  store ptr null, ptr %4, align 8
  br label %73

42:                                               ; preds = %36
  br label %43

43:                                               ; preds = %42, %18
  %44 = load i8, ptr %6, align 1, !tbaa !9
  %45 = icmp ne i8 %44, 0
  br i1 %45, label %46, label %61

46:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.XJWT, ptr %47, i32 0, i32 4
  %49 = load i64, ptr %48, align 8, !tbaa !16
  store i64 %49, ptr %8, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.XJWT, ptr %50, i32 0, i32 3
  %52 = load ptr, ptr %51, align 8, !tbaa !12
  %53 = call ptr @XBase64_UrlDecrypt(ptr noundef %52, ptr noundef %8)
  store ptr %53, ptr %9, align 8, !tbaa !5
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = icmp ne ptr %54, null
  br i1 %55, label %56, label %59

56:                                               ; preds = %46
  %57 = load i64, ptr %8, align 8, !tbaa !10
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %57, ptr %58, align 8, !tbaa !10
  br label %59

59:                                               ; preds = %56, %46
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %60, ptr %4, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %73

61:                                               ; preds = %43
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = icmp ne ptr %62, null
  br i1 %63, label %64, label %69

64:                                               ; preds = %61
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.XJWT, ptr %65, i32 0, i32 4
  %67 = load i64, ptr %66, align 8, !tbaa !16
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %67, ptr %68, align 8, !tbaa !10
  br label %69

69:                                               ; preds = %64, %61
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.XJWT, ptr %70, i32 0, i32 3
  %72 = load ptr, ptr %71, align 8, !tbaa !12
  store ptr %72, ptr %4, align 8
  br label %73

73:                                               ; preds = %69, %59, %41, %12
  %74 = load ptr, ptr %4, align 8
  ret ptr %74
}

declare ptr @XJSON_DumpObj(ptr noundef, i64 noundef, ptr noundef) #2

declare ptr @XBase64_UrlDecrypt(ptr noundef, ptr noundef) #2

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

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


; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress 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 ptr @XJWT_GetPayload(ptr noundef %0, i8 noundef zeroext %1, ptr noundef writeonly %2) local_unnamed_addr #1 {
  %4 = alloca i64, align 8
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %31, label %5

5:                                                ; preds = %3
  %.not21 = icmp eq ptr %2, null
  br i1 %.not21, label %7, label %6

6:                                                ; preds = %5
  store i64 0, ptr %2, align 8, !tbaa !5
  br label %7

7:                                                ; preds = %6, %5
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  %10 = icmp eq ptr %9, null
  br i1 %10, label %11, label %18

11:                                               ; preds = %7
  %12 = getelementptr inbounds i8, ptr %0, i64 40
  %13 = load ptr, ptr %12, align 8, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %0, i64 32
  %15 = tail call ptr @XJSON_DumpObj(ptr noundef %13, i64 noundef 0, ptr noundef nonnull %14) #3
  store ptr %15, ptr %8, align 8, !tbaa !9
  %.not22 = icmp eq ptr %15, null
  br i1 %.not22, label %31, label %16

16:                                               ; preds = %11
  %17 = load i64, ptr %14, align 8, !tbaa !14
  %.not23 = icmp eq i64 %17, 0
  br i1 %.not23, label %31, label %18

18:                                               ; preds = %16, %7
  %19 = phi ptr [ %15, %16 ], [ %9, %7 ]
  %.not24 = icmp eq i8 %1, 0
  br i1 %.not24, label %27, label %20

20:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  %21 = getelementptr inbounds i8, ptr %0, i64 32
  %22 = load i64, ptr %21, align 8, !tbaa !14
  store i64 %22, ptr %4, align 8, !tbaa !5
  %23 = call ptr @XBase64_UrlDecrypt(ptr noundef nonnull %19, ptr noundef nonnull %4) #3
  br i1 %.not21, label %26, label %24

24:                                               ; preds = %20
  %25 = load i64, ptr %4, align 8, !tbaa !5
  store i64 %25, ptr %2, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %24, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  br label %31

27:                                               ; preds = %18
  br i1 %.not21, label %31, label %28

28:                                               ; preds = %27
  %29 = getelementptr inbounds i8, ptr %0, i64 32
  %30 = load i64, ptr %29, align 8, !tbaa !14
  store i64 %30, ptr %2, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %27, %28, %11, %16, %3, %26
  %.0 = phi ptr [ %23, %26 ], [ null, %3 ], [ null, %16 ], [ null, %11 ], [ %19, %28 ], [ %19, %27 ]
  ret ptr %.0
}

declare ptr @XJSON_DumpObj(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #2

declare ptr @XBase64_UrlDecrypt(ptr noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress 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 = { "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 }

!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, !11, i64 24}
!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}
!13 = !{!10, !11, i64 40}
!14 = !{!10, !6, i64 32}


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