; LLVM IR from specinfo-ua/UAPKI :: library/uapkic/src (dstu7564)

; 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.Dstu7564Ctx_st = type { [256 x i8], i64, [2 x i64], [128 x i8], i64, i64, i64, i64, i64, ptr }

@.str = external hidden unnamed_addr constant [18 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

declare void @stacktrace_create(ptr noundef, i64 noundef, i32 noundef, ptr noundef) #1

; 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 i32 @dstu7564_init(ptr noundef %0, i64 noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !11
  br label %6

6:                                                ; preds = %2
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = icmp ne ptr %7, null
  br i1 %8, label %11, label %9

9:                                                ; preds = %6
  store i32 2, ptr %5, align 4, !tbaa !11
  %10 = load i32, ptr %5, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 623, i32 noundef %10, ptr noundef null)
  br label %80

11:                                               ; preds = %6
  br label %12

12:                                               ; preds = %11
  br label %13

13:                                               ; preds = %12
  br label %14

14:                                               ; preds = %13
  %15 = load i64, ptr %4, align 8, !tbaa !9
  %16 = icmp ugt i64 %15, 0
  %17 = zext i1 %16 to i32
  %18 = load i64, ptr %4, align 8, !tbaa !9
  %19 = icmp ule i64 %18, 64
  %20 = zext i1 %19 to i32
  %21 = and i32 %17, %20
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %25, label %23

23:                                               ; preds = %14
  store i32 2, ptr %5, align 4, !tbaa !11
  %24 = load i32, ptr %5, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 624, i32 noundef %24, ptr noundef null)
  br label %80

25:                                               ; preds = %14
  br label %26

26:                                               ; preds = %25
  br label %27

27:                                               ; preds = %26
  %28 = load i64, ptr %4, align 8, !tbaa !9
  %29 = icmp ule i64 %28, 32
  br i1 %29, label %30, label %43

30:                                               ; preds = %27
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.Dstu7564Ctx_st, ptr %31, i32 0, i32 8
  store i64 10, ptr %32, align 8, !tbaa !13
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.Dstu7564Ctx_st, ptr %33, i32 0, i32 6
  store i64 8, ptr %34, align 8, !tbaa !15
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.Dstu7564Ctx_st, ptr %35, i32 0, i32 4
  store i64 64, ptr %36, align 8, !tbaa !16
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.Dstu7564Ctx_st, ptr %37, i32 0, i32 3
  %39 = getelementptr inbounds [128 x i8], ptr %38, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 8 %39, i8 0, i64 64, i1 false)
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.Dstu7564Ctx_st, ptr %40, i32 0, i32 3
  %42 = getelementptr inbounds [128 x i8], ptr %41, i64 0, i64 0
  store i8 64, ptr %42, align 8, !tbaa !17
  br label %56

43:                                               ; preds = %27
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.Dstu7564Ctx_st, ptr %44, i32 0, i32 8
  store i64 14, ptr %45, align 8, !tbaa !13
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.Dstu7564Ctx_st, ptr %46, i32 0, i32 6
  store i64 16, ptr %47, align 8, !tbaa !15
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.Dstu7564Ctx_st, ptr %48, i32 0, i32 4
  store i64 128, ptr %49, align 8, !tbaa !16
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.Dstu7564Ctx_st, ptr %50, i32 0, i32 3
  %52 = getelementptr inbounds [128 x i8], ptr %51, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 8 %52, i8 0, i64 128, i1 false)
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.Dstu7564Ctx_st, ptr %53, i32 0, i32 3
  %55 = getelementptr inbounds [128 x i8], ptr %54, i64 0, i64 0
  store i8 -128, ptr %55, align 8, !tbaa !17
  br label %56

56:                                               ; preds = %43, %30
  %57 = load i64, ptr %4, align 8, !tbaa !9
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.Dstu7564Ctx_st, ptr %58, i32 0, i32 5
  store i64 %57, ptr %59, align 8, !tbaa !18
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.Dstu7564Ctx_st, ptr %60, i32 0, i32 0
  call void @llvm.memset.p0.i64(ptr align 8 %61, i8 0, i64 256, i1 false)
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.Dstu7564Ctx_st, ptr %62, i32 0, i32 1
  store i64 0, ptr %63, align 8, !tbaa !19
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.Dstu7564Ctx_st, ptr %64, i32 0, i32 2
  %66 = getelementptr inbounds [2 x i64], ptr %65, i64 0, i64 0
  store i64 0, ptr %66, align 8, !tbaa !9
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.Dstu7564Ctx_st, ptr %67, i32 0, i32 2
  %69 = getelementptr inbounds [2 x i64], ptr %68, i64 0, i64 1
  store i64 0, ptr %69, align 8, !tbaa !9
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.Dstu7564Ctx_st, ptr %70, i32 0, i32 7
  %72 = load i64, ptr %71, align 8, !tbaa !20
  %73 = icmp eq i64 %72, 0
  br i1 %73, label %74, label %77

74:                                               ; preds = %56
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.Dstu7564Ctx_st, ptr %75, i32 0, i32 9
  store ptr null, ptr %76, align 8, !tbaa !21
  br label %77

77:                                               ; preds = %74, %56
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.Dstu7564Ctx_st, ptr %78, i32 0, i32 7
  store i64 1, ptr %79, align 8, !tbaa !20
  br label %80

80:                                               ; preds = %77, %23, %9
  %81 = load i32, ptr %5, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  ret i32 %81
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"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, !10, i64 440}
!14 = !{!"Dstu7564Ctx_st", !7, i64 0, !10, i64 256, !7, i64 264, !7, i64 280, !10, i64 408, !10, i64 416, !10, i64 424, !10, i64 432, !10, i64 440, !6, i64 448}
!15 = !{!14, !10, i64 424}
!16 = !{!14, !10, i64 408}
!17 = !{!7, !7, i64 0}
!18 = !{!14, !10, i64 416}
!19 = !{!14, !10, i64 256}
!20 = !{!14, !10, i64 432}
!21 = !{!14, !6, i64 448}


; 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 = external hidden unnamed_addr constant [18 x i8], align 1

declare void @stacktrace_create(ptr noundef, i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 3) i32 @dstu7564_init(ptr noundef %0, i64 noundef %1) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %3, label %4

3:                                                ; preds = %2
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 623, i32 noundef 2, ptr noundef null) #3
  br label %24

4:                                                ; preds = %2
  %5 = add i64 %1, -1
  %6 = icmp ult i64 %5, 64
  br i1 %6, label %8, label %7

7:                                                ; preds = %4
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 624, i32 noundef 2, ptr noundef null) #3
  br label %24

8:                                                ; preds = %4
  %9 = icmp ult i64 %1, 33
  %10 = getelementptr inbounds i8, ptr %0, i64 440
  %11 = getelementptr inbounds i8, ptr %0, i64 424
  %12 = getelementptr inbounds i8, ptr %0, i64 408
  %13 = getelementptr inbounds i8, ptr %0, i64 280
  br i1 %9, label %14, label %15

14:                                               ; preds = %8
  store i64 10, ptr %10, align 8, !tbaa !5
  store i64 8, ptr %11, align 8, !tbaa !11
  store i64 64, ptr %12, align 8, !tbaa !12
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(64) %13, i8 0, i64 64, i1 false)
  br label %16

15:                                               ; preds = %8
  store i64 14, ptr %10, align 8, !tbaa !5
  store i64 16, ptr %11, align 8, !tbaa !11
  store i64 128, ptr %12, align 8, !tbaa !12
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(128) %13, i8 0, i64 128, i1 false)
  br label %16

16:                                               ; preds = %15, %14
  %.sink = phi i8 [ -128, %15 ], [ 64, %14 ]
  store i8 %.sink, ptr %13, align 8, !tbaa !13
  %17 = getelementptr inbounds i8, ptr %0, i64 416
  store i64 %1, ptr %17, align 8, !tbaa !14
  %18 = getelementptr inbounds i8, ptr %0, i64 432
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(280) %0, i8 0, i64 280, i1 false)
  %19 = load i64, ptr %18, align 8, !tbaa !15
  %20 = icmp eq i64 %19, 0
  br i1 %20, label %21, label %23

21:                                               ; preds = %16
  %22 = getelementptr inbounds i8, ptr %0, i64 448
  store ptr null, ptr %22, align 8, !tbaa !16
  br label %23

23:                                               ; preds = %21, %16
  store i64 1, ptr %18, align 8, !tbaa !15
  br label %24

24:                                               ; preds = %23, %7, %3
  %.0 = phi i32 [ 0, %23 ], [ 2, %7 ], [ 2, %3 ]
  ret i32 %.0
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

attributes #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 = { 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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, !9, i64 440}
!6 = !{!"Dstu7564Ctx_st", !7, i64 0, !9, i64 256, !7, i64 264, !7, i64 280, !9, i64 408, !9, i64 416, !9, i64 424, !9, i64 432, !9, i64 440, !10, i64 448}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"long", !7, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!6, !9, i64 424}
!12 = !{!6, !9, i64 408}
!13 = !{!7, !7, i64 0}
!14 = !{!6, !9, i64 416}
!15 = !{!6, !9, i64 432}
!16 = !{!6, !10, i64 448}


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