; 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.secd = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@stderr = external global ptr, align 8
@.str.97 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.98 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.99 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.100 = external hidden unnamed_addr constant [9 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @print_cell(ptr noundef) #2

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @get_car(ptr noundef) #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @get_cdr(ptr noundef) #0

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

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

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @symname(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @print_env(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.secd, ptr %10, i32 0, i32 1
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  store ptr %12, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !11
  %13 = call i32 (ptr, ...) @printf(ptr noundef @.str.97)
  br label %14

14:                                               ; preds = %53, %1
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = call i32 @not_nil(ptr noundef %15)
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %18, label %56

18:                                               ; preds = %14
  %19 = load i32, ptr %4, align 4, !tbaa !11
  %20 = add nsw i32 %19, 1
  store i32 %20, ptr %4, align 4, !tbaa !11
  %21 = call i32 (ptr, ...) @printf(ptr noundef @.str.98, i32 noundef %19)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = call ptr @get_car(ptr noundef %22)
  store ptr %23, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = call ptr @get_car(ptr noundef %24)
  store ptr %25, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = call ptr @get_cdr(ptr noundef %26)
  store ptr %27, ptr %7, align 8, !tbaa !5
  br label %28

28:                                               ; preds = %44, %18
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = call i32 @not_nil(ptr noundef %29)
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %53

32:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = call ptr @get_car(ptr noundef %33)
  store ptr %34, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = call ptr @get_car(ptr noundef %35)
  store ptr %36, ptr %9, align 8, !tbaa !5
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = call i32 @atom_type(ptr noundef %37)
  %39 = icmp ne i32 %38, 2
  br i1 %39, label %40, label %44

40:                                               ; preds = %32
  %41 = load ptr, ptr @stderr, align 8, !tbaa !5
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %41, ptr noundef @.str.99, ptr noundef %42) #5
  br label %44

44:                                               ; preds = %40, %32
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = call ptr @symname(ptr noundef %45)
  %47 = call i32 (ptr, ...) @printf(ptr noundef @.str.100, ptr noundef %46)
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  call void @print_cell(ptr noundef %48)
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = call ptr @list_next(ptr noundef %49)
  store ptr %50, ptr %6, align 8, !tbaa !5
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = call ptr @list_next(ptr noundef %51)
  store ptr %52, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %28, !llvm.loop !13

53:                                               ; preds = %28
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = call ptr @list_next(ptr noundef %54)
  store ptr %55, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %14, !llvm.loop !15

56:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret void
}

attributes #0 = { 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 #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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !6, i64 8}
!10 = !{!"secd", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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.97 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.98 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.99 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.100 = external hidden unnamed_addr constant [9 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @print_cell(ptr noundef) local_unnamed_addr #2

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

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @print_env(ptr nocapture noundef readonly %0) local_unnamed_addr #2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.97)
  %5 = tail call i32 @not_nil(ptr noundef %3)
  %.not23 = icmp eq i32 %5, 0
  br i1 %.not23, label %._crit_edge28, label %.lr.ph27

.lr.ph27:                                         ; preds = %1, %._crit_edge
  %.025 = phi ptr [ %24, %._crit_edge ], [ %3, %1 ]
  %.01524 = phi i32 [ %6, %._crit_edge ], [ 0, %1 ]
  %6 = add nuw nsw i32 %.01524, 1
  %7 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.98, i32 noundef %.01524)
  %8 = tail call ptr @get_car(ptr noundef %.025)
  %9 = tail call ptr @get_car(ptr noundef %8)
  %10 = tail call ptr @get_cdr(ptr noundef %8)
  %11 = tail call i32 @not_nil(ptr noundef %9)
  %.not1820 = icmp eq i32 %11, 0
  br i1 %.not1820, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph27, %18
  %.01622 = phi ptr [ %22, %18 ], [ %10, %.lr.ph27 ]
  %.01721 = phi ptr [ %21, %18 ], [ %9, %.lr.ph27 ]
  %12 = tail call ptr @get_car(ptr noundef %.01721)
  %13 = tail call ptr @get_car(ptr noundef %.01622)
  %14 = tail call i32 @atom_type(ptr noundef %12)
  %.not19 = icmp eq i32 %14, 2
  br i1 %.not19, label %18, label %15

15:                                               ; preds = %.lr.ph
  %16 = load ptr, ptr @stderr, align 8, !tbaa !10
  %17 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str.99, ptr noundef %12) #3
  br label %18

18:                                               ; preds = %15, %.lr.ph
  %19 = tail call ptr @symname(ptr noundef %12)
  %20 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.100, ptr noundef %19)
  tail call void @print_cell(ptr noundef %13)
  %21 = tail call ptr @list_next(ptr noundef %.01721)
  %22 = tail call ptr @list_next(ptr noundef %.01622)
  %23 = tail call i32 @not_nil(ptr noundef %21)
  %.not18 = icmp eq i32 %23, 0
  br i1 %.not18, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %18, %.lr.ph27
  %24 = tail call ptr @list_next(ptr noundef %.025)
  %25 = tail call i32 @not_nil(ptr noundef %24)
  %.not = icmp eq i32 %25, 0
  br i1 %.not, label %._crit_edge28, label %.lr.ph27, !llvm.loop !13

._crit_edge28:                                    ; preds = %._crit_edge, %1
  ret void
}

attributes #0 = { 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 #1 = { 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 #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 = { cold 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 8}
!6 = !{!"secd", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!7, !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; Effective O3 passes: GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass