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

; 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.revert_opts = type { i32, i32, %struct.strbuf_list, i32, i32, i8, i32, i32, i32 }
%struct.strbuf_list = type { ptr, ptr, i64 }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@rev_opts = external dso_local global %struct.revert_opts, align 8
@.str.38 = external hidden unnamed_addr constant [41 x i8], align 1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #0

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #1

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

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

declare i64 @make_commit_list(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @revert_to_nth_commit(ptr noundef, i64 noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local i32 @revert_files_commit(ptr noundef, i64 noundef) #4

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

declare i32 @status(ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @checkout(i32 noundef %0, ptr noundef %1) #4 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  %8 = call i32 @status(ptr noundef @.str.6)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %9 = load i32, ptr %4, align 4, !tbaa !5
  %10 = load ptr, ptr %5, align 8, !tbaa !9
  %11 = call i32 @revert_parse_options(i32 noundef %9, ptr noundef %10)
  %12 = call i64 @make_commit_list(ptr noundef %6)
  %13 = load ptr, ptr %6, align 8, !tbaa !9
  %14 = icmp ne ptr %13, null
  br i1 %14, label %29, label %15

15:                                               ; preds = %2
  br label %16

16:                                               ; preds = %15
  %17 = load ptr, ptr @stderr, align 8, !tbaa !9
  %18 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef @.str) #5
  %19 = load ptr, ptr @stderr, align 8, !tbaa !9
  %20 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef @.str.1) #5
  %21 = load ptr, ptr @stderr, align 8, !tbaa !9
  %22 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef @.str.2) #5
  %23 = load ptr, ptr @stderr, align 8, !tbaa !9
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef @.str.3) #5
  %25 = load ptr, ptr @stderr, align 8, !tbaa !9
  %26 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef @.str.38) #5
  call void @exit(i32 noundef 1) #6
  unreachable

27:                                               ; No predecessors!
  br label %28

28:                                               ; preds = %27
  br label %29

29:                                               ; preds = %28, %2
  %30 = load i32, ptr getelementptr inbounds (%struct.revert_opts, ptr @rev_opts, i32 0, i32 4), align 4, !tbaa !11
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %36

32:                                               ; preds = %29
  %33 = load i32, ptr getelementptr inbounds (%struct.revert_opts, ptr @rev_opts, i32 0, i32 1), align 4, !tbaa !15
  %34 = sext i32 %33 to i64
  %35 = call i32 @revert_files_commit(ptr noundef getelementptr inbounds (%struct.revert_opts, ptr @rev_opts, i32 0, i32 2), i64 noundef %34)
  br label %50

36:                                               ; preds = %29
  %37 = load i32, ptr getelementptr inbounds (%struct.revert_opts, ptr @rev_opts, i32 0, i32 6), align 4, !tbaa !16
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %44

39:                                               ; preds = %36
  %40 = load ptr, ptr %6, align 8, !tbaa !9
  %41 = load i32, ptr getelementptr inbounds (%struct.revert_opts, ptr @rev_opts, i32 0, i32 1), align 4, !tbaa !15
  %42 = sext i32 %41 to i64
  %43 = call i32 @revert_to_nth_commit(ptr noundef %40, i64 noundef %42)
  br label %49

44:                                               ; preds = %36
  %45 = load i32, ptr getelementptr inbounds (%struct.revert_opts, ptr @rev_opts, i32 0, i32 8), align 4, !tbaa !17
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %47, label %48

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

48:                                               ; preds = %44
  br label %49

49:                                               ; preds = %48, %39
  br label %50

50:                                               ; preds = %49, %32
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %51

51:                                               ; preds = %50, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %52 = load i32, ptr %3, align 4
  ret i32 %52
}

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 = { noreturn 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { noreturn 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, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 36}
!12 = !{!"revert_opts", !6, i64 0, !6, i64 4, !13, i64 8, !6, i64 32, !6, i64 36, !7, i64 40, !6, i64 44, !6, i64 48, !6, i64 52}
!13 = !{!"strbuf_list", !10, i64 0, !10, i64 8, !14, i64 16}
!14 = !{!"long", !7, i64 0}
!15 = !{!12, !6, i64 4}
!16 = !{!12, !6, i64 44}
!17 = !{!12, !6, i64 52}


; 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.revert_opts = type { i32, i32, %struct.strbuf_list, i32, i32, i8, i32, i32, i32 }
%struct.strbuf_list = type { ptr, ptr, i64 }

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@rev_opts = external dso_local global %struct.revert_opts, align 8
@.str.38 = external hidden unnamed_addr constant [41 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: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #1

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

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

declare i64 @make_commit_list(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @revert_to_nth_commit(ptr noundef, i64 noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare dso_local i32 @revert_files_commit(ptr noundef, i64 noundef) local_unnamed_addr #4

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

declare i32 @status(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @checkout(i32 noundef %0, ptr noundef %1) local_unnamed_addr #4 {
  %3 = alloca ptr, align 8
  %4 = tail call i32 @status(ptr noundef nonnull @.str.6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %5 = tail call i32 @revert_parse_options(i32 noundef %0, ptr noundef %1)
  %6 = call i64 @make_commit_list(ptr noundef nonnull %3) #5
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %8, label %19

8:                                                ; preds = %2
  %9 = load ptr, ptr @stderr, align 8, !tbaa !5
  %10 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef nonnull @.str) #6
  %11 = load ptr, ptr @stderr, align 8, !tbaa !5
  %12 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.1) #6
  %13 = load ptr, ptr @stderr, align 8, !tbaa !5
  %14 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %13, ptr noundef nonnull @.str.2) #6
  %15 = load ptr, ptr @stderr, align 8, !tbaa !5
  %16 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull @.str.3) #6
  %17 = load ptr, ptr @stderr, align 8, !tbaa !5
  %18 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef nonnull @.str.38) #6
  call void @exit(i32 noundef 1) #7
  unreachable

19:                                               ; preds = %2
  %20 = load i32, ptr getelementptr inbounds (i8, ptr @rev_opts, i64 36), align 4, !tbaa !9
  %.not2 = icmp eq i32 %20, 0
  br i1 %.not2, label %25, label %21

21:                                               ; preds = %19
  %22 = load i32, ptr getelementptr inbounds (i8, ptr @rev_opts, i64 4), align 4, !tbaa !14
  %23 = sext i32 %22 to i64
  %24 = call i32 @revert_files_commit(ptr noundef nonnull getelementptr inbounds (i8, ptr @rev_opts, i64 8), i64 noundef %23)
  br label %31

25:                                               ; preds = %19
  %26 = load i32, ptr getelementptr inbounds (i8, ptr @rev_opts, i64 44), align 4, !tbaa !15
  %.not3 = icmp eq i32 %26, 0
  br i1 %.not3, label %31, label %27

27:                                               ; preds = %25
  %28 = load i32, ptr getelementptr inbounds (i8, ptr @rev_opts, i64 4), align 4, !tbaa !14
  %29 = sext i32 %28 to i64
  %30 = call i32 @revert_to_nth_commit(ptr noundef nonnull %7, i64 noundef %29)
  br label %31

31:                                               ; preds = %25, %21, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  ret i32 0
}

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 = { noreturn 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { cold nounwind }
attributes #7 = { noreturn 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, !11, i64 36}
!10 = !{!"revert_opts", !11, i64 0, !11, i64 4, !12, i64 8, !11, i64 32, !11, i64 36, !7, i64 40, !11, i64 44, !11, i64 48, !11, i64 52}
!11 = !{!"int", !7, i64 0}
!12 = !{!"strbuf_list", !6, i64 0, !6, i64 8, !13, i64 16}
!13 = !{!"long", !7, i64 0}
!14 = !{!10, !11, i64 4}
!15 = !{!10, !11, i64 44}


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