; LLVM IR from jspd-group/pegit :: src (commit)

; 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.commit_list = type { i64, ptr, ptr }
%struct.commit = type { i16, [20 x i8], [50 x i8], [41 x i8], ptr, %struct.strbuf, %struct.strbuf, %struct.timestamp, i64, i64 }
%struct.strbuf = type { i64, i64, ptr }
%struct.timestamp = type { i64, ptr }

@stdout = external global ptr, align 8
@.str.80 = external hidden unnamed_addr constant [15 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

; 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 i32 @fprintf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
declare dso_local void @commit_list_del(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @make_commit_list(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @list_tags() #2 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  %4 = call i64 @make_commit_list(ptr noundef %1)
  %5 = load ptr, ptr %1, align 8, !tbaa !5
  %6 = icmp ne ptr %5, null
  br i1 %6, label %8, label %7

7:                                                ; preds = %0
  store i32 1, ptr %3, align 4
  br label %35

8:                                                ; preds = %0
  %9 = load ptr, ptr %1, align 8, !tbaa !5
  store ptr %9, ptr %2, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %30, %8
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %34

13:                                               ; preds = %10
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.commit_list, ptr %14, i32 0, i32 1
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = getelementptr inbounds %struct.commit, ptr %16, i32 0, i32 0
  %18 = load i16, ptr %17, align 8, !tbaa !12
  %19 = sext i16 %18 to i32
  %20 = and i32 %19, 1
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %22, label %30

22:                                               ; preds = %13
  %23 = load ptr, ptr @stdout, align 8, !tbaa !5
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.commit_list, ptr %24, i32 0, i32 1
  %26 = load ptr, ptr %25, align 8, !tbaa !9
  %27 = getelementptr inbounds %struct.commit, ptr %26, i32 0, i32 2
  %28 = getelementptr inbounds [50 x i8], ptr %27, i64 0, i64 0
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef @.str.80, ptr noundef %28) #3
  br label %30

30:                                               ; preds = %22, %13
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.commit_list, ptr %31, i32 0, i32 2
  %33 = load ptr, ptr %32, align 8, !tbaa !17
  store ptr %33, ptr %2, align 8, !tbaa !5
  br label %10, !llvm.loop !18

34:                                               ; preds = %10
  call void @commit_list_del(ptr noundef %1)
  store i32 0, ptr %3, align 4
  br label %35

35:                                               ; preds = %34, %7
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #3
  %36 = load i32, ptr %3, align 4
  switch i32 %36, label %38 [
    i32 0, label %37
    i32 1, label %37
  ]

37:                                               ; preds = %35, %35
  ret void

38:                                               ; preds = %35
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { 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 8}
!10 = !{!"commit_list", !11, i64 0, !6, i64 8, !6, i64 16}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !14, i64 0}
!13 = !{!"commit", !14, i64 0, !7, i64 2, !7, i64 22, !7, i64 72, !6, i64 120, !15, i64 128, !15, i64 152, !16, i64 176, !11, i64 192, !11, i64 200}
!14 = !{!"short", !7, i64 0}
!15 = !{!"strbuf", !11, i64 0, !11, i64 8, !6, i64 16}
!16 = !{!"timestamp", !11, i64 0, !6, i64 8}
!17 = !{!10, !6, i64 16}
!18 = distinct !{!18, !19}
!19 = !{!"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"

@stdout = external local_unnamed_addr global ptr, align 8
@.str.80 = external hidden unnamed_addr constant [15 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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @list_tags() local_unnamed_addr #2 {
  %1 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #3
  %2 = call i64 @make_commit_list(ptr noundef nonnull %1)
  %3 = load ptr, ptr %1, align 8, !tbaa !5
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %16, label %.preheader

.preheader:                                       ; preds = %0, %12
  %.07 = phi ptr [ %14, %12 ], [ %3, %0 ]
  %4 = getelementptr inbounds i8, ptr %.07, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %6 = load i16, ptr %5, align 8, !tbaa !12
  %7 = and i16 %6, 1
  %.not6 = icmp eq i16 %7, 0
  br i1 %.not6, label %12, label %8

8:                                                ; preds = %.preheader
  %9 = load ptr, ptr @stdout, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %5, i64 22
  %11 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef nonnull @.str.80, ptr noundef nonnull %10) #3
  br label %12

12:                                               ; preds = %8, %.preheader
  %13 = getelementptr inbounds i8, ptr %.07, i64 16
  %14 = load ptr, ptr %13, align 8, !tbaa !17
  %.not5 = icmp eq ptr %14, null
  br i1 %.not5, label %15, label %.preheader, !llvm.loop !18

15:                                               ; preds = %12
  call void @commit_list_del(ptr noundef nonnull %1)
  br label %16

16:                                               ; preds = %0, %15
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #3
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 8}
!10 = !{!"commit_list", !11, i64 0, !6, i64 8, !6, i64 16}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !14, i64 0}
!13 = !{!"commit", !14, i64 0, !7, i64 2, !7, i64 22, !7, i64 72, !6, i64 120, !15, i64 128, !15, i64 152, !16, i64 176, !11, i64 192, !11, i64 200}
!14 = !{!"short", !7, i64 0}
!15 = !{!"strbuf", !11, i64 0, !11, i64 8, !6, i64 16}
!16 = !{!"timestamp", !11, i64 0, !6, i64 8}
!17 = !{!10, !6, i64 16}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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