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

@.str.42 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [8 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 willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @set_head_commit_relative(i64 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @reset_head_to_master() #2

; Function Attrs: nounwind uwtable
define dso_local void @reset_head_command(i32 noundef %0, ptr noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  store i32 %0, ptr %3, align 4, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  %8 = call i32 @status(ptr noundef @.str.42)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %70, %2
  %10 = load i32, ptr %5, align 4, !tbaa !5
  %11 = load i32, ptr %3, align 4, !tbaa !5
  %12 = icmp slt i32 %10, %11
  br i1 %12, label %14, label %13

13:                                               ; preds = %9
  store i32 2, ptr %6, align 4
  br label %73

14:                                               ; preds = %9
  %15 = load ptr, ptr %4, align 8, !tbaa !9
  %16 = load i32, ptr %5, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds ptr, ptr %15, i64 %17
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = call i32 @strcmp(ptr noundef @.str.43, ptr noundef %19) #6
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %22, label %30

22:                                               ; preds = %14
  %23 = load ptr, ptr %4, align 8, !tbaa !9
  %24 = load i32, ptr %5, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds ptr, ptr %23, i64 %25
  %27 = load ptr, ptr %26, align 8, !tbaa !9
  %28 = call i32 @strcmp(ptr noundef @.str.44, ptr noundef %27) #6
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %31, label %30

30:                                               ; preds = %22, %14
  store i32 2, ptr %6, align 4
  br label %73

31:                                               ; preds = %22
  %32 = load ptr, ptr %4, align 8, !tbaa !9
  %33 = load i32, ptr %5, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds ptr, ptr %32, i64 %34
  %36 = load ptr, ptr %35, align 8, !tbaa !9
  %37 = call i32 @strcmp(ptr noundef @.str.45, ptr noundef %36) #6
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %40, label %39

39:                                               ; preds = %31
  call void @reset_head_to_master()
  store i32 1, ptr %6, align 4
  br label %73

40:                                               ; preds = %31
  %41 = load ptr, ptr %4, align 8, !tbaa !9
  %42 = load i32, ptr %5, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds ptr, ptr %41, i64 %43
  %45 = load ptr, ptr %44, align 8, !tbaa !9
  %46 = call i32 @strncmp(ptr noundef @.str.46, ptr noundef %45, i64 noundef 7) #6
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %58, label %48

48:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %49 = load ptr, ptr %4, align 8, !tbaa !9
  %50 = load i32, ptr %5, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds ptr, ptr %49, i64 %51
  %53 = load ptr, ptr %52, align 8, !tbaa !9
  %54 = getelementptr inbounds i8, ptr %53, i64 7
  %55 = call i32 @atoi(ptr noundef %54) #6
  %56 = sext i32 %55 to i64
  store i64 %56, ptr %7, align 8, !tbaa !11
  %57 = load i64, ptr %7, align 8, !tbaa !11
  call void @set_head_commit_relative(i64 noundef %57)
  store i32 1, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %73

58:                                               ; preds = %40
  %59 = load ptr, ptr %4, align 8, !tbaa !9
  %60 = load i32, ptr %5, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds ptr, ptr %59, i64 %61
  %63 = load ptr, ptr %62, align 8, !tbaa !9
  %64 = load ptr, ptr %4, align 8, !tbaa !9
  %65 = load i32, ptr %5, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds ptr, ptr %64, i64 %66
  %68 = load ptr, ptr %67, align 8, !tbaa !9
  %69 = call i64 @strlen(ptr noundef %68) #6
  call void @set_head_commit(ptr noundef %63, i64 noundef %69)
  store i32 1, ptr %6, align 4
  br label %73

70:                                               ; No predecessors!
  %71 = load i32, ptr %5, align 4, !tbaa !5
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %5, align 4, !tbaa !5
  br label %9, !llvm.loop !13

73:                                               ; preds = %58, %48, %39, %30, %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  %74 = load i32, ptr %6, align 4
  switch i32 %74, label %76 [
    i32 2, label %75
    i32 1, label %75
  ]

75:                                               ; preds = %73, %73
  ret void

76:                                               ; preds = %73
  unreachable
}

declare i32 @status(ptr noundef) #3

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

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr noundef nonnull) #4

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { "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 = { inlinehint nounwind willreturn memory(read) 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

@.str.42 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [8 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @set_head_commit_relative(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @reset_head_to_master() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @reset_head_command(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 {
  %3 = tail call i32 @status(ptr noundef nonnull @.str.42) #4
  %4 = icmp sgt i32 %0, 1
  br i1 %4, label %5, label %22

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) @.str.43, ptr noundef nonnull dereferenceable(1) %7) #5
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %22, label %9

9:                                                ; preds = %5
  %10 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) @.str.44, ptr noundef nonnull dereferenceable(1) %7) #5
  %.not16 = icmp eq i32 %10, 0
  br i1 %.not16, label %22, label %11

11:                                               ; preds = %9
  %12 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) @.str.45, ptr noundef nonnull dereferenceable(1) %7) #5
  %.not17 = icmp eq i32 %12, 0
  br i1 %.not17, label %13, label %14

13:                                               ; preds = %11
  tail call void @reset_head_to_master()
  br label %22

14:                                               ; preds = %11
  %15 = tail call i32 @strncmp(ptr noundef nonnull dereferenceable(1) @.str.46, ptr noundef nonnull dereferenceable(1) %7, i64 noundef 7) #5
  %.not18 = icmp eq i32 %15, 0
  br i1 %.not18, label %16, label %20

16:                                               ; preds = %14
  %17 = getelementptr inbounds i8, ptr %7, i64 7
  %18 = tail call i32 @atoi(ptr nocapture noundef %17) #5
  %19 = sext i32 %18 to i64
  tail call void @set_head_commit_relative(i64 noundef %19)
  br label %22

20:                                               ; preds = %14
  %21 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %7) #5
  tail call void @set_head_commit(ptr noundef %7, i64 noundef %21)
  br label %22

22:                                               ; preds = %5, %9, %2, %20, %16, %13
  ret void
}

declare i32 @status(ptr noundef) local_unnamed_addr #2

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

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr nocapture noundef nonnull) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #0

attributes #0 = { 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 #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 = { "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 mustprogress nofree nounwind willreturn memory(read) 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 }
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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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