; LLVM IR from lionsoul2014/friso :: src (tst-link)

; 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.friso_link_entry = type { ptr, ptr, i32 }
%struct.friso_link_node = type { ptr, ptr, ptr }

@__const.main.keys = external hidden unnamed_addr constant [19 x ptr], align 16
@.str.19 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca [19 x ptr], align 16
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 152, ptr %7) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %7, ptr align 16 @__const.main.keys, i64 152, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 19, ptr %9, align 4, !tbaa !5
  %10 = call ptr @new_link_list()
  store ptr %10, ptr %6, align 8, !tbaa !9
  %11 = load ptr, ptr %6, align 8, !tbaa !9
  %12 = getelementptr inbounds %struct.friso_link_entry, ptr %11, i32 0, i32 2
  %13 = load i32, ptr %12, align 8, !tbaa !11
  %14 = call i32 (ptr, ...) @printf(ptr noundef @.str.19, i32 noundef %13)
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %25, %2
  %16 = load i32, ptr %8, align 4, !tbaa !5
  %17 = load i32, ptr %9, align 4, !tbaa !5
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %19, label %28

19:                                               ; preds = %15
  %20 = load ptr, ptr %6, align 8, !tbaa !9
  %21 = load i32, ptr %8, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [19 x ptr], ptr %7, i64 0, i64 %22
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  call void @link_list_add_last(ptr noundef %20, ptr noundef %24)
  br label %25

25:                                               ; preds = %19
  %26 = load i32, ptr %8, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %8, align 4, !tbaa !5
  br label %15, !llvm.loop !13

28:                                               ; preds = %15
  %29 = load ptr, ptr %6, align 8, !tbaa !9
  %30 = getelementptr inbounds %struct.friso_link_entry, ptr %29, i32 0, i32 2
  %31 = load i32, ptr %30, align 8, !tbaa !11
  %32 = call i32 (ptr, ...) @printf(ptr noundef @.str.19, i32 noundef %31)
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %43, %28
  %34 = load i32, ptr %8, align 4, !tbaa !5
  %35 = load i32, ptr %9, align 4, !tbaa !5
  %36 = sdiv i32 %35, 2
  %37 = icmp slt i32 %34, %36
  br i1 %37, label %38, label %46

38:                                               ; preds = %33
  %39 = load i32, ptr %8, align 4, !tbaa !5
  %40 = load ptr, ptr %6, align 8, !tbaa !9
  %41 = call ptr @link_list_remove_first(ptr noundef %40)
  %42 = call i32 (ptr, ...) @printf(ptr noundef @.str.20, i32 noundef %39, ptr noundef %41)
  br label %43

43:                                               ; preds = %38
  %44 = load i32, ptr %8, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %8, align 4, !tbaa !5
  br label %33, !llvm.loop !15

46:                                               ; preds = %33
  %47 = load ptr, ptr %6, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct.friso_link_entry, ptr %47, i32 0, i32 2
  %49 = load i32, ptr %48, align 8, !tbaa !11
  %50 = call i32 (ptr, ...) @printf(ptr noundef @.str.19, i32 noundef %49)
  %51 = load ptr, ptr %6, align 8, !tbaa !9
  %52 = call ptr @link_list_clear(ptr noundef %51)
  %53 = load ptr, ptr %6, align 8, !tbaa !9
  %54 = getelementptr inbounds %struct.friso_link_entry, ptr %53, i32 0, i32 2
  %55 = load i32, ptr %54, align 8, !tbaa !11
  %56 = load ptr, ptr %6, align 8, !tbaa !9
  %57 = getelementptr inbounds %struct.friso_link_entry, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !16
  %59 = getelementptr inbounds %struct.friso_link_node, ptr %58, i32 0, i32 2
  %60 = load ptr, ptr %59, align 8, !tbaa !17
  %61 = getelementptr inbounds %struct.friso_link_node, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !19
  %63 = call i32 (ptr, ...) @printf(ptr noundef @.str.21, i32 noundef %55, ptr noundef %62)
  %64 = load ptr, ptr %6, align 8, !tbaa !9
  call void @free_link_list(ptr noundef %64)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 152, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  ret i32 0
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare ptr @new_link_list() #3

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

declare void @link_list_add_last(ptr noundef, ptr noundef) #3

declare ptr @link_list_remove_first(ptr noundef) #3

declare ptr @link_list_clear(ptr noundef) #3

declare void @free_link_list(ptr noundef) #3

; 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 16}
!12 = !{!"", !10, i64 0, !10, i64 8, !6, i64 16}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = !{!12, !10, i64 0}
!17 = !{!18, !10, i64 16}
!18 = !{!"friso_link_node", !10, i64 0, !10, i64 8, !10, i64 16}
!19 = !{!18, !10, i64 0}


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

@__const.main.keys = external hidden unnamed_addr constant [19 x ptr], align 16
@.str.19 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = tail call ptr @new_link_list() #3
  %4 = getelementptr inbounds i8, ptr %3, i64 16
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.19, i32 noundef %5)
  %7 = load ptr, ptr @__const.main.keys, align 16, !tbaa !11
  tail call void @link_list_add_last(ptr noundef %3, ptr noundef %7) #3
  %8 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 8), align 8, !tbaa !11
  tail call void @link_list_add_last(ptr noundef %3, ptr noundef %8) #3
  %9 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 16), align 16, !tbaa !11
  tail call void @link_list_add_last(ptr noundef %3, ptr noundef %9) #3
  %10 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 24), align 8, !tbaa !11
  tail call void @link_list_add_last(ptr noundef %3, ptr noundef %10) #3
  %11 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 32), align 16, !tbaa !11
  tail call void @link_list_add_last(ptr noundef %3, ptr noundef %11) #3
  %12 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 40), align 8, !tbaa !11
  tail call void @link_list_add_last(ptr noundef %3, ptr noundef %12) #3
  %13 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 48), align 16, !tbaa !11
  tail call void @link_list_add_last(ptr noundef %3, ptr noundef %13) #3
  %14 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 56), align 8, !tbaa !11
  tail call void @link_list_add_last(ptr noundef %3, ptr noundef %14) #3
  %15 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 64), align 16, !tbaa !11
  tail call void @link_list_add_last(ptr noundef %3, ptr noundef %15) #3
  %16 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 72), align 8, !tbaa !11
  tail call void @link_list_add_last(ptr noundef %3, ptr noundef %16) #3
  %17 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 80), align 16, !tbaa !11
  tail call void @link_list_add_last(ptr noundef %3, ptr noundef %17) #3
  %18 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 88), align 8, !tbaa !11
  tail call void @link_list_add_last(ptr noundef %3, ptr noundef %18) #3
  %19 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 96), align 16, !tbaa !11
  tail call void @link_list_add_last(ptr noundef %3, ptr noundef %19) #3
  %20 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 104), align 8, !tbaa !11
  tail call void @link_list_add_last(ptr noundef %3, ptr noundef %20) #3
  %21 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 112), align 16, !tbaa !11
  tail call void @link_list_add_last(ptr noundef %3, ptr noundef %21) #3
  %22 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 120), align 8, !tbaa !11
  tail call void @link_list_add_last(ptr noundef %3, ptr noundef %22) #3
  %23 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 128), align 16, !tbaa !11
  tail call void @link_list_add_last(ptr noundef %3, ptr noundef %23) #3
  %24 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 136), align 8, !tbaa !11
  tail call void @link_list_add_last(ptr noundef %3, ptr noundef %24) #3
  %25 = load ptr, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 144), align 16, !tbaa !11
  tail call void @link_list_add_last(ptr noundef %3, ptr noundef %25) #3
  %26 = load i32, ptr %4, align 8, !tbaa !5
  %27 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.19, i32 noundef %26)
  %28 = tail call ptr @link_list_remove_first(ptr noundef %3) #3
  %29 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.20, i32 noundef 0, ptr noundef %28)
  %30 = tail call ptr @link_list_remove_first(ptr noundef %3) #3
  %31 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.20, i32 noundef 1, ptr noundef %30)
  %32 = tail call ptr @link_list_remove_first(ptr noundef %3) #3
  %33 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.20, i32 noundef 2, ptr noundef %32)
  %34 = tail call ptr @link_list_remove_first(ptr noundef %3) #3
  %35 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.20, i32 noundef 3, ptr noundef %34)
  %36 = tail call ptr @link_list_remove_first(ptr noundef %3) #3
  %37 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.20, i32 noundef 4, ptr noundef %36)
  %38 = tail call ptr @link_list_remove_first(ptr noundef %3) #3
  %39 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.20, i32 noundef 5, ptr noundef %38)
  %40 = tail call ptr @link_list_remove_first(ptr noundef %3) #3
  %41 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.20, i32 noundef 6, ptr noundef %40)
  %42 = tail call ptr @link_list_remove_first(ptr noundef %3) #3
  %43 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.20, i32 noundef 7, ptr noundef %42)
  %44 = tail call ptr @link_list_remove_first(ptr noundef %3) #3
  %45 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.20, i32 noundef 8, ptr noundef %44)
  %46 = load i32, ptr %4, align 8, !tbaa !5
  %47 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.19, i32 noundef %46)
  %48 = tail call ptr @link_list_clear(ptr noundef %3) #3
  %49 = load i32, ptr %4, align 8, !tbaa !5
  %50 = load ptr, ptr %3, align 8, !tbaa !12
  %51 = getelementptr inbounds i8, ptr %50, i64 16
  %52 = load ptr, ptr %51, align 8, !tbaa !13
  %53 = load ptr, ptr %52, align 8, !tbaa !15
  %54 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.21, i32 noundef %49, ptr noundef %53)
  tail call void @free_link_list(ptr noundef nonnull %3) #3
  ret i32 0
}

declare ptr @new_link_list() local_unnamed_addr #1

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

declare void @link_list_add_last(ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @link_list_remove_first(ptr noundef) local_unnamed_addr #1

declare ptr @link_list_clear(ptr noundef) local_unnamed_addr #1

declare void @free_link_list(ptr noundef) local_unnamed_addr #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 = { "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 = { 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 #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, !10, i64 16}
!6 = !{!"", !7, i64 0, !7, i64 8, !10, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!6, !7, i64 0}
!13 = !{!14, !7, i64 16}
!14 = !{!"friso_link_node", !7, i64 0, !7, i64 8, !7, i64 16}
!15 = !{!14, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass