; 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.9 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.95 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.96 = external hidden unnamed_addr constant [50 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: inlinehint nounwind uwtable
declare hidden i32 @cell_type(ptr noundef) #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @get_car(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) #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 @symname(ptr noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local ptr @lookup_symbol(ptr noundef %0, ptr noundef %1) #4 {
  %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
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.secd, ptr %11, i32 0, i32 1
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  store ptr %13, ptr %6, align 8, !tbaa !5
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = call i32 @cell_type(ptr noundef %14)
  %16 = icmp eq i32 %15, 2
  br i1 %16, label %22, label %17

17:                                               ; preds = %2
  %18 = load ptr, ptr @stderr, align 8, !tbaa !5
  %19 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef @.str.95) #5
  %20 = load ptr, ptr @stderr, align 8, !tbaa !5
  %21 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef @.str.9) #5
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %70

22:                                               ; preds = %2
  br label %23

23:                                               ; preds = %68, %22
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = call i32 @not_nil(ptr noundef %24)
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %69

27:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = call ptr @get_car(ptr noundef %28)
  store ptr %29, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = call ptr @get_car(ptr noundef %30)
  store ptr %31, ptr %9, align 8, !tbaa !5
  br label %32

32:                                               ; preds = %62, %27
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  %34 = call i32 @not_nil(ptr noundef %33)
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %63

36:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = call ptr @get_car(ptr noundef %37)
  store ptr %38, ptr %10, align 8, !tbaa !5
  %39 = load ptr, ptr %10, align 8, !tbaa !5
  %40 = call i32 @atom_type(ptr noundef %39)
  %41 = icmp ne i32 %40, 2
  br i1 %41, label %49, label %42

42:                                               ; preds = %36
  %43 = load ptr, ptr @stderr, align 8, !tbaa !5
  %44 = load ptr, ptr %10, align 8, !tbaa !5
  %45 = call i64 @cell_index(ptr noundef %44)
  %46 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %43, ptr noundef @.str.96, i64 noundef %45) #5
  %47 = load ptr, ptr @stderr, align 8, !tbaa !5
  %48 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %47, ptr noundef @.str.9) #5
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %60

49:                                               ; preds = %36
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = load ptr, ptr %10, align 8, !tbaa !5
  %52 = call ptr @symname(ptr noundef %51)
  %53 = call i32 @strcasecmp(ptr noundef %50, ptr noundef %52) #6
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %57, label %55

55:                                               ; preds = %49
  %56 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %56, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %60

57:                                               ; preds = %49
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = call ptr @list_next(ptr noundef %58)
  store ptr %59, ptr %9, align 8, !tbaa !5
  store i32 0, ptr %7, align 4
  br label %60

60:                                               ; preds = %57, %55, %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %61 = load i32, ptr %7, align 4
  switch i32 %61, label %66 [
    i32 0, label %62
  ]

62:                                               ; preds = %60
  br label %32, !llvm.loop !11

63:                                               ; preds = %32
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = call ptr @list_next(ptr noundef %64)
  store ptr %65, ptr %6, align 8, !tbaa !5
  store i32 0, ptr %7, align 4
  br label %66

66:                                               ; preds = %63, %60
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %67 = load i32, ptr %7, align 4
  switch i32 %67, label %70 [
    i32 0, label %68
  ]

68:                                               ; preds = %66
  br label %23, !llvm.loop !13

69:                                               ; preds = %23
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %70

70:                                               ; preds = %69, %66, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %71 = load ptr, ptr %3, align 8
  ret ptr %71
}

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 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 = { 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 #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 = !{!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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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.95 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.96 = external hidden unnamed_addr constant [50 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 i32 @cell_type(ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @get_car(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: mustprogress nofree nounwind willreturn memory(read)
declare i32 @strcasecmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @lookup_symbol(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #3 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = tail call i32 @cell_type(ptr noundef %4)
  %6 = icmp eq i32 %5, 2
  br i1 %6, label %.preheader, label %8

.preheader:                                       ; preds = %2
  %7 = tail call i32 @not_nil(ptr noundef %4)
  %.not36 = icmp eq i32 %7, 0
  br i1 %.not36, label %.thread29, label %.lr.ph38

8:                                                ; preds = %2
  %9 = load ptr, ptr @stderr, align 8, !tbaa !10
  %10 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef nonnull @.str.95) #4
  br label %.thread29.sink.split

.lr.ph38:                                         ; preds = %.preheader, %._crit_edge
  %.01937 = phi ptr [ %26, %._crit_edge ], [ %4, %.preheader ]
  %11 = tail call ptr @get_car(ptr noundef %.01937)
  %12 = tail call ptr @get_car(ptr noundef %11)
  %13 = tail call i32 @not_nil(ptr noundef %12)
  %.not2334 = icmp eq i32 %13, 0
  br i1 %.not2334, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph38, %23
  %.01735 = phi ptr [ %24, %23 ], [ %12, %.lr.ph38 ]
  %14 = tail call ptr @get_car(ptr noundef %.01735)
  %15 = tail call i32 @atom_type(ptr noundef %14)
  %.not24 = icmp eq i32 %15, 2
  br i1 %.not24, label %16, label %20

16:                                               ; preds = %.lr.ph
  %17 = load ptr, ptr @stderr, align 8, !tbaa !10
  %18 = tail call i64 @cell_index(ptr noundef %14)
  %19 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef nonnull @.str.96, i64 noundef %18) #4
  br label %.thread29.sink.split

20:                                               ; preds = %.lr.ph
  %21 = tail call ptr @symname(ptr noundef %14)
  %22 = tail call i32 @strcasecmp(ptr noundef %1, ptr noundef %21) #5
  %.not25 = icmp eq i32 %22, 0
  br i1 %.not25, label %.thread29, label %23

23:                                               ; preds = %20
  %24 = tail call ptr @list_next(ptr noundef %.01735)
  %25 = tail call i32 @not_nil(ptr noundef %24)
  %.not23 = icmp eq i32 %25, 0
  br i1 %.not23, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %23, %.lr.ph38
  %26 = tail call ptr @list_next(ptr noundef %.01937)
  %27 = tail call i32 @not_nil(ptr noundef %26)
  %.not = icmp eq i32 %27, 0
  br i1 %.not, label %.thread29, label %.lr.ph38, !llvm.loop !13

.thread29.sink.split:                             ; preds = %8, %16
  %28 = load ptr, ptr @stderr, align 8, !tbaa !10
  %29 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef nonnull @.str.9) #4
  br label %.thread29

.thread29:                                        ; preds = %._crit_edge, %20, %.thread29.sink.split, %.preheader
  %.4 = phi ptr [ null, %.preheader ], [ null, %.thread29.sink.split ], [ %14, %20 ], [ null, %._crit_edge ]
  ret ptr %.4
}

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 = { 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 #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 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, !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: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass