; 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 }
%struct.secd_parser = type { i32, ptr, i32, i32, [256 x i8], [256 x i8], i32 }

@stderr = external global ptr, align 8
@.str.60 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.112 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.113 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.114 = external hidden unnamed_addr constant [19 x i8], align 1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @lexnext(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local ptr @sexp_read(ptr noundef %0, ptr noundef %1) #2 {
  %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 i32, align 4
  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) #4
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.secd, ptr %9, i32 0, i32 6
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  store ptr %11, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = call i32 @lexnext(ptr noundef %12)
  store i32 %13, ptr %7, align 4, !tbaa !11
  switch i32 %13, label %61 [
    i32 40, label %14
    i32 -3, label %32
    i32 -2, label %38
    i32 -1, label %44
    i32 39, label %47
  ]

14:                                               ; preds = %2
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call ptr @read_list(ptr noundef %15, ptr noundef %16)
  store ptr %17, ptr %6, align 8, !tbaa !5
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.secd_parser, ptr %18, i32 0, i32 0
  %20 = load i32, ptr %19, align 8, !tbaa !13
  %21 = icmp ne i32 %20, 41
  br i1 %21, label %22, label %31

22:                                               ; preds = %14
  %23 = load ptr, ptr @stderr, align 8, !tbaa !5
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef @.str.114) #4
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %30

27:                                               ; preds = %22
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = call ptr @drop_cell(ptr noundef %28)
  br label %30

30:                                               ; preds = %27, %22
  store ptr null, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %67

31:                                               ; preds = %14
  br label %65

32:                                               ; preds = %2
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.secd_parser, ptr %34, i32 0, i32 3
  %36 = load i32, ptr %35, align 4, !tbaa !15
  %37 = call ptr @new_number(ptr noundef %33, i32 noundef %36)
  store ptr %37, ptr %6, align 8, !tbaa !5
  br label %65

38:                                               ; preds = %2
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.secd_parser, ptr %40, i32 0, i32 4
  %42 = getelementptr inbounds [256 x i8], ptr %41, i64 0, i64 0
  %43 = call ptr @new_symbol(ptr noundef %39, ptr noundef %42)
  store ptr %43, ptr %6, align 8, !tbaa !5
  br label %65

44:                                               ; preds = %2
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = call ptr @new_symbol(ptr noundef %45, ptr noundef @.str.60)
  store ptr %46, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %67

47:                                               ; preds = %2
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = call ptr @sexp_read(ptr noundef %48, ptr noundef %49)
  store ptr %50, ptr %6, align 8, !tbaa !5
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = call ptr @new_symbol(ptr noundef %52, ptr noundef @.str.112)
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.secd, ptr %56, i32 0, i32 6
  %58 = load ptr, ptr %57, align 8, !tbaa !9
  %59 = call ptr @new_cons(ptr noundef %54, ptr noundef %55, ptr noundef %58)
  %60 = call ptr @new_cons(ptr noundef %51, ptr noundef %53, ptr noundef %59)
  store ptr %60, ptr %6, align 8, !tbaa !5
  br label %65

61:                                               ; preds = %2
  %62 = load ptr, ptr @stderr, align 8, !tbaa !5
  %63 = load i32, ptr %7, align 4, !tbaa !11
  %64 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %62, ptr noundef @.str.113, i32 noundef %63) #4
  store ptr null, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %67

65:                                               ; preds = %47, %38, %32, %31
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %66, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %67

67:                                               ; preds = %65, %61, %44, %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %68 = load ptr, ptr %3, align 8
  ret ptr %68
}

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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, !6, i64 48}
!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 = !{!14, !12, i64 0}
!14 = !{!"secd_parser", !12, i64 0, !6, i64 8, !12, i64 16, !12, i64 20, !7, i64 24, !7, i64 280, !12, i64 536}
!15 = !{!14, !12, i64 20}


; 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.60 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.112 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.113 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.114 = external hidden unnamed_addr constant [19 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: nounwind uwtable
declare dso_local ptr @new_cons(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @new_number(ptr noundef, i32 noundef) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @lexnext(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local ptr @sexp_read(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = tail call i32 @lexnext(ptr noundef %1)
  switch i32 %3, label %28 [
    i32 40, label %4
    i32 -3, label %12
    i32 -2, label %16
    i32 -1, label %19
    i32 39, label %21
  ]

4:                                                ; preds = %2
  %5 = tail call ptr @read_list(ptr noundef %0, ptr noundef %1)
  %6 = load i32, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i32 %6, 41
  br i1 %.not, label %common.ret24, label %7

7:                                                ; preds = %4
  %8 = load ptr, ptr @stderr, align 8, !tbaa !11
  %9 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %8, ptr noundef nonnull @.str.114) #3
  %.not23 = icmp eq ptr %5, null
  br i1 %.not23, label %common.ret24, label %10

10:                                               ; preds = %7
  %11 = tail call ptr @drop_cell(ptr noundef nonnull %5)
  br label %common.ret24

12:                                               ; preds = %2
  %13 = getelementptr inbounds i8, ptr %1, i64 20
  %14 = load i32, ptr %13, align 4, !tbaa !12
  %15 = tail call ptr @new_number(ptr noundef %0, i32 noundef %14)
  br label %common.ret24

16:                                               ; preds = %2
  %17 = getelementptr inbounds i8, ptr %1, i64 24
  %18 = tail call ptr @new_symbol(ptr noundef %0, ptr noundef nonnull %17)
  br label %common.ret24

19:                                               ; preds = %2
  %20 = tail call ptr @new_symbol(ptr noundef %0, ptr noundef nonnull @.str.60)
  br label %common.ret24

common.ret24:                                     ; preds = %12, %16, %4, %7, %10, %28, %19, %21
  %common.ret24.op = phi ptr [ %27, %21 ], [ null, %28 ], [ %20, %19 ], [ null, %10 ], [ null, %7 ], [ %18, %16 ], [ %15, %12 ], [ %5, %4 ]
  ret ptr %common.ret24.op

21:                                               ; preds = %2
  %22 = getelementptr inbounds i8, ptr %0, i64 48
  %23 = tail call ptr @sexp_read(ptr noundef %0, ptr noundef %1)
  %24 = tail call ptr @new_symbol(ptr noundef %0, ptr noundef nonnull @.str.112)
  %25 = load ptr, ptr %22, align 8, !tbaa !13
  %26 = tail call ptr @new_cons(ptr noundef %0, ptr noundef %23, ptr noundef %25)
  %27 = tail call ptr @new_cons(ptr noundef %0, ptr noundef %24, ptr noundef %26)
  br label %common.ret24

28:                                               ; preds = %2
  %29 = load ptr, ptr @stderr, align 8, !tbaa !11
  %30 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %29, ptr noundef nonnull @.str.113, i32 noundef %3) #3
  br label %common.ret24
}

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 = { 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 = { 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 #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 0}
!6 = !{!"secd_parser", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 20, !8, i64 24, !8, i64 280, !7, i64 536}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!10, !10, i64 0}
!12 = !{!6, !7, i64 20}
!13 = !{!14, !10, i64 48}
!14 = !{!"secd", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass