; LLVM IR from recrsn/tinydb :: database (parse_create)

; 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.table_info = type { [32 x i8], i32, [32 x %struct.field], i64 }
%struct.field = type { [32 x i8], i64, i32 }

@.str.9 = external hidden unnamed_addr constant [16 x i8], align 1
@stdin = external global ptr, align 8
@.str.10 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @str_trim(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 i32 @str_to_field_type(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @write_table_info(ptr noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @parse_create(ptr noundef %0) #0 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca %struct.table_info, align 8
  %6 = alloca i32, align 4
  %7 = alloca [2048 x i8], align 16
  %8 = alloca i32, align 4
  %9 = alloca [16 x i8], align 16
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 1584, ptr %5) #6
  call void @llvm.memset.p0.i64(ptr align 8 %5, i8 0, i64 1584, i1 false)
  %10 = getelementptr inbounds %struct.table_info, ptr %5, i32 0, i32 1
  store i32 0, ptr %10, align 8, !tbaa !9
  %11 = getelementptr inbounds %struct.table_info, ptr %5, i32 0, i32 3
  store i64 0, ptr %11, align 8, !tbaa !13
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.table_info, ptr %5, i32 0, i32 0
  %14 = getelementptr inbounds [32 x i8], ptr %13, i64 0, i64 0
  %15 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef %12, ptr noundef @.str.9, ptr noundef %14) #6
  store i32 %15, ptr %4, align 4, !tbaa !14
  %16 = load i32, ptr %4, align 4, !tbaa !14
  %17 = icmp ne i32 %16, 1
  br i1 %17, label %18, label %19

18:                                               ; preds = %1
  store i1 false, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %71

19:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 2048, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %8, align 4, !tbaa !14
  br label %20

20:                                               ; preds = %64, %19
  %21 = getelementptr inbounds [2048 x i8], ptr %7, i64 0, i64 0
  %22 = load ptr, ptr @stdin, align 8, !tbaa !5
  %23 = call ptr @fgets(ptr noundef %21, i32 noundef 2048, ptr noundef %22)
  %24 = getelementptr inbounds [2048 x i8], ptr %7, i64 0, i64 0
  %25 = call ptr @str_trim(ptr noundef %24)
  %26 = getelementptr inbounds [2048 x i8], ptr %7, i64 0, i64 0
  %27 = call i32 @strncmp(ptr noundef @.str.10, ptr noundef %26, i64 noundef 3) #7
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %63

29:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #6
  %30 = getelementptr inbounds [2048 x i8], ptr %7, i64 0, i64 0
  %31 = getelementptr inbounds %struct.table_info, ptr %5, i32 0, i32 2
  %32 = load i32, ptr %8, align 4, !tbaa !14
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [32 x %struct.field], ptr %31, i64 0, i64 %33
  %35 = getelementptr inbounds %struct.field, ptr %34, i32 0, i32 0
  %36 = getelementptr inbounds [32 x i8], ptr %35, i64 0, i64 0
  %37 = getelementptr inbounds [16 x i8], ptr %9, i64 0, i64 0
  %38 = getelementptr inbounds %struct.table_info, ptr %5, i32 0, i32 2
  %39 = load i32, ptr %8, align 4, !tbaa !14
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [32 x %struct.field], ptr %38, i64 0, i64 %40
  %42 = getelementptr inbounds %struct.field, ptr %41, i32 0, i32 1
  %43 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef %30, ptr noundef @.str.11, ptr noundef %36, ptr noundef %37, ptr noundef %42) #6
  store i32 %43, ptr %4, align 4, !tbaa !14
  %44 = load i32, ptr %4, align 4, !tbaa !14
  %45 = icmp ne i32 %44, 3
  br i1 %45, label %46, label %47

46:                                               ; preds = %29
  store i1 false, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %60

47:                                               ; preds = %29
  %48 = getelementptr inbounds [16 x i8], ptr %9, i64 0, i64 0
  %49 = call i32 @str_to_field_type(ptr noundef %48)
  %50 = getelementptr inbounds %struct.table_info, ptr %5, i32 0, i32 2
  %51 = load i32, ptr %8, align 4, !tbaa !14
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [32 x %struct.field], ptr %50, i64 0, i64 %52
  %54 = getelementptr inbounds %struct.field, ptr %53, i32 0, i32 2
  store i32 %49, ptr %54, align 8, !tbaa !15
  %55 = load i32, ptr %8, align 4, !tbaa !14
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %8, align 4, !tbaa !14
  %57 = getelementptr inbounds %struct.table_info, ptr %5, i32 0, i32 1
  %58 = load i32, ptr %57, align 8, !tbaa !9
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %57, align 8, !tbaa !9
  store i32 0, ptr %6, align 4
  br label %60

60:                                               ; preds = %47, %46
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #6
  %61 = load i32, ptr %6, align 4
  switch i32 %61, label %70 [
    i32 0, label %62
  ]

62:                                               ; preds = %60
  br label %63

63:                                               ; preds = %62, %20
  br label %64

64:                                               ; preds = %63
  %65 = getelementptr inbounds [2048 x i8], ptr %7, i64 0, i64 0
  %66 = call i32 @strcmp(ptr noundef %65, ptr noundef @.str.12) #7
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %20, label %68, !llvm.loop !17

68:                                               ; preds = %64
  %69 = call zeroext i1 @write_table_info(ptr noundef %5)
  store i1 %69, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %70

70:                                               ; preds = %68, %60
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 2048, ptr %7) #6
  br label %71

71:                                               ; preds = %70, %18
  call void @llvm.lifetime.end.p0(i64 1584, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  %72 = load i1, ptr %2, align 1
  ret i1 %72
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: nounwind
declare i32 @__isoc99_sscanf(ptr noundef, ptr noundef, ...) #4

declare ptr @fgets(ptr noundef, i32 noundef, ptr noundef) #5

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strncmp(ptr noundef, ptr noundef, i64 noundef) #2

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { "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 #6 = { nounwind }
attributes #7 = { 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, !11, i64 32}
!10 = !{!"", !7, i64 0, !11, i64 32, !7, i64 40, !12, i64 1576}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !12, i64 1576}
!14 = !{!11, !11, i64 0}
!15 = !{!16, !11, i64 40}
!16 = !{!"", !7, i64 0, !12, i64 32, !11, i64 40}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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

%struct.table_info = type { [32 x i8], i32, [32 x %struct.field], i64 }
%struct.field = type { [32 x i8], i64, i32 }

@.str.9 = external hidden unnamed_addr constant [16 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.10 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @str_trim(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress 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 i32 @str_to_field_type(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @write_table_info(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @parse_create(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = alloca %struct.table_info, align 8
  %3 = alloca [2048 x i8], align 16
  %4 = alloca [16 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 1584, ptr nonnull %2) #5
  %5 = getelementptr inbounds i8, ptr %2, i64 32
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1584) %2, i8 0, i64 1584, i1 false)
  %6 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef %0, ptr noundef nonnull @.str.9, ptr noundef nonnull %2) #5
  %.not = icmp eq i32 %6, 1
  br i1 %.not, label %7, label %31

7:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 2048, ptr nonnull %3) #5
  %8 = getelementptr inbounds i8, ptr %2, i64 40
  br label %9

9:                                                ; preds = %26, %7
  %.0 = phi i32 [ 0, %7 ], [ %.2, %26 ]
  %10 = load ptr, ptr @stdin, align 8, !tbaa !5
  %11 = call ptr @fgets(ptr noundef nonnull %3, i32 noundef 2048, ptr noundef %10)
  %12 = call ptr @str_trim(ptr noundef nonnull %3)
  %13 = call i32 @strncmp(ptr noundef nonnull dereferenceable(1) @.str.10, ptr noundef nonnull dereferenceable(1) %3, i64 noundef 3) #6
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %15, label %26

15:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #5
  %16 = sext i32 %.0 to i64
  %17 = getelementptr inbounds [32 x %struct.field], ptr %8, i64 0, i64 %16
  %18 = getelementptr inbounds i8, ptr %17, i64 32
  %19 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef nonnull %3, ptr noundef nonnull @.str.11, ptr noundef nonnull %17, ptr noundef nonnull %4, ptr noundef nonnull %18) #5
  %.not12 = icmp eq i32 %19, 3
  br i1 %.not12, label %.thread, label %25

.thread:                                          ; preds = %15
  %20 = call i32 @str_to_field_type(ptr noundef nonnull %4)
  %21 = getelementptr inbounds i8, ptr %17, i64 40
  store i32 %20, ptr %21, align 8, !tbaa !9
  %22 = add nsw i32 %.0, 1
  %23 = load i32, ptr %5, align 8, !tbaa !13
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %5, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #5
  br label %26

25:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #5
  br label %30

26:                                               ; preds = %.thread, %9
  %.2 = phi i32 [ %.0, %9 ], [ %22, %.thread ]
  %27 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) @.str.12) #6
  %.not13 = icmp eq i32 %27, 0
  br i1 %.not13, label %28, label %9, !llvm.loop !15

28:                                               ; preds = %26
  %29 = call zeroext i1 @write_table_info(ptr noundef nonnull %2)
  br label %30

30:                                               ; preds = %25, %28
  %.3 = phi i1 [ %29, %28 ], [ false, %25 ]
  call void @llvm.lifetime.end.p0(i64 2048, ptr nonnull %3) #5
  br label %31

31:                                               ; preds = %1, %30
  %.4 = phi i1 [ %.3, %30 ], [ false, %1 ]
  call void @llvm.lifetime.end.p0(i64 1584, ptr nonnull %2) #5
  ret i1 %.4
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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

; Function Attrs: nofree nounwind
declare noundef ptr @fgets(ptr noundef, i32 noundef, ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strncmp(ptr nocapture noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #2

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass