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

@.str.5 = external hidden unnamed_addr constant [9 x i8], align 1

; 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 allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @XJWT_GetPayload(ptr noundef, i8 noundef zeroext, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @XJWT_GetHeader(ptr noundef, i8 noundef zeroext, ptr noundef) #2

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

declare i64 @xstrncpyf(ptr noundef, i64 noundef, ptr noundef, ...) #3

; Function Attrs: nounwind uwtable
declare dso_local ptr @XJWT_GetSignature(ptr noundef, ptr noundef, i64 noundef, i8 noundef zeroext, ptr noundef) #2

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

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

18:                                               ; preds = %16, %4
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %27

21:                                               ; preds = %18
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %27

24:                                               ; preds = %21
  %25 = load i64, ptr %8, align 8, !tbaa !9
  %26 = icmp ne i64 %25, 0
  br i1 %26, label %28, label %27

27:                                               ; preds = %24, %21, %18
  store ptr null, ptr %5, align 8
  br label %91

28:                                               ; preds = %24
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = call ptr @XJWT_GetHeader(ptr noundef %29, i8 noundef zeroext 0, ptr noundef null)
  %31 = icmp ne ptr %30, null
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  store ptr null, ptr %5, align 8
  br label %91

33:                                               ; preds = %28
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = call ptr @XJWT_GetPayload(ptr noundef %34, i8 noundef zeroext 0, ptr noundef null)
  %36 = icmp ne ptr %35, null
  br i1 %36, label %38, label %37

37:                                               ; preds = %33
  store ptr null, ptr %5, align 8
  br label %91

38:                                               ; preds = %33
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = call i32 @XJWT_GetAlgorithm(ptr noundef %39)
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %43, label %42

42:                                               ; preds = %38
  store ptr null, ptr %5, align 8
  br label %91

43:                                               ; preds = %38
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = load i64, ptr %8, align 8, !tbaa !9
  %47 = call ptr @XJWT_GetSignature(ptr noundef %44, ptr noundef %45, i64 noundef %46, i8 noundef zeroext 0, ptr noundef null)
  %48 = icmp ne ptr %47, null
  br i1 %48, label %50, label %49

49:                                               ; preds = %43
  store ptr null, ptr %5, align 8
  br label %91

50:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.XJWT, ptr %51, i32 0, i32 1
  %53 = load i64, ptr %52, align 8, !tbaa !11
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.XJWT, ptr %54, i32 0, i32 4
  %56 = load i64, ptr %55, align 8, !tbaa !14
  %57 = add i64 %53, %56
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.XJWT, ptr %58, i32 0, i32 7
  %60 = load i64, ptr %59, align 8, !tbaa !15
  %61 = add i64 %57, %60
  %62 = add i64 %61, 2
  store i64 %62, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %63 = load i64, ptr %10, align 8, !tbaa !9
  %64 = add i64 %63, 1
  %65 = call noalias ptr @malloc(i64 noundef %64) #5
  store ptr %65, ptr %11, align 8, !tbaa !5
  %66 = load ptr, ptr %11, align 8, !tbaa !5
  %67 = icmp ne ptr %66, null
  br i1 %67, label %69, label %68

68:                                               ; preds = %50
  store ptr null, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %90

69:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %70 = load ptr, ptr %11, align 8, !tbaa !5
  %71 = load i64, ptr %10, align 8, !tbaa !9
  %72 = add i64 %71, 1
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.XJWT, ptr %73, i32 0, i32 0
  %75 = load ptr, ptr %74, align 8, !tbaa !16
  %76 = load ptr, ptr %6, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.XJWT, ptr %76, i32 0, i32 3
  %78 = load ptr, ptr %77, align 8, !tbaa !17
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.XJWT, ptr %79, i32 0, i32 6
  %81 = load ptr, ptr %80, align 8, !tbaa !18
  %82 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef %70, i64 noundef %72, ptr noundef @.str.5, ptr noundef %75, ptr noundef %78, ptr noundef %81)
  store i64 %82, ptr %13, align 8, !tbaa !9
  %83 = load ptr, ptr %9, align 8, !tbaa !5
  %84 = icmp ne ptr %83, null
  br i1 %84, label %85, label %88

85:                                               ; preds = %69
  %86 = load i64, ptr %13, align 8, !tbaa !9
  %87 = load ptr, ptr %9, align 8, !tbaa !5
  store i64 %86, ptr %87, align 8, !tbaa !9
  br label %88

88:                                               ; preds = %85, %69
  %89 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %89, ptr %5, align 8
  store i32 1, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  br label %90

90:                                               ; preds = %88, %68
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %91

91:                                               ; preds = %90, %49, %42, %37, %32, %27
  %92 = load ptr, ptr %5, align 8
  ret ptr %92
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(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 = { 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 = { "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 }
attributes #5 = { nounwind allocsize(0) }

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

@.str.5 = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @XJWT_GetPayload(ptr noundef, i8 noundef zeroext, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @XJWT_GetHeader(ptr noundef, i8 noundef zeroext, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @XJWT_GetAlgorithm(ptr noundef) local_unnamed_addr #1

declare i64 @xstrncpyf(ptr noundef, i64 noundef, ptr noundef, ...) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @XJWT_GetSignature(ptr noundef, ptr noundef, i64 noundef, i8 noundef zeroext, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @XJWT_Create(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef writeonly %3) local_unnamed_addr #1 {
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %6, label %5

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

6:                                                ; preds = %5, %4
  %7 = icmp ne ptr %0, null
  %8 = icmp ne ptr %1, null
  %or.cond = and i1 %7, %8
  %9 = icmp ne i64 %2, 0
  %or.cond3 = and i1 %or.cond, %9
  br i1 %or.cond3, label %10, label %37

10:                                               ; preds = %6
  %11 = tail call ptr @XJWT_GetHeader(ptr noundef nonnull %0, i8 noundef zeroext 0, ptr noundef null)
  %.not34 = icmp eq ptr %11, null
  br i1 %.not34, label %37, label %12

12:                                               ; preds = %10
  %13 = tail call ptr @XJWT_GetPayload(ptr noundef nonnull %0, i8 noundef zeroext 0, ptr noundef null)
  %.not35 = icmp eq ptr %13, null
  br i1 %.not35, label %37, label %14

14:                                               ; preds = %12
  %15 = tail call i32 @XJWT_GetAlgorithm(ptr noundef nonnull %0)
  %.not36 = icmp eq i32 %15, 0
  br i1 %.not36, label %37, label %16

16:                                               ; preds = %14
  %17 = tail call ptr @XJWT_GetSignature(ptr noundef nonnull %0, ptr noundef nonnull %1, i64 noundef %2, i8 noundef zeroext 0, ptr noundef null)
  %.not37 = icmp eq ptr %17, null
  br i1 %.not37, label %37, label %18

18:                                               ; preds = %16
  %19 = getelementptr inbounds i8, ptr %0, i64 8
  %20 = load i64, ptr %19, align 8, !tbaa !9
  %21 = getelementptr inbounds i8, ptr %0, i64 32
  %22 = load i64, ptr %21, align 8, !tbaa !13
  %23 = getelementptr inbounds i8, ptr %0, i64 56
  %24 = load i64, ptr %23, align 8, !tbaa !14
  %25 = add i64 %20, 3
  %26 = add i64 %25, %22
  %27 = add i64 %26, %24
  %28 = tail call noalias ptr @malloc(i64 noundef %27) #3
  %.not38 = icmp eq ptr %28, null
  br i1 %.not38, label %37, label %29

29:                                               ; preds = %18
  %30 = load ptr, ptr %0, align 8, !tbaa !15
  %31 = getelementptr inbounds i8, ptr %0, i64 24
  %32 = load ptr, ptr %31, align 8, !tbaa !16
  %33 = getelementptr inbounds i8, ptr %0, i64 48
  %34 = load ptr, ptr %33, align 8, !tbaa !17
  %35 = tail call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %28, i64 noundef %27, ptr noundef nonnull @.str.5, ptr noundef %30, ptr noundef %32, ptr noundef %34) #4
  br i1 %.not, label %37, label %36

36:                                               ; preds = %29
  store i64 %35, ptr %3, align 8, !tbaa !5
  br label %37

37:                                               ; preds = %18, %36, %29, %16, %14, %12, %10, %6
  %.1 = phi ptr [ null, %6 ], [ null, %10 ], [ null, %12 ], [ null, %14 ], [ null, %16 ], [ null, %18 ], [ %28, %36 ], [ %28, %29 ]
  ret ptr %.1
}

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(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 #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 allocsize(0) }
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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 8}
!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, !6, i64 32}
!14 = !{!10, !6, i64 56}
!15 = !{!10, !11, i64 0}
!16 = !{!10, !11, i64 24}
!17 = !{!10, !11, i64 48}


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