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

@stderr = external global ptr, align 8
@.str.9 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.117 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.118 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.119 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.120 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.121 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.122 = external hidden unnamed_addr constant [25 x i8], align 1

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

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

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

; 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 @drop_cell(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @pop_control(ptr noundef) #3

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @lookup_env(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcasecmp(ptr noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
define dso_local void @run_secd(ptr noundef %0) #3 {
  %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
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  br label %9

9:                                                ; preds = %81, %79, %24, %1
  br label %10

10:                                               ; preds = %9
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = call ptr @pop_control(ptr noundef %11)
  store ptr %12, ptr %3, align 8, !tbaa !5
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %20, label %15

15:                                               ; preds = %10
  %16 = load ptr, ptr @stderr, align 8, !tbaa !5
  %17 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef @.str.117) #5
  %18 = load ptr, ptr @stderr, align 8, !tbaa !5
  %19 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef @.str.9) #5
  store i32 1, ptr %4, align 4
  br label %82

20:                                               ; preds = %10
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = call i32 @atom_type(ptr noundef %21)
  %23 = icmp eq i32 %22, 2
  br i1 %23, label %31, label %24

24:                                               ; preds = %20
  %25 = load ptr, ptr @stderr, align 8, !tbaa !5
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = call i64 @cell_index(ptr noundef %26)
  %28 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef @.str.118, i64 noundef %27) #5
  %29 = load ptr, ptr @stderr, align 8, !tbaa !5
  %30 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %29, ptr noundef @.str.9) #5
  br label %9

31:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = call ptr @symname(ptr noundef %32)
  store ptr %33, ptr %5, align 8, !tbaa !5
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = call i32 @strcasecmp(ptr noundef @.str.119, ptr noundef %34) #6
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %38, label %37

37:                                               ; preds = %31
  store i32 1, ptr %4, align 4
  br label %79

38:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = call ptr @lookup_env(ptr noundef %39, ptr noundef %40)
  store ptr %41, ptr %6, align 8, !tbaa !5
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = icmp ne ptr %42, null
  br i1 %43, label %50, label %44

44:                                               ; preds = %38
  %45 = load ptr, ptr @stderr, align 8, !tbaa !5
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %45, ptr noundef @.str.120, ptr noundef %46) #5
  %48 = load ptr, ptr @stderr, align 8, !tbaa !5
  %49 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %48, ptr noundef @.str.9) #5
  store i32 2, ptr %4, align 4
  br label %78

50:                                               ; preds = %38
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = call i32 @atom_type(ptr noundef %51)
  %53 = icmp eq i32 %52, 3
  br i1 %53, label %59, label %54

54:                                               ; preds = %50
  %55 = load ptr, ptr @stderr, align 8, !tbaa !5
  %56 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %55, ptr noundef @.str.121) #5
  %57 = load ptr, ptr @stderr, align 8, !tbaa !5
  %58 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %57, ptr noundef @.str.9) #5
  store i32 2, ptr %4, align 4
  br label %78

59:                                               ; preds = %50
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = call ptr @drop_cell(ptr noundef %60)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.cell, ptr %62, i32 0, i32 1
  %64 = getelementptr inbounds %struct.atom, ptr %63, i32 0, i32 1
  %65 = load ptr, ptr %64, align 8, !tbaa !9
  store ptr %65, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  %68 = call ptr %66(ptr noundef %67)
  store ptr %68, ptr %8, align 8, !tbaa !5
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = icmp ne ptr %69, null
  br i1 %70, label %76, label %71

71:                                               ; preds = %59
  %72 = load ptr, ptr @stderr, align 8, !tbaa !5
  %73 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %72, ptr noundef @.str.122) #5
  %74 = load ptr, ptr @stderr, align 8, !tbaa !5
  %75 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %74, ptr noundef @.str.9) #5
  store i32 1, ptr %4, align 4
  br label %77

76:                                               ; preds = %59
  store i32 0, ptr %4, align 4
  br label %77

77:                                               ; preds = %76, %71
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %78

78:                                               ; preds = %77, %54, %44
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %79

79:                                               ; preds = %78, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  %80 = load i32, ptr %4, align 4
  switch i32 %80, label %82 [
    i32 0, label %81
    i32 2, label %9
  ]

81:                                               ; preds = %79
  br label %9

82:                                               ; preds = %79, %15
  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 = { 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 = { 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 willreturn memory(read) "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 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }

!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 = !{!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.117 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.118 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.119 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.120 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.121 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.122 = external hidden unnamed_addr constant [25 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 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

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

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

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(read)
declare i32 @strcasecmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local void @run_secd(ptr noundef %0) local_unnamed_addr #2 {
  %2 = tail call ptr @pop_control(ptr noundef %0)
  %.not22 = icmp eq ptr %2, null
  br i1 %.not22, label %.thread.sink.split, label %.lr.ph

.lr.ph:                                           ; preds = %1, %.backedge
  %3 = phi ptr [ %12, %.backedge ], [ %2, %1 ]
  %4 = tail call i32 @atom_type(ptr noundef nonnull %3)
  %5 = icmp eq i32 %4, 2
  br i1 %5, label %13, label %6

6:                                                ; preds = %.lr.ph
  %7 = load ptr, ptr @stderr, align 8, !tbaa !5
  %8 = tail call i64 @cell_index(ptr noundef nonnull %3)
  %9 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.118, i64 noundef %8) #4
  br label %.backedge.sink.split

.backedge.sink.split:                             ; preds = %6, %18, %24
  %10 = load ptr, ptr @stderr, align 8, !tbaa !5
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef nonnull @.str.9) #4
  br label %.backedge

.backedge:                                        ; preds = %.backedge.sink.split, %27
  %12 = tail call ptr @pop_control(ptr noundef %0)
  %.not = icmp eq ptr %12, null
  br i1 %.not, label %.thread.sink.split, label %.lr.ph

13:                                               ; preds = %.lr.ph
  %14 = tail call ptr @symname(ptr noundef nonnull %3)
  %15 = tail call i32 @strcasecmp(ptr noundef nonnull @.str.119, ptr noundef %14) #5
  %.not18 = icmp eq i32 %15, 0
  br i1 %.not18, label %.thread, label %16

16:                                               ; preds = %13
  %17 = tail call ptr @lookup_env(ptr noundef %0, ptr noundef %14)
  %.not19 = icmp eq ptr %17, null
  br i1 %.not19, label %18, label %21

18:                                               ; preds = %16
  %19 = load ptr, ptr @stderr, align 8, !tbaa !5
  %20 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef nonnull @.str.120, ptr noundef %14) #4
  br label %.backedge.sink.split

21:                                               ; preds = %16
  %22 = tail call i32 @atom_type(ptr noundef nonnull %17)
  %23 = icmp eq i32 %22, 3
  br i1 %23, label %27, label %24

24:                                               ; preds = %21
  %25 = load ptr, ptr @stderr, align 8, !tbaa !5
  %26 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef nonnull @.str.121) #4
  br label %.backedge.sink.split

27:                                               ; preds = %21
  %28 = tail call ptr @drop_cell(ptr noundef nonnull %3)
  %29 = getelementptr inbounds i8, ptr %17, i64 16
  %30 = load ptr, ptr %29, align 8, !tbaa !9
  %31 = tail call ptr %30(ptr noundef %0) #6
  %.not20 = icmp eq ptr %31, null
  br i1 %.not20, label %.thread.sink.split, label %.backedge

.thread.sink.split:                               ; preds = %27, %.backedge, %1
  %.str.122.sink = phi ptr [ @.str.117, %1 ], [ @.str.117, %.backedge ], [ @.str.122, %27 ]
  %32 = load ptr, ptr @stderr, align 8, !tbaa !5
  %33 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef nonnull %.str.122.sink) #4
  %34 = load ptr, ptr @stderr, align 8, !tbaa !5
  %35 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %34, ptr noundef nonnull @.str.9) #4
  br label %.thread

.thread:                                          ; preds = %13, %.thread.sink.split
  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 = { mustprogress nofree nounwind willreturn memory(read) "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 willreturn memory(read) }
attributes #6 = { 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 = !{!7, !7, i64 0}


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