; LLVM IR from introlab/odas :: src/sink (snk_categories)

; 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.snk_categories_obj = type { i64, i32, i32, ptr, ptr, ptr, i32, ptr, %struct.sockaddr_in, i32, ptr }
%struct.sockaddr_in = type { i16, i16, %struct.in_addr, [8 x i8] }
%struct.in_addr = type { i32 }
%struct.msg_categories_cfg = type { i32, i32 }
%struct.snk_categories_cfg = type { i32, ptr, ptr }
%struct.interface_obj = type { i32, ptr, ptr, i32, ptr }
%struct.format_obj = type { i32 }

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

; Function Attrs: nounwind uwtable
define dso_local ptr @snk_categories_construct(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %6 = call noalias ptr @malloc(i64 noundef 88) #7
  store ptr %6, ptr %5, align 8, !tbaa !5
  %7 = load ptr, ptr %5, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.snk_categories_obj, ptr %7, i32 0, i32 0
  store i64 0, ptr %8, align 8, !tbaa !9
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.msg_categories_cfg, ptr %9, i32 0, i32 0
  %11 = load i32, ptr %10, align 4, !tbaa !16
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.snk_categories_obj, ptr %12, i32 0, i32 1
  store i32 %11, ptr %13, align 8, !tbaa !18
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.snk_categories_cfg, ptr %14, i32 0, i32 0
  %16 = load i32, ptr %15, align 8, !tbaa !19
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.snk_categories_obj, ptr %17, i32 0, i32 2
  store i32 %16, ptr %18, align 4, !tbaa !21
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.snk_categories_cfg, ptr %19, i32 0, i32 1
  %21 = load ptr, ptr %20, align 8, !tbaa !22
  %22 = call ptr @format_clone(ptr noundef %21)
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.snk_categories_obj, ptr %23, i32 0, i32 3
  store ptr %22, ptr %24, align 8, !tbaa !23
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.snk_categories_cfg, ptr %25, i32 0, i32 2
  %27 = load ptr, ptr %26, align 8, !tbaa !24
  %28 = call ptr @interface_clone(ptr noundef %27)
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.snk_categories_obj, ptr %29, i32 0, i32 4
  store ptr %28, ptr %30, align 8, !tbaa !25
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.snk_categories_obj, ptr %31, i32 0, i32 4
  %33 = load ptr, ptr %32, align 8, !tbaa !25
  %34 = getelementptr inbounds %struct.interface_obj, ptr %33, i32 0, i32 0
  %35 = load i32, ptr %34, align 8, !tbaa !26
  %36 = icmp eq i32 %35, 1
  br i1 %36, label %37, label %44

37:                                               ; preds = %2
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.snk_categories_obj, ptr %38, i32 0, i32 3
  %40 = load ptr, ptr %39, align 8, !tbaa !23
  %41 = getelementptr inbounds %struct.format_obj, ptr %40, i32 0, i32 0
  %42 = load i32, ptr %41, align 4, !tbaa !28
  %43 = icmp eq i32 %42, 0
  br i1 %43, label %88, label %44

44:                                               ; preds = %37, %2
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.snk_categories_obj, ptr %45, i32 0, i32 4
  %47 = load ptr, ptr %46, align 8, !tbaa !25
  %48 = getelementptr inbounds %struct.interface_obj, ptr %47, i32 0, i32 0
  %49 = load i32, ptr %48, align 8, !tbaa !26
  %50 = icmp eq i32 %49, 2
  br i1 %50, label %51, label %58

51:                                               ; preds = %44
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.snk_categories_obj, ptr %52, i32 0, i32 3
  %54 = load ptr, ptr %53, align 8, !tbaa !23
  %55 = getelementptr inbounds %struct.format_obj, ptr %54, i32 0, i32 0
  %56 = load i32, ptr %55, align 4, !tbaa !28
  %57 = icmp eq i32 %56, 2
  br i1 %57, label %88, label %58

58:                                               ; preds = %51, %44
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.snk_categories_obj, ptr %59, i32 0, i32 4
  %61 = load ptr, ptr %60, align 8, !tbaa !25
  %62 = getelementptr inbounds %struct.interface_obj, ptr %61, i32 0, i32 0
  %63 = load i32, ptr %62, align 8, !tbaa !26
  %64 = icmp eq i32 %63, 3
  br i1 %64, label %65, label %72

65:                                               ; preds = %58
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.snk_categories_obj, ptr %66, i32 0, i32 3
  %68 = load ptr, ptr %67, align 8, !tbaa !23
  %69 = getelementptr inbounds %struct.format_obj, ptr %68, i32 0, i32 0
  %70 = load i32, ptr %69, align 4, !tbaa !28
  %71 = icmp eq i32 %70, 2
  br i1 %71, label %88, label %72

72:                                               ; preds = %65, %58
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.snk_categories_obj, ptr %73, i32 0, i32 4
  %75 = load ptr, ptr %74, align 8, !tbaa !25
  %76 = getelementptr inbounds %struct.interface_obj, ptr %75, i32 0, i32 0
  %77 = load i32, ptr %76, align 8, !tbaa !26
  %78 = icmp eq i32 %77, 5
  br i1 %78, label %79, label %86

79:                                               ; preds = %72
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.snk_categories_obj, ptr %80, i32 0, i32 3
  %82 = load ptr, ptr %81, align 8, !tbaa !23
  %83 = getelementptr inbounds %struct.format_obj, ptr %82, i32 0, i32 0
  %84 = load i32, ptr %83, align 4, !tbaa !28
  %85 = icmp eq i32 %84, 2
  br i1 %85, label %88, label %86

86:                                               ; preds = %79, %72
  %87 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  call void @exit(i32 noundef 1) #8
  unreachable

88:                                               ; preds = %79, %65, %51, %37
  %89 = call noalias ptr @malloc(i64 noundef 1024) #7
  %90 = load ptr, ptr %5, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.snk_categories_obj, ptr %90, i32 0, i32 5
  store ptr %89, ptr %91, align 8, !tbaa !30
  %92 = load ptr, ptr %5, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.snk_categories_obj, ptr %92, i32 0, i32 5
  %94 = load ptr, ptr %93, align 8, !tbaa !30
  call void @llvm.memset.p0.i64(ptr align 1 %94, i8 0, i64 1024, i1 false)
  %95 = load ptr, ptr %5, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.snk_categories_obj, ptr %95, i32 0, i32 6
  store i32 0, ptr %96, align 8, !tbaa !31
  %97 = load ptr, ptr %5, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.snk_categories_obj, ptr %97, i32 0, i32 10
  store ptr null, ptr %98, align 8, !tbaa !32
  %99 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  ret ptr %99
}

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

declare ptr @format_clone(ptr noundef) #3

declare ptr @interface_clone(ptr noundef) #3

declare i32 @printf(ptr noundef, ...) #3

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #4

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { noreturn 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { noreturn 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, !11, i64 0}
!10 = !{!"snk_categories_obj", !11, i64 0, !12, i64 8, !12, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !12, i64 40, !6, i64 48, !13, i64 56, !12, i64 72, !6, i64 80}
!11 = !{!"long long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"sockaddr_in", !14, i64 0, !14, i64 2, !15, i64 4, !7, i64 8}
!14 = !{!"short", !7, i64 0}
!15 = !{!"in_addr", !12, i64 0}
!16 = !{!17, !12, i64 0}
!17 = !{!"msg_categories_cfg", !12, i64 0, !12, i64 4}
!18 = !{!10, !12, i64 8}
!19 = !{!20, !12, i64 0}
!20 = !{!"snk_categories_cfg", !12, i64 0, !6, i64 8, !6, i64 16}
!21 = !{!10, !12, i64 12}
!22 = !{!20, !6, i64 8}
!23 = !{!10, !6, i64 16}
!24 = !{!20, !6, i64 16}
!25 = !{!10, !6, i64 24}
!26 = !{!27, !12, i64 0}
!27 = !{!"interface_obj", !12, i64 0, !6, i64 8, !6, i64 16, !12, i64 24, !6, i64 32}
!28 = !{!29, !12, i64 0}
!29 = !{!"format_obj", !12, i64 0}
!30 = !{!10, !6, i64 32}
!31 = !{!10, !12, i64 40}
!32 = !{!10, !6, i64 80}


; 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 [51 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @snk_categories_construct(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = tail call noalias dereferenceable_or_null(88) ptr @malloc(i64 noundef 88) #6
  store i64 0, ptr %3, align 8, !tbaa !5
  %4 = load i32, ptr %1, align 4, !tbaa !15
  %5 = getelementptr inbounds i8, ptr %3, i64 8
  store i32 %4, ptr %5, align 8, !tbaa !17
  %6 = load i32, ptr %0, align 8, !tbaa !18
  %7 = getelementptr inbounds i8, ptr %3, i64 12
  store i32 %6, ptr %7, align 4, !tbaa !20
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load ptr, ptr %8, align 8, !tbaa !21
  %10 = tail call ptr @format_clone(ptr noundef %9) #7
  %11 = getelementptr inbounds i8, ptr %3, i64 16
  store ptr %10, ptr %11, align 8, !tbaa !22
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = load ptr, ptr %12, align 8, !tbaa !23
  %14 = tail call ptr @interface_clone(ptr noundef %13) #7
  %15 = getelementptr inbounds i8, ptr %3, i64 24
  store ptr %14, ptr %15, align 8, !tbaa !24
  %16 = load i32, ptr %14, align 8, !tbaa !25
  switch i32 %16, label %.thread24 [
    i32 1, label %17
    i32 2, label %20
    i32 3, label %23
    i32 5, label %26
  ]

17:                                               ; preds = %2
  %18 = load i32, ptr %10, align 4, !tbaa !27
  %19 = icmp eq i32 %18, 0
  br i1 %19, label %30, label %.thread24

20:                                               ; preds = %2
  %21 = load i32, ptr %10, align 4, !tbaa !27
  %22 = icmp eq i32 %21, 2
  br i1 %22, label %30, label %.thread24

23:                                               ; preds = %2
  %24 = load i32, ptr %10, align 4, !tbaa !27
  %25 = icmp eq i32 %24, 2
  br i1 %25, label %30, label %.thread24

26:                                               ; preds = %2
  %27 = load i32, ptr %10, align 4, !tbaa !27
  %28 = icmp eq i32 %27, 2
  br i1 %28, label %30, label %.thread24

.thread24:                                        ; preds = %2, %17, %20, %23, %26
  %29 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  tail call void @exit(i32 noundef 1) #8
  unreachable

30:                                               ; preds = %26, %23, %20, %17
  %calloc = tail call dereferenceable_or_null(1024) ptr @calloc(i64 1, i64 1024)
  %31 = getelementptr inbounds i8, ptr %3, i64 32
  store ptr %calloc, ptr %31, align 8, !tbaa !29
  %32 = getelementptr inbounds i8, ptr %3, i64 40
  store i32 0, ptr %32, align 8, !tbaa !30
  %33 = getelementptr inbounds i8, ptr %3, i64 80
  store ptr null, ptr %33, align 8, !tbaa !31
  ret ptr %3
}

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

declare ptr @format_clone(ptr noundef) local_unnamed_addr #2

declare ptr @interface_clone(ptr noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #4

; Function Attrs: nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) 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 = { 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 #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 = { nofree 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 #4 = { noreturn 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 = { nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #6 = { nounwind allocsize(0) }
attributes #7 = { nounwind }
attributes #8 = { noreturn 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, !7, i64 0}
!6 = !{!"snk_categories_obj", !7, i64 0, !10, i64 8, !10, i64 12, !11, i64 16, !11, i64 24, !11, i64 32, !10, i64 40, !11, i64 48, !12, i64 56, !10, i64 72, !11, i64 80}
!7 = !{!"long long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"sockaddr_in", !13, i64 0, !13, i64 2, !14, i64 4, !8, i64 8}
!13 = !{!"short", !8, i64 0}
!14 = !{!"in_addr", !10, i64 0}
!15 = !{!16, !10, i64 0}
!16 = !{!"msg_categories_cfg", !10, i64 0, !10, i64 4}
!17 = !{!6, !10, i64 8}
!18 = !{!19, !10, i64 0}
!19 = !{!"snk_categories_cfg", !10, i64 0, !11, i64 8, !11, i64 16}
!20 = !{!6, !10, i64 12}
!21 = !{!19, !11, i64 8}
!22 = !{!6, !11, i64 16}
!23 = !{!19, !11, i64 16}
!24 = !{!6, !11, i64 24}
!25 = !{!26, !10, i64 0}
!26 = !{!"interface_obj", !10, i64 0, !11, i64 8, !11, i64 16, !10, i64 24, !11, i64 32}
!27 = !{!28, !10, i64 0}
!28 = !{!"format_obj", !10, i64 0}
!29 = !{!6, !11, i64 32}
!30 = !{!6, !10, i64 40}
!31 = !{!6, !11, i64 80}


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