; LLVM IR from CLASS-SZ/class_sz :: class-sz/tools (parser)

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

@.str.4 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [31 x i8], align 1
@__func__.parser_read_string = external hidden unnamed_addr constant [19 x i8], align 1

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

declare void @class_protect_sprintf(ptr noundef, ptr noundef, ...) #1

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

; Function Attrs: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local i32 @parser_read_string(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #4 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca [2048 x i8], align 16
  %16 = alloca [2048 x i8], align 16
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %17 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 0, ptr %17, align 4, !tbaa !9
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %37, %5
  %19 = load i32, ptr %12, align 4, !tbaa !9
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.file_content, ptr %20, i32 0, i32 1
  %22 = load i32, ptr %21, align 8, !tbaa !11
  %23 = icmp slt i32 %19, %22
  br i1 %23, label %24, label %35

24:                                               ; preds = %18
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.file_content, ptr %25, i32 0, i32 2
  %27 = load ptr, ptr %26, align 8, !tbaa !13
  %28 = load i32, ptr %12, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [1024 x i8], ptr %27, i64 %29
  %31 = getelementptr inbounds [1024 x i8], ptr %30, i64 0, i64 0
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = call i32 @strcmp(ptr noundef %31, ptr noundef %32) #6
  %34 = icmp ne i32 %33, 0
  br label %35

35:                                               ; preds = %24, %18
  %36 = phi i1 [ false, %18 ], [ %34, %24 ]
  br i1 %36, label %37, label %40

37:                                               ; preds = %35
  %38 = load i32, ptr %12, align 4, !tbaa !9
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %12, align 4, !tbaa !9
  br label %18, !llvm.loop !14

40:                                               ; preds = %35
  %41 = load i32, ptr %12, align 4, !tbaa !9
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.file_content, ptr %42, i32 0, i32 1
  %44 = load i32, ptr %43, align 8, !tbaa !11
  %45 = icmp eq i32 %41, %44
  br i1 %45, label %46, label %47

46:                                               ; preds = %40
  store i32 0, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %99

47:                                               ; preds = %40
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = getelementptr inbounds [1024 x i8], ptr %48, i64 0, i64 0
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.file_content, ptr %50, i32 0, i32 3
  %52 = load ptr, ptr %51, align 8, !tbaa !16
  %53 = load i32, ptr %12, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [1024 x i8], ptr %52, i64 %54
  %56 = getelementptr inbounds [1024 x i8], ptr %55, i64 0, i64 0
  %57 = call ptr @strcpy(ptr noundef %49, ptr noundef %56) #5
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 1, ptr %58, align 4, !tbaa !9
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.file_content, ptr %59, i32 0, i32 4
  %61 = load ptr, ptr %60, align 8, !tbaa !17
  %62 = load i32, ptr %12, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds i16, ptr %61, i64 %63
  store i16 1, ptr %64, align 2, !tbaa !18
  %65 = load i32, ptr %12, align 4, !tbaa !9
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %13, align 4, !tbaa !9
  br label %67

67:                                               ; preds = %95, %47
  %68 = load i32, ptr %13, align 4, !tbaa !9
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.file_content, ptr %69, i32 0, i32 1
  %71 = load i32, ptr %70, align 8, !tbaa !11
  %72 = icmp slt i32 %68, %71
  br i1 %72, label %73, label %98

73:                                               ; preds = %67
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.file_content, ptr %74, i32 0, i32 2
  %76 = load ptr, ptr %75, align 8, !tbaa !13
  %77 = load i32, ptr %13, align 4, !tbaa !9
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [1024 x i8], ptr %76, i64 %78
  %80 = getelementptr inbounds [1024 x i8], ptr %79, i64 0, i64 0
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = call i32 @strcmp(ptr noundef %80, ptr noundef %81) #6
  %83 = icmp eq i32 %82, 0
  br i1 %83, label %84, label %94

84:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 2048, ptr %15) #5
  %85 = getelementptr inbounds [2048 x i8], ptr %15, i64 0, i64 0
  %86 = load ptr, ptr %8, align 8, !tbaa !5
  %87 = load ptr, ptr %7, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.file_content, ptr %87, i32 0, i32 0
  %89 = load ptr, ptr %88, align 8, !tbaa !20
  call void (ptr, ptr, ...) @class_protect_sprintf(ptr noundef %85, ptr noundef @.str.24, ptr noundef %86, ptr noundef %89)
  call void @llvm.lifetime.start.p0(i64 2048, ptr %16) #5
  %90 = getelementptr inbounds [2048 x i8], ptr %16, i64 0, i64 0
  %91 = getelementptr inbounds [2048 x i8], ptr %15, i64 0, i64 0
  call void (ptr, ptr, ...) @class_protect_sprintf(ptr noundef %90, ptr noundef @.str.8, ptr noundef @.str.25, ptr noundef %91)
  %92 = load ptr, ptr %11, align 8, !tbaa !5
  %93 = getelementptr inbounds [2048 x i8], ptr %16, i64 0, i64 0
  call void (ptr, ptr, ...) @class_protect_sprintf(ptr noundef %92, ptr noundef @.str.4, ptr noundef @__func__.parser_read_string, i32 noundef 371, ptr noundef %93)
  call void @llvm.lifetime.end.p0(i64 2048, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 2048, ptr %15) #5
  store i32 1, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %99

94:                                               ; preds = %73
  br label %95

95:                                               ; preds = %94
  %96 = load i32, ptr %13, align 4, !tbaa !9
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %13, align 4, !tbaa !9
  br label %67, !llvm.loop !21

98:                                               ; preds = %67
  store i32 0, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %99

99:                                               ; preds = %98, %84, %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  %100 = load i32, ptr %6, align 4
  ret i32 %100
}

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


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

@.str.4 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [31 x i8], align 1
@__func__.parser_read_string = external hidden unnamed_addr constant [19 x i8], align 1

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

declare void @class_protect_sprintf(ptr noundef, ptr noundef, ...) local_unnamed_addr #1

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @parser_read_string(ptr nocapture noundef readonly %0, ptr noundef %1, ptr noundef %2, ptr nocapture noundef writeonly %3, ptr noundef %4) local_unnamed_addr #4 {
  %6 = alloca [2048 x i8], align 16
  %7 = alloca [2048 x i8], align 16
  store i32 0, ptr %3, align 4, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load i32, ptr %8, align 8, !tbaa !9
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %5
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  %12 = load ptr, ptr %11, align 8, !tbaa !12
  %wide.trip.count = zext nneg i32 %9 to i64
  br label %13

13:                                               ; preds = %.lr.ph, %16
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %16 ]
  %14 = getelementptr inbounds [1024 x i8], ptr %12, i64 %indvars.iv
  %15 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %14, ptr noundef nonnull dereferenceable(1) %1) #5
  %.not = icmp eq i32 %15, 0
  br i1 %.not, label %.critedge.loopexit, label %16

16:                                               ; preds = %13
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %13, !llvm.loop !13

.critedge.loopexit:                               ; preds = %13
  %17 = trunc nuw nsw i64 %indvars.iv to i32
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %5
  %.025.lcssa = phi i32 [ 0, %5 ], [ %17, %.critedge.loopexit ]
  %18 = icmp eq i32 %.025.lcssa, %9
  br i1 %18, label %.loopexit, label %19

19:                                               ; preds = %.critedge
  %20 = getelementptr inbounds i8, ptr %0, i64 24
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = zext i32 %.025.lcssa to i64
  %23 = getelementptr inbounds [1024 x i8], ptr %21, i64 %22
  %24 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) %23) #6
  store i32 1, ptr %3, align 4, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %0, i64 32
  %26 = load ptr, ptr %25, align 8, !tbaa !16
  %27 = getelementptr inbounds i16, ptr %26, i64 %22
  store i16 1, ptr %27, align 2, !tbaa !17
  %28 = load i32, ptr %8, align 8, !tbaa !9
  %29 = getelementptr inbounds i8, ptr %0, i64 16
  br label %30

30:                                               ; preds = %33, %19
  %indvars.iv34 = phi i64 [ %indvars.iv.next35, %33 ], [ %22, %19 ]
  %indvars.iv.next35 = add nuw nsw i64 %indvars.iv34, 1
  %31 = trunc nuw i64 %indvars.iv.next35 to i32
  %32 = icmp sgt i32 %28, %31
  br i1 %32, label %33, label %.loopexit

33:                                               ; preds = %30
  %34 = load ptr, ptr %29, align 8, !tbaa !12
  %35 = getelementptr inbounds [1024 x i8], ptr %34, i64 %indvars.iv.next35
  %36 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %35, ptr noundef nonnull dereferenceable(1) %1) #5
  %37 = icmp eq i32 %36, 0
  br i1 %37, label %38, label %30, !llvm.loop !19

38:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 2048, ptr nonnull %6) #6
  %39 = load ptr, ptr %0, align 8, !tbaa !20
  call void (ptr, ptr, ...) @class_protect_sprintf(ptr noundef nonnull %6, ptr noundef nonnull @.str.24, ptr noundef %1, ptr noundef %39) #6
  call void @llvm.lifetime.start.p0(i64 2048, ptr nonnull %7) #6
  call void (ptr, ptr, ...) @class_protect_sprintf(ptr noundef nonnull %7, ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.25, ptr noundef nonnull %6) #6
  call void (ptr, ptr, ...) @class_protect_sprintf(ptr noundef %4, ptr noundef nonnull @.str.4, ptr noundef nonnull @__func__.parser_read_string, i32 noundef 371, ptr noundef nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 2048, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 2048, ptr nonnull %6) #6
  br label %.loopexit

.loopexit:                                        ; preds = %16, %30, %.critedge, %38
  %.026 = phi i32 [ 1, %38 ], [ 0, %.critedge ], [ 0, %30 ], [ 0, %16 ]
  ret i32 %.026
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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(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 #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 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"file_content", !11, i64 0, !6, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!10, !11, i64 16}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!10, !11, i64 24}
!16 = !{!10, !11, i64 32}
!17 = !{!18, !18, i64 0}
!18 = !{!"short", !7, i64 0}
!19 = distinct !{!19, !14}
!20 = !{!10, !11, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass