; LLVM IR from holzschu/ios_system :: ssh-agent/y.tab (op_colon)

; 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.re_pattern_buffer = type { ptr, i64, i64, i64, ptr, ptr, i64, i8 }
%struct.regmatch_t = type { i32, i32 }
%struct.val = type { i32, %union.anon }
%union.anon = type { ptr }

@.str.11 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [3 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 uwtable
define dso_local ptr @op_colon(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %struct.re_pattern_buffer, align 8
  %6 = alloca [2 x %struct.regmatch_t], align 16
  %7 = alloca [256 x i8], align 16
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 64, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 256, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  call void @to_string(ptr noundef %10)
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  call void @to_string(ptr noundef %11)
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.val, ptr %12, i32 0, i32 1
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = call i32 @regcomp(ptr noundef %5, ptr noundef %14, i32 noundef 0)
  store i32 %15, ptr %8, align 4, !tbaa !10
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %22

17:                                               ; preds = %2
  %18 = load i32, ptr %8, align 4, !tbaa !10
  %19 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %20 = call i64 @regerror(i32 noundef %18, ptr noundef %5, ptr noundef %19, i64 noundef 256)
  %21 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  call void (i32, ptr, ...) @errx(i32 noundef 2, ptr noundef @.str.19, ptr noundef %21) #5
  unreachable

22:                                               ; preds = %2
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.val, ptr %23, i32 0, i32 1
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  %26 = getelementptr inbounds [2 x %struct.regmatch_t], ptr %6, i64 0, i64 0
  %27 = call i32 @regexec(ptr noundef %5, ptr noundef %25, i64 noundef 2, ptr noundef %26, i32 noundef 0)
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %68

29:                                               ; preds = %22
  %30 = getelementptr inbounds [2 x %struct.regmatch_t], ptr %6, i64 0, i64 0
  %31 = getelementptr inbounds %struct.regmatch_t, ptr %30, i32 0, i32 0
  %32 = load i32, ptr %31, align 16, !tbaa !12
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %34, label %68

34:                                               ; preds = %29
  %35 = getelementptr inbounds [2 x %struct.regmatch_t], ptr %6, i64 0, i64 1
  %36 = getelementptr inbounds %struct.regmatch_t, ptr %35, i32 0, i32 0
  %37 = load i32, ptr %36, align 8, !tbaa !12
  %38 = icmp sge i32 %37, 0
  br i1 %38, label %39, label %57

39:                                               ; preds = %34
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.val, ptr %40, i32 0, i32 1
  %42 = load ptr, ptr %41, align 8, !tbaa !9
  %43 = getelementptr inbounds [2 x %struct.regmatch_t], ptr %6, i64 0, i64 1
  %44 = getelementptr inbounds %struct.regmatch_t, ptr %43, i32 0, i32 1
  %45 = load i32, ptr %44, align 4, !tbaa !14
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds i8, ptr %42, i64 %46
  store i8 0, ptr %47, align 1, !tbaa !9
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.val, ptr %48, i32 0, i32 1
  %50 = load ptr, ptr %49, align 8, !tbaa !9
  %51 = getelementptr inbounds [2 x %struct.regmatch_t], ptr %6, i64 0, i64 1
  %52 = getelementptr inbounds %struct.regmatch_t, ptr %51, i32 0, i32 0
  %53 = load i32, ptr %52, align 8, !tbaa !12
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds i8, ptr %50, i64 %54
  %56 = call ptr @make_str(ptr noundef %55)
  store ptr %56, ptr %9, align 8, !tbaa !5
  br label %67

57:                                               ; preds = %34
  %58 = getelementptr inbounds [2 x %struct.regmatch_t], ptr %6, i64 0, i64 0
  %59 = getelementptr inbounds %struct.regmatch_t, ptr %58, i32 0, i32 1
  %60 = load i32, ptr %59, align 4, !tbaa !14
  %61 = getelementptr inbounds [2 x %struct.regmatch_t], ptr %6, i64 0, i64 0
  %62 = getelementptr inbounds %struct.regmatch_t, ptr %61, i32 0, i32 0
  %63 = load i32, ptr %62, align 16, !tbaa !12
  %64 = sub nsw i32 %60, %63
  %65 = sext i32 %64 to i64
  %66 = call ptr @make_integer(i64 noundef %65)
  store ptr %66, ptr %9, align 8, !tbaa !5
  br label %67

67:                                               ; preds = %57, %39
  br label %77

68:                                               ; preds = %29, %22
  %69 = getelementptr inbounds %struct.re_pattern_buffer, ptr %5, i32 0, i32 6
  %70 = load i64, ptr %69, align 8, !tbaa !15
  %71 = icmp eq i64 %70, 0
  br i1 %71, label %72, label %74

72:                                               ; preds = %68
  %73 = call ptr @make_integer(i64 noundef 0)
  store ptr %73, ptr %9, align 8, !tbaa !5
  br label %76

74:                                               ; preds = %68
  %75 = call ptr @make_str(ptr noundef @.str.11)
  store ptr %75, ptr %9, align 8, !tbaa !5
  br label %76

76:                                               ; preds = %74, %72
  br label %77

77:                                               ; preds = %76, %67
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  call void @free_value(ptr noundef %78)
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free_value(ptr noundef %79)
  call void @regfree(ptr noundef %5)
  %80 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 256, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr %5) #4
  ret ptr %80
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @make_integer(i64 noundef) #1

; Function Attrs: noreturn
declare void @errx(i32 noundef, ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @make_str(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @free_value(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @to_string(ptr noundef) #1

declare i32 @regcomp(ptr noundef, ptr noundef, i32 noundef) #3

declare i64 @regerror(i32 noundef, ptr noundef, ptr noundef, i64 noundef) #3

declare i32 @regexec(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i32 noundef) #3

declare void @regfree(ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { noreturn "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 = { nounwind }
attributes #5 = { noreturn }

!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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 0}
!13 = !{!"", !11, i64 0, !11, i64 4}
!14 = !{!13, !11, i64 4}
!15 = !{!16, !17, i64 48}
!16 = !{!"re_pattern_buffer", !6, i64 0, !17, i64 8, !17, i64 16, !17, i64 24, !6, i64 32, !6, i64 40, !17, i64 48, !11, i64 56, !11, i64 56, !11, i64 56, !11, i64 56, !11, i64 56, !11, i64 56, !11, i64 56}
!17 = !{!"long", !7, i64 0}


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

@.str.11 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [3 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: nounwind uwtable
define dso_local ptr @op_colon(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = alloca %struct.re_pattern_buffer, align 8
  %4 = alloca [2 x %struct.regmatch_t], align 16
  %5 = alloca [256 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %5) #4
  tail call void @to_string(ptr noundef %0)
  tail call void @to_string(ptr noundef %1)
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = call i32 @regcomp(ptr noundef nonnull %3, ptr noundef %7, i32 noundef 0) #4
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %11, label %9

9:                                                ; preds = %2
  %10 = call i64 @regerror(i32 noundef %8, ptr noundef nonnull %3, ptr noundef nonnull %5, i64 noundef 256) #4
  call void (i32, ptr, ...) @errx(i32 noundef 2, ptr noundef nonnull @.str.19, ptr noundef nonnull %5) #5
  unreachable

11:                                               ; preds = %2
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  %14 = call i32 @regexec(ptr noundef nonnull %3, ptr noundef %13, i64 noundef 2, ptr noundef nonnull %4, i32 noundef 0) #4
  %15 = icmp eq i32 %14, 0
  %16 = load i32, ptr %4, align 16
  %17 = icmp eq i32 %16, 0
  %or.cond = select i1 %15, i1 %17, i1 false
  br i1 %or.cond, label %18, label %38

18:                                               ; preds = %11
  %19 = getelementptr inbounds i8, ptr %4, i64 8
  %20 = load i32, ptr %19, align 8, !tbaa !8
  %21 = icmp sgt i32 %20, -1
  br i1 %21, label %22, label %33

22:                                               ; preds = %18
  %23 = load ptr, ptr %12, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %4, i64 12
  %25 = load i32, ptr %24, align 4, !tbaa !11
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds i8, ptr %23, i64 %26
  store i8 0, ptr %27, align 1, !tbaa !5
  %28 = load ptr, ptr %12, align 8, !tbaa !5
  %29 = load i32, ptr %19, align 8, !tbaa !8
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds i8, ptr %28, i64 %30
  %32 = call ptr @make_str(ptr noundef %31)
  br label %46

33:                                               ; preds = %18
  %34 = getelementptr inbounds i8, ptr %4, i64 4
  %35 = load i32, ptr %34, align 4, !tbaa !11
  %36 = sext i32 %35 to i64
  %37 = call ptr @make_integer(i64 noundef %36)
  br label %46

38:                                               ; preds = %11
  %39 = getelementptr inbounds i8, ptr %3, i64 48
  %40 = load i64, ptr %39, align 8, !tbaa !12
  %41 = icmp eq i64 %40, 0
  br i1 %41, label %42, label %44

42:                                               ; preds = %38
  %43 = call ptr @make_integer(i64 noundef 0)
  br label %46

44:                                               ; preds = %38
  %45 = call ptr @make_str(ptr noundef nonnull @.str.11)
  br label %46

46:                                               ; preds = %42, %44, %22, %33
  %.0 = phi ptr [ %32, %22 ], [ %37, %33 ], [ %43, %42 ], [ %45, %44 ]
  call void @free_value(ptr noundef nonnull %0)
  call void @free_value(ptr noundef nonnull %1)
  call void @regfree(ptr noundef nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %3) #4
  ret ptr %.0
}

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

; Function Attrs: noreturn
declare void @errx(i32 noundef, ptr noundef, ...) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @make_str(ptr noundef) local_unnamed_addr #1

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

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

declare i32 @regcomp(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

declare i64 @regerror(i32 noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #3

declare i32 @regexec(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

declare void @regfree(ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { noreturn "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 = { nounwind }
attributes #5 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !10, i64 0}
!9 = !{!"", !10, i64 0, !10, i64 4}
!10 = !{!"int", !6, i64 0}
!11 = !{!9, !10, i64 4}
!12 = !{!13, !15, i64 48}
!13 = !{!"re_pattern_buffer", !14, i64 0, !15, i64 8, !15, i64 16, !15, i64 24, !14, i64 32, !14, i64 40, !15, i64 48, !10, i64 56, !10, i64 56, !10, i64 56, !10, i64 56, !10, i64 56, !10, i64 56, !10, i64 56}
!14 = !{!"any pointer", !6, i64 0}
!15 = !{!"long", !6, i64 0}


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