; LLVM IR from EarlGray/language-incubator :: fp/secd (secd)

; 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.cell = type { i64, %union.anon, i64 }
%union.anon = type { %struct.atom }
%struct.atom = type { i32, %union.anon.0 }
%union.anon.0 = type { %struct.anon }
%struct.anon = type { i64, ptr }
%struct.cons = type { ptr, ptr }

@stderr = external global ptr, align 8
@.str.9 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.58 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.59 = external hidden unnamed_addr constant [37 x i8], align 1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @is_nil(ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @not_nil(ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @is_cons(ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @list_next(ptr noundef) #1

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @share_cell(ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @list_head(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden ptr @list_copy(ptr noundef, ptr noundef, ptr noundef) #3

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

15:                                               ; preds = %2
  %16 = load ptr, ptr @stderr, align 8, !tbaa !5
  %17 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef @.str.58) #4
  %18 = load ptr, ptr @stderr, align 8, !tbaa !5
  %19 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef @.str.9) #4
  store ptr null, ptr %3, align 8
  br label %93

20:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = call ptr @list_head(ptr noundef %21)
  store ptr %22, ptr %6, align 8, !tbaa !5
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = call ptr @list_next(ptr noundef %23)
  %25 = call i32 @is_cons(ptr noundef %24)
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %32, label %27

27:                                               ; preds = %20
  %28 = load ptr, ptr @stderr, align 8, !tbaa !5
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef @.str.59) #4
  %30 = load ptr, ptr @stderr, align 8, !tbaa !5
  %31 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef @.str.9) #4
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %92

32:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = call ptr @list_next(ptr noundef %33)
  store ptr %34, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = call ptr @list_head(ptr noundef %35)
  store ptr %36, ptr %9, align 8, !tbaa !5
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = call ptr @list_next(ptr noundef %37)
  %39 = call i32 @not_nil(ptr noundef %38)
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %45

41:                                               ; preds = %32
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = call ptr @secdf_append(ptr noundef %42, ptr noundef %43)
  store ptr %44, ptr %9, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %41, %32
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = call i32 @is_nil(ptr noundef %46)
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %49, label %51

49:                                               ; preds = %45
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %50, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %91

51:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %52, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %53, ptr %11, align 8, !tbaa !5
  br label %54

54:                                               ; preds = %67, %51
  br label %55

55:                                               ; preds = %54
  %56 = load ptr, ptr %11, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.cell, ptr %56, i32 0, i32 2
  %58 = load i64, ptr %57, align 8, !tbaa !9
  %59 = icmp ugt i64 %58, 1
  br i1 %59, label %60, label %61

60:                                               ; preds = %55
  store ptr null, ptr %11, align 8, !tbaa !5
  br label %70

61:                                               ; preds = %55
  %62 = load ptr, ptr %11, align 8, !tbaa !5
  %63 = call ptr @list_next(ptr noundef %62)
  %64 = call i32 @is_nil(ptr noundef %63)
  %65 = icmp ne i32 %64, 0
  br i1 %65, label %66, label %67

66:                                               ; preds = %61
  br label %70

67:                                               ; preds = %61
  %68 = load ptr, ptr %11, align 8, !tbaa !5
  %69 = call ptr @list_next(ptr noundef %68)
  store ptr %69, ptr %11, align 8, !tbaa !5
  br label %54

70:                                               ; preds = %66, %60
  %71 = load ptr, ptr %11, align 8, !tbaa !5
  %72 = icmp ne ptr %71, null
  br i1 %72, label %73, label %80

73:                                               ; preds = %70
  %74 = load ptr, ptr %9, align 8, !tbaa !5
  %75 = call ptr @share_cell(ptr noundef %74)
  %76 = load ptr, ptr %11, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.cell, ptr %76, i32 0, i32 1
  %78 = getelementptr inbounds %struct.cons, ptr %77, i32 0, i32 1
  store ptr %75, ptr %78, align 8, !tbaa !12
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %79, ptr %10, align 8, !tbaa !5
  br label %89

80:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %81 = load ptr, ptr %4, align 8, !tbaa !5
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = call ptr @list_copy(ptr noundef %81, ptr noundef %82, ptr noundef %12)
  store ptr %83, ptr %10, align 8, !tbaa !5
  %84 = load ptr, ptr %9, align 8, !tbaa !5
  %85 = call ptr @share_cell(ptr noundef %84)
  %86 = load ptr, ptr %12, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.cell, ptr %86, i32 0, i32 1
  %88 = getelementptr inbounds %struct.cons, ptr %87, i32 0, i32 1
  store ptr %85, ptr %88, align 8, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %89

89:                                               ; preds = %80, %73
  %90 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %90, ptr %3, align 8
  store i32 1, ptr %7, align 4
  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 = %89, %49
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %92

92:                                               ; preds = %91, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %93

93:                                               ; preds = %92, %15
  %94 = load ptr, ptr %3, align 8
  ret ptr %94
}

attributes #0 = { 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 #1 = { inlinehint 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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, !11, i64 32}
!10 = !{!"cell", !11, i64 0, !7, i64 8, !11, i64 32}
!11 = !{!"long", !7, i64 0}
!12 = !{!7, !7, 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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str.9 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.58 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.59 = external hidden unnamed_addr constant [37 x i8], align 1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @is_nil(ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @not_nil(ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @is_cons(ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @list_next(ptr noundef) local_unnamed_addr #1

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @share_cell(ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @list_head(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden ptr @list_copy(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local ptr @secdf_append(ptr noundef %0, ptr noundef %1) local_unnamed_addr #3 {
  %3 = alloca ptr, align 8
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %4, label %9

4:                                                ; preds = %2
  %5 = load ptr, ptr @stderr, align 8, !tbaa !5
  %6 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %5, ptr noundef nonnull @.str.58) #4
  %7 = load ptr, ptr @stderr, align 8, !tbaa !5
  %8 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.9) #4
  br label %44

9:                                                ; preds = %2
  %10 = tail call ptr @list_head(ptr noundef nonnull %1)
  %11 = tail call ptr @list_next(ptr noundef nonnull %1)
  %12 = tail call i32 @is_cons(ptr noundef %11)
  %.not29 = icmp eq i32 %12, 0
  br i1 %.not29, label %13, label %18

13:                                               ; preds = %9
  %14 = load ptr, ptr @stderr, align 8, !tbaa !5
  %15 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str.59) #4
  %16 = load ptr, ptr @stderr, align 8, !tbaa !5
  %17 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str.9) #4
  br label %44

18:                                               ; preds = %9
  %19 = tail call ptr @list_next(ptr noundef nonnull %1)
  %20 = tail call ptr @list_head(ptr noundef %19)
  %21 = tail call ptr @list_next(ptr noundef %19)
  %22 = tail call i32 @not_nil(ptr noundef %21)
  %.not30 = icmp eq i32 %22, 0
  br i1 %.not30, label %25, label %23

23:                                               ; preds = %18
  %24 = tail call ptr @secdf_append(ptr noundef %0, ptr noundef %19)
  br label %25

25:                                               ; preds = %23, %18
  %.025 = phi ptr [ %24, %23 ], [ %20, %18 ]
  %26 = tail call i32 @is_nil(ptr noundef %10)
  %.not31 = icmp eq i32 %26, 0
  br i1 %.not31, label %.preheader, label %44

.preheader:                                       ; preds = %25
  %27 = getelementptr inbounds i8, ptr %10, i64 32
  %28 = load i64, ptr %27, align 8, !tbaa !9
  %29 = icmp ugt i64 %28, 1
  br i1 %29, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %32
  %.037 = phi ptr [ %33, %32 ], [ %10, %.preheader ]
  %30 = tail call ptr @list_next(ptr noundef nonnull %.037)
  %31 = tail call i32 @is_nil(ptr noundef %30)
  %.not32 = icmp eq i32 %31, 0
  br i1 %.not32, label %32, label %37

32:                                               ; preds = %.lr.ph
  %33 = tail call ptr @list_next(ptr noundef nonnull %.037)
  %34 = getelementptr inbounds i8, ptr %33, i64 32
  %35 = load i64, ptr %34, align 8, !tbaa !9
  %36 = icmp ugt i64 %35, 1
  br i1 %36, label %._crit_edge, label %.lr.ph

37:                                               ; preds = %.lr.ph
  %38 = tail call ptr @share_cell(ptr noundef %.025)
  %39 = getelementptr inbounds i8, ptr %.037, i64 16
  store ptr %38, ptr %39, align 8, !tbaa !12
  br label %44

._crit_edge:                                      ; preds = %32, %.preheader
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %40 = call ptr @list_copy(ptr noundef %0, ptr noundef %10, ptr noundef nonnull %3)
  %41 = call ptr @share_cell(ptr noundef %.025)
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %42, i64 16
  store ptr %41, ptr %43, align 8, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  br label %44

44:                                               ; preds = %13, %37, %._crit_edge, %25, %4
  %.2 = phi ptr [ null, %4 ], [ null, %13 ], [ %.025, %25 ], [ %10, %37 ], [ %40, %._crit_edge ]
  ret ptr %.2
}

attributes #0 = { 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 #1 = { inlinehint 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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { cold nounwind }
attributes #5 = { 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 32}
!10 = !{!"cell", !11, i64 0, !7, i64 8, !11, i64 32}
!11 = !{!"long", !7, i64 0}
!12 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass