; 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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @XJWT_CreateSignature(ptr noundef, ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @XJWT_GetSignature(ptr noundef %0, ptr noundef %1, i64 noundef %2, i8 noundef zeroext %3, ptr noundef %4) #2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i8, align 1
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i64 %2, ptr %9, align 8, !tbaa !9
  store i8 %3, ptr %10, align 1, !tbaa !11
  store ptr %4, ptr %11, align 8, !tbaa !5
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %17, label %16

16:                                               ; preds = %5
  store ptr null, ptr %6, align 8
  br label %74

17:                                               ; preds = %5
  %18 = load ptr, ptr %11, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %22

20:                                               ; preds = %17
  %21 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 0, ptr %21, align 8, !tbaa !9
  br label %22

22:                                               ; preds = %20, %17
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %44

25:                                               ; preds = %22
  %26 = load i64, ptr %9, align 8, !tbaa !9
  %27 = icmp ugt i64 %26, 0
  br i1 %27, label %28, label %44

28:                                               ; preds = %25
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = load i64, ptr %9, align 8, !tbaa !9
  %32 = call i32 @XJWT_CreateSignature(ptr noundef %29, ptr noundef %30, i64 noundef %31)
  %33 = icmp eq i32 %32, 1
  br i1 %33, label %35, label %34

34:                                               ; preds = %28
  store ptr null, ptr %6, align 8
  br label %74

35:                                               ; preds = %28
  %36 = load ptr, ptr %11, align 8, !tbaa !5
  %37 = icmp ne ptr %36, null
  br i1 %37, label %38, label %43

38:                                               ; preds = %35
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.XJWT, ptr %39, i32 0, i32 7
  %41 = load i64, ptr %40, align 8, !tbaa !12
  %42 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 %41, ptr %42, align 8, !tbaa !9
  br label %43

43:                                               ; preds = %38, %35
  br label %44

44:                                               ; preds = %43, %25, %22
  %45 = load i8, ptr %10, align 1, !tbaa !11
  %46 = icmp ne i8 %45, 0
  br i1 %46, label %47, label %62

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

57:                                               ; preds = %47
  %58 = load i64, ptr %12, align 8, !tbaa !9
  %59 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 %58, ptr %59, align 8, !tbaa !9
  br label %60

60:                                               ; preds = %57, %47
  %61 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %61, ptr %6, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  br label %74

62:                                               ; preds = %44
  %63 = load ptr, ptr %11, align 8, !tbaa !5
  %64 = icmp ne ptr %63, null
  br i1 %64, label %65, label %70

65:                                               ; preds = %62
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.XJWT, ptr %66, i32 0, i32 7
  %68 = load i64, ptr %67, align 8, !tbaa !12
  %69 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 %68, ptr %69, align 8, !tbaa !9
  br label %70

70:                                               ; preds = %65, %62
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.XJWT, ptr %71, i32 0, i32 6
  %73 = load ptr, ptr %72, align 8, !tbaa !15
  store ptr %73, ptr %6, align 8
  br label %74

74:                                               ; preds = %70, %60, %34, %16
  %75 = load ptr, ptr %6, align 8
  ret ptr %75
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #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 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !10, i64 56}
!13 = !{!"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, !14, i64 64, !7, i64 68}
!14 = !{!"int", !7, i64 0}
!15 = !{!13, !6, i64 48}


; 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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @XJWT_CreateSignature(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local ptr @XJWT_GetSignature(ptr noundef %0, ptr noundef %1, i64 noundef %2, i8 noundef zeroext %3, ptr noundef writeonly %4) local_unnamed_addr #2 {
  %6 = alloca i64, align 8
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %32, label %7

7:                                                ; preds = %5
  %.not26 = icmp eq ptr %4, null
  br i1 %.not26, label %9, label %8

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

9:                                                ; preds = %8, %7
  %10 = icmp ne ptr %1, null
  %11 = icmp ne i64 %2, 0
  %or.cond = and i1 %10, %11
  br i1 %or.cond, label %12, label %16

12:                                               ; preds = %9
  %13 = tail call i32 @XJWT_CreateSignature(ptr noundef nonnull %0, ptr noundef nonnull %1, i64 noundef %2)
  %14 = icmp eq i32 %13, 1
  br i1 %14, label %15, label %32

15:                                               ; preds = %12
  br i1 %.not26, label %.thread30, label %.thread

16:                                               ; preds = %9
  %.not27 = icmp eq i8 %3, 0
  br i1 %.not27, label %28, label %19

.thread30:                                        ; preds = %15
  %.not2731 = icmp eq i8 %3, 0
  br i1 %.not2731, label %.thread32, label %19

.thread:                                          ; preds = %15
  %17 = getelementptr inbounds i8, ptr %0, i64 56
  %18 = load i64, ptr %17, align 8, !tbaa !9
  store i64 %18, ptr %4, align 8, !tbaa !5
  %.not2728 = icmp eq i8 %3, 0
  br i1 %.not2728, label %.thread29, label %19

19:                                               ; preds = %.thread30, %.thread, %16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  %20 = getelementptr inbounds i8, ptr %0, i64 56
  %21 = load i64, ptr %20, align 8, !tbaa !9
  store i64 %21, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %0, i64 48
  %23 = load ptr, ptr %22, align 8, !tbaa !13
  %24 = call ptr @XBase64_UrlDecrypt(ptr noundef %23, ptr noundef nonnull %6) #3
  br i1 %.not26, label %27, label %25

25:                                               ; preds = %19
  %26 = load i64, ptr %6, align 8, !tbaa !5
  store i64 %26, ptr %4, align 8, !tbaa !5
  br label %27

27:                                               ; preds = %25, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  br label %32

28:                                               ; preds = %16
  br i1 %.not26, label %.thread32, label %..thread29_crit_edge

..thread29_crit_edge:                             ; preds = %28
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 56
  %.pre = load i64, ptr %.phi.trans.insert, align 8, !tbaa !9
  br label %.thread29

.thread29:                                        ; preds = %..thread29_crit_edge, %.thread
  %29 = phi i64 [ %.pre, %..thread29_crit_edge ], [ %18, %.thread ]
  store i64 %29, ptr %4, align 8, !tbaa !5
  br label %.thread32

.thread32:                                        ; preds = %.thread30, %.thread29, %28
  %30 = getelementptr inbounds i8, ptr %0, i64 48
  %31 = load ptr, ptr %30, align 8, !tbaa !13
  br label %32

32:                                               ; preds = %12, %5, %.thread32, %27
  %.0 = phi ptr [ %24, %27 ], [ %31, %.thread32 ], [ null, %5 ], [ null, %12 ]
  ret ptr %.0
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #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, !6, i64 56}
!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 48}


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