; LLVM IR from jim-b/ECCSI-SAKKE :: 4u2change (msdb)

; 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.stat = type { i64, i64, i64, i32, i32, i32, i32, i64, i64, i64, i64, %struct.timespec, %struct.timespec, %struct.timespec, [3 x i64] }
%struct.timespec = type { i64, i64 }

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@stdout = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.79 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.80 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.85 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.86 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.87 = external hidden unnamed_addr constant [46 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: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #1

; Function Attrs: nounwind
declare i32 @snprintf(ptr noundef, i64 noundef, ptr noundef, ...) #2

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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

; Function Attrs: nounwind uwtable
define dso_local signext i16 @msdb_userExists(ptr noundef %0, i64 noundef %1, ptr noundef %2) #4 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i16, align 2
  %8 = alloca [1024 x i8], align 16
  %9 = alloca %struct.stat, align 8
  %10 = alloca [1200 x i8], align 16
  %11 = alloca [1200 x i8], align 16
  %12 = alloca [1200 x i8], align 16
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %7) #5
  store i16 0, ptr %7, align 2, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1024, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 144, ptr %9) #5
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = icmp eq ptr null, %13
  br i1 %14, label %15, label %21

15:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 1200, ptr %10) #5
  %16 = getelementptr inbounds [1200 x i8], ptr %10, i64 0, i64 0
  %17 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %16, i64 noundef 1200, ptr noundef @.str, ptr noundef @.str.85) #5
  %18 = load ptr, ptr @stdout, align 8, !tbaa !5
  %19 = getelementptr inbounds [1200 x i8], ptr %10, i64 0, i64 0
  %20 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef @.str.2, ptr noundef %19) #5
  call void @llvm.lifetime.end.p0(i64 1200, ptr %10) #5
  br label %72

21:                                               ; preds = %3
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = icmp eq ptr null, %22
  br i1 %23, label %24, label %30

24:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 1200, ptr %11) #5
  %25 = getelementptr inbounds [1200 x i8], ptr %11, i64 0, i64 0
  %26 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %25, i64 noundef 1200, ptr noundef @.str, ptr noundef @.str.86) #5
  %27 = load ptr, ptr @stdout, align 8, !tbaa !5
  %28 = getelementptr inbounds [1200 x i8], ptr %11, i64 0, i64 0
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef @.str.2, ptr noundef %28) #5
  call void @llvm.lifetime.end.p0(i64 1200, ptr %11) #5
  br label %71

30:                                               ; preds = %21
  %31 = load i64, ptr %5, align 8, !tbaa !9
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = call i64 @strlen(ptr noundef %32) #6
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = call i64 @strlen(ptr noundef %35) #6
  %37 = getelementptr inbounds i8, ptr %34, i64 %36
  %38 = getelementptr inbounds i8, ptr %37, i64 1
  %39 = call i64 @strlen(ptr noundef %38) #6
  %40 = add i64 %33, %39
  %41 = add i64 %40, 2
  %42 = icmp ne i64 %31, %41
  br i1 %42, label %43, label %49

43:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 1200, ptr %12) #5
  %44 = getelementptr inbounds [1200 x i8], ptr %12, i64 0, i64 0
  %45 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %44, i64 noundef 1200, ptr noundef @.str, ptr noundef @.str.87) #5
  %46 = load ptr, ptr @stdout, align 8, !tbaa !5
  %47 = getelementptr inbounds [1200 x i8], ptr %12, i64 0, i64 0
  %48 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %46, ptr noundef @.str.2, ptr noundef %47) #5
  call void @llvm.lifetime.end.p0(i64 1200, ptr %12) #5
  br label %70

49:                                               ; preds = %30
  %50 = getelementptr inbounds [1024 x i8], ptr %8, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %50, i8 0, i64 1024, i1 false)
  %51 = getelementptr inbounds [1024 x i8], ptr %8, i64 0, i64 0
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = call i64 @strlen(ptr noundef %54) #6
  %56 = add i64 %55, 1
  %57 = getelementptr inbounds i8, ptr %53, i64 %56
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %51, i64 noundef 1024, ptr noundef @.str.79, ptr noundef @.str.80, ptr noundef %52, ptr noundef %57, ptr noundef %58) #5
  %60 = getelementptr inbounds [1024 x i8], ptr %8, i64 0, i64 0
  %61 = call i32 @stat(ptr noundef %60, ptr noundef %9) #5
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %69, label %63

63:                                               ; preds = %49
  %64 = getelementptr inbounds %struct.stat, ptr %9, i32 0, i32 3
  %65 = load i32, ptr %64, align 8, !tbaa !13
  %66 = and i32 %65, 61440
  %67 = icmp eq i32 %66, 32768
  br i1 %67, label %68, label %69

68:                                               ; preds = %63
  store i16 1, ptr %7, align 2, !tbaa !11
  br label %69

69:                                               ; preds = %68, %63, %49
  br label %70

70:                                               ; preds = %69, %43
  br label %71

71:                                               ; preds = %70, %24
  br label %72

72:                                               ; preds = %71, %15
  %73 = load i16, ptr %7, align 2, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 144, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 1024, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 2, ptr %7) #5
  ret i16 %73
}

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 "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!14, !15, i64 24}
!14 = !{!"stat", !10, i64 0, !10, i64 8, !10, i64 16, !15, i64 24, !15, i64 28, !15, i64 32, !15, i64 36, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !16, i64 72, !16, i64 88, !16, i64 104, !7, i64 120}
!15 = !{!"int", !7, i64 0}
!16 = !{!"timespec", !10, i64 0, !10, i64 8}


; 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.stat = type { i64, i64, i64, i32, i32, i32, i32, i64, i64, i64, i64, %struct.timespec, %struct.timespec, %struct.timespec, [3 x i64] }
%struct.timespec = type { i64, i64 }

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.79 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.80 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.85 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.86 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.87 = external hidden unnamed_addr constant [46 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 nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @snprintf(ptr noalias nocapture noundef writeonly, i64 noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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

; 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 nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: nofree nounwind
declare noundef i32 @stat(ptr nocapture noundef readonly, ptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind uwtable
define dso_local signext range(i16 0, 2) i16 @msdb_userExists(ptr noundef %0, i64 noundef %1, ptr noundef %2) local_unnamed_addr #4 {
  %4 = alloca [1024 x i8], align 16
  %5 = alloca %struct.stat, align 8
  %6 = alloca [1200 x i8], align 16
  %7 = alloca [1200 x i8], align 16
  %8 = alloca [1200 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 144, ptr nonnull %5) #5
  %9 = icmp eq ptr %2, null
  br i1 %9, label %10, label %14

10:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 1200, ptr nonnull %6) #5
  %11 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %6, i64 noundef 1200, ptr noundef nonnull @.str, ptr noundef nonnull @.str.85) #5
  %12 = load ptr, ptr @stdout, align 8, !tbaa !5
  %13 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.2, ptr noundef nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 1200, ptr nonnull %6) #5
  br label %39

14:                                               ; preds = %3
  %15 = icmp eq ptr %0, null
  br i1 %15, label %16, label %20

16:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 1200, ptr nonnull %7) #5
  %17 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %7, i64 noundef 1200, ptr noundef nonnull @.str, ptr noundef nonnull @.str.86) #5
  %18 = load ptr, ptr @stdout, align 8, !tbaa !5
  %19 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef nonnull @.str.2, ptr noundef nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 1200, ptr nonnull %7) #5
  br label %39

20:                                               ; preds = %14
  %21 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #6
  %22 = getelementptr inbounds i8, ptr %0, i64 %21
  %23 = getelementptr inbounds i8, ptr %22, i64 1
  %24 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %23) #6
  %25 = add i64 %21, 2
  %26 = add i64 %25, %24
  %.not = icmp eq i64 %26, %1
  br i1 %.not, label %31, label %27

27:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 1200, ptr nonnull %8) #5
  %28 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %8, i64 noundef 1200, ptr noundef nonnull @.str, ptr noundef nonnull @.str.87) #5
  %29 = load ptr, ptr @stdout, align 8, !tbaa !5
  %30 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %29, ptr noundef nonnull @.str.2, ptr noundef nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 1200, ptr nonnull %8) #5
  br label %39

31:                                               ; preds = %20
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1024) %4, i8 0, i64 1024, i1 false)
  %32 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %4, i64 noundef 1024, ptr noundef nonnull @.str.79, ptr noundef nonnull @.str.80, ptr noundef nonnull %0, ptr noundef nonnull %23, ptr noundef nonnull %2) #5
  %33 = call i32 @stat(ptr noundef nonnull %4, ptr noundef nonnull %5) #5
  %.not12 = icmp eq i32 %33, 0
  br i1 %.not12, label %34, label %39

34:                                               ; preds = %31
  %35 = getelementptr inbounds i8, ptr %5, i64 24
  %36 = load i32, ptr %35, align 8, !tbaa !9
  %37 = and i32 %36, 61440
  %38 = icmp eq i32 %37, 32768
  %spec.select = zext i1 %38 to i16
  br label %39

39:                                               ; preds = %34, %16, %31, %27, %10
  %.0 = phi i16 [ 0, %10 ], [ 0, %16 ], [ 0, %27 ], [ 0, %31 ], [ %spec.select, %34 ]
  call void @llvm.lifetime.end.p0(i64 144, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %4) #5
  ret i16 %.0
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nofree 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, !12, i64 24}
!10 = !{!"stat", !11, i64 0, !11, i64 8, !11, i64 16, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !13, i64 72, !13, i64 88, !13, i64 104, !7, i64 120}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"timespec", !11, i64 0, !11, i64 8}


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