; LLVM IR from QiaoLiuHit/LSOTB-TIR :: vlfeat-0.9.19/vl (pgm)

; 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._VlPgmImage = type { i64, i64, i64, i32 }

@.str = external hidden unnamed_addr constant [19 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @vl_pgm_extract_head(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca [2 x i8], align 1
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %15 = getelementptr inbounds [2 x i8], ptr %6, i64 0, i64 0
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = call i64 @fread(ptr noundef %15, i64 noundef 1, i64 noundef 2, ptr noundef %16)
  store i64 %17, ptr %12, align 8, !tbaa !9
  %18 = load i64, ptr %12, align 8, !tbaa !9
  %19 = icmp ult i64 %18, 2
  br i1 %19, label %20, label %22

20:                                               ; preds = %2
  %21 = call i32 (i32, ptr, ...) @vl_set_last_error(i32 noundef 101, ptr noundef @.str)
  store i32 %21, ptr %3, align 4
  store i32 1, ptr %14, align 4
  br label %128

22:                                               ; preds = %2
  %23 = getelementptr inbounds [2 x i8], ptr %6, i64 0, i64 0
  %24 = load i8, ptr %23, align 1, !tbaa !11
  %25 = sext i8 %24 to i32
  %26 = icmp eq i32 %25, 80
  %27 = zext i1 %26 to i32
  store i32 %27, ptr %13, align 4, !tbaa !12
  %28 = getelementptr inbounds [2 x i8], ptr %6, i64 0, i64 1
  %29 = load i8, ptr %28, align 1, !tbaa !11
  %30 = sext i8 %29 to i32
  switch i32 %30, label %33 [
    i32 50, label %31
    i32 53, label %32
  ]

31:                                               ; preds = %22
  store i32 0, ptr %8, align 4, !tbaa !12
  br label %34

32:                                               ; preds = %22
  store i32 1, ptr %8, align 4, !tbaa !12
  br label %34

33:                                               ; preds = %22
  store i32 0, ptr %13, align 4, !tbaa !12
  br label %34

34:                                               ; preds = %33, %32, %31
  %35 = load i32, ptr %13, align 4, !tbaa !12
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %39, label %37

37:                                               ; preds = %34
  %38 = call i32 (i32, ptr, ...) @vl_set_last_error(i32 noundef 101, ptr noundef @.str)
  store i32 %38, ptr %3, align 4
  store i32 1, ptr %14, align 4
  br label %128

39:                                               ; preds = %34
  store i32 1, ptr %13, align 4, !tbaa !12
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = call i32 @remove_blanks(ptr noundef %40)
  store i32 %41, ptr %7, align 4, !tbaa !12
  %42 = load i32, ptr %7, align 4, !tbaa !12
  %43 = icmp sgt i32 %42, 0
  %44 = zext i1 %43 to i32
  %45 = load i32, ptr %13, align 4, !tbaa !12
  %46 = and i32 %45, %44
  store i32 %46, ptr %13, align 4, !tbaa !12
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %47, ptr noundef @.str.1, ptr noundef %9)
  store i32 %48, ptr %7, align 4, !tbaa !12
  %49 = load i32, ptr %7, align 4, !tbaa !12
  %50 = icmp eq i32 %49, 1
  %51 = zext i1 %50 to i32
  %52 = load i32, ptr %13, align 4, !tbaa !12
  %53 = and i32 %52, %51
  store i32 %53, ptr %13, align 4, !tbaa !12
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = call i32 @remove_blanks(ptr noundef %54)
  store i32 %55, ptr %7, align 4, !tbaa !12
  %56 = load i32, ptr %7, align 4, !tbaa !12
  %57 = icmp sgt i32 %56, 0
  %58 = zext i1 %57 to i32
  %59 = load i32, ptr %13, align 4, !tbaa !12
  %60 = and i32 %59, %58
  store i32 %60, ptr %13, align 4, !tbaa !12
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %61, ptr noundef @.str.1, ptr noundef %10)
  store i32 %62, ptr %7, align 4, !tbaa !12
  %63 = load i32, ptr %7, align 4, !tbaa !12
  %64 = icmp eq i32 %63, 1
  %65 = zext i1 %64 to i32
  %66 = load i32, ptr %13, align 4, !tbaa !12
  %67 = and i32 %66, %65
  store i32 %67, ptr %13, align 4, !tbaa !12
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = call i32 @remove_blanks(ptr noundef %68)
  store i32 %69, ptr %7, align 4, !tbaa !12
  %70 = load i32, ptr %7, align 4, !tbaa !12
  %71 = icmp sgt i32 %70, 0
  %72 = zext i1 %71 to i32
  %73 = load i32, ptr %13, align 4, !tbaa !12
  %74 = and i32 %73, %72
  store i32 %74, ptr %13, align 4, !tbaa !12
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %75, ptr noundef @.str.1, ptr noundef %11)
  store i32 %76, ptr %7, align 4, !tbaa !12
  %77 = load i32, ptr %7, align 4, !tbaa !12
  %78 = icmp eq i32 %77, 1
  %79 = zext i1 %78 to i32
  %80 = load i32, ptr %13, align 4, !tbaa !12
  %81 = and i32 %80, %79
  store i32 %81, ptr %13, align 4, !tbaa !12
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = call i32 @fgetc(ptr noundef %82)
  store i32 %83, ptr %7, align 4, !tbaa !12
  %84 = load i32, ptr %7, align 4, !tbaa !12
  %85 = icmp eq i32 %84, 10
  br i1 %85, label %95, label %86

86:                                               ; preds = %39
  %87 = load i32, ptr %7, align 4, !tbaa !12
  %88 = icmp eq i32 %87, 9
  br i1 %88, label %95, label %89

89:                                               ; preds = %86
  %90 = load i32, ptr %7, align 4, !tbaa !12
  %91 = icmp eq i32 %90, 32
  br i1 %91, label %95, label %92

92:                                               ; preds = %89
  %93 = load i32, ptr %7, align 4, !tbaa !12
  %94 = icmp eq i32 %93, 13
  br label %95

95:                                               ; preds = %92, %89, %86, %39
  %96 = phi i1 [ true, %89 ], [ true, %86 ], [ true, %39 ], [ %94, %92 ]
  %97 = zext i1 %96 to i32
  %98 = load i32, ptr %13, align 4, !tbaa !12
  %99 = and i32 %98, %97
  store i32 %99, ptr %13, align 4, !tbaa !12
  %100 = load i32, ptr %13, align 4, !tbaa !12
  %101 = icmp ne i32 %100, 0
  br i1 %101, label %104, label %102

102:                                              ; preds = %95
  %103 = call i32 (i32, ptr, ...) @vl_set_last_error(i32 noundef 102, ptr noundef @.str.2)
  store i32 %103, ptr %3, align 4
  store i32 1, ptr %14, align 4
  br label %128

104:                                              ; preds = %95
  %105 = load i32, ptr %11, align 4, !tbaa !12
  %106 = icmp ne i32 %105, 0
  %107 = xor i1 %106, true
  %108 = zext i1 %107 to i32
  %109 = icmp sge i32 %108, 65536
  br i1 %109, label %110, label %112

110:                                              ; preds = %104
  %111 = call i32 (i32, ptr, ...) @vl_set_last_error(i32 noundef 102, ptr noundef @.str.2)
  store i32 %111, ptr %3, align 4
  store i32 1, ptr %14, align 4
  br label %128

112:                                              ; preds = %104
  %113 = load i32, ptr %9, align 4, !tbaa !12
  %114 = sext i32 %113 to i64
  %115 = load ptr, ptr %5, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct._VlPgmImage, ptr %115, i32 0, i32 0
  store i64 %114, ptr %116, align 8, !tbaa !14
  %117 = load i32, ptr %10, align 4, !tbaa !12
  %118 = sext i32 %117 to i64
  %119 = load ptr, ptr %5, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct._VlPgmImage, ptr %119, i32 0, i32 1
  store i64 %118, ptr %120, align 8, !tbaa !17
  %121 = load i32, ptr %11, align 4, !tbaa !12
  %122 = sext i32 %121 to i64
  %123 = load ptr, ptr %5, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct._VlPgmImage, ptr %123, i32 0, i32 2
  store i64 %122, ptr %124, align 8, !tbaa !18
  %125 = load i32, ptr %8, align 4, !tbaa !12
  %126 = load ptr, ptr %5, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct._VlPgmImage, ptr %126, i32 0, i32 3
  store i32 %125, ptr %127, align 8, !tbaa !19
  store i32 0, ptr %3, align 4
  store i32 1, ptr %14, align 4
  br label %128

128:                                              ; preds = %112, %110, %102, %37, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %6) #3
  %129 = load i32, ptr %3, align 4
  ret i32 %129
}

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

declare i64 @fread(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #2

declare i32 @vl_set_last_error(i32 noundef, ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @remove_blanks(ptr noundef) #0

declare i32 @__isoc99_fscanf(ptr noundef, ptr noundef, ...) #2

declare i32 @fgetc(ptr noundef) #2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !16, i64 0}
!15 = !{!"_VlPgmImage", !16, i64 0, !16, i64 8, !16, i64 16, !13, i64 24}
!16 = !{!"long long", !7, i64 0}
!17 = !{!15, !16, i64 8}
!18 = !{!15, !16, i64 16}
!19 = !{!15, !13, i64 24}


; 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 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @vl_pgm_extract_head(ptr noundef %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #0 {
  %3 = alloca [2 x i8], align 1
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #4
  %7 = call i64 @fread(ptr noundef nonnull %3, i64 noundef 1, i64 noundef 2, ptr noundef %0)
  %8 = icmp ult i64 %7, 2
  br i1 %8, label %9, label %11

9:                                                ; preds = %2
  %10 = tail call i32 (i32, ptr, ...) @vl_set_last_error(i32 noundef 101, ptr noundef nonnull @.str) #4
  br label %44

11:                                               ; preds = %2
  %12 = load i8, ptr %3, align 1, !tbaa !5
  %13 = icmp eq i8 %12, 80
  %14 = getelementptr inbounds i8, ptr %3, i64 1
  %15 = load i8, ptr %14, align 1, !tbaa !5
  switch i8 %15, label %.thread [
    i8 50, label %17
    i8 53, label %16
  ]

16:                                               ; preds = %11
  br i1 %13, label %19, label %.thread

17:                                               ; preds = %11
  br i1 %13, label %19, label %.thread

.thread:                                          ; preds = %11, %16, %17
  %18 = tail call i32 (i32, ptr, ...) @vl_set_last_error(i32 noundef 101, ptr noundef nonnull @.str) #4
  br label %44

19:                                               ; preds = %16, %17
  %.03757 = phi i32 [ 1, %16 ], [ 0, %17 ]
  %20 = tail call i32 @remove_blanks(ptr noundef %0)
  %21 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %0, ptr noundef nonnull @.str.1, ptr noundef nonnull %4) #4
  %22 = call i32 @remove_blanks(ptr noundef %0)
  %23 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %0, ptr noundef nonnull @.str.1, ptr noundef nonnull %5) #4
  %24 = call i32 @remove_blanks(ptr noundef %0)
  %25 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %0, ptr noundef nonnull @.str.1, ptr noundef nonnull %6) #4
  %26 = call i32 @fgetc(ptr noundef %0)
  switch i32 %26, label %switch.edge.thread [
    i32 32, label %switch.edge
    i32 10, label %switch.edge
    i32 9, label %switch.edge
    i32 13, label %switch.edge
  ]

switch.edge:                                      ; preds = %19, %19, %19, %19
  %27 = icmp slt i32 %20, 1
  %28 = icmp ne i32 %21, 1
  %.not54 = or i1 %27, %28
  %29 = icmp slt i32 %22, 1
  %.not51 = or i1 %.not54, %29
  %30 = icmp ne i32 %23, 1
  %.not48 = or i1 %.not51, %30
  %31 = icmp slt i32 %24, 1
  %.not45 = or i1 %.not48, %31
  %32 = icmp ne i32 %25, 1
  %.not42 = or i1 %.not45, %32
  br i1 %.not42, label %switch.edge.thread, label %34

switch.edge.thread:                               ; preds = %19, %switch.edge
  %33 = call i32 (i32, ptr, ...) @vl_set_last_error(i32 noundef 102, ptr noundef nonnull @.str.2) #4
  br label %44

34:                                               ; preds = %switch.edge
  %35 = load i32, ptr %4, align 4, !tbaa !8
  %36 = sext i32 %35 to i64
  store i64 %36, ptr %1, align 8, !tbaa !10
  %37 = load i32, ptr %5, align 4, !tbaa !8
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i8, ptr %1, i64 8
  store i64 %38, ptr %39, align 8, !tbaa !13
  %40 = load i32, ptr %6, align 4, !tbaa !8
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds i8, ptr %1, i64 16
  store i64 %41, ptr %42, align 8, !tbaa !14
  %43 = getelementptr inbounds i8, ptr %1, i64 24
  store i32 %.03757, ptr %43, align 8, !tbaa !15
  br label %44

44:                                               ; preds = %34, %switch.edge.thread, %.thread, %9
  %.036 = phi i32 [ %10, %9 ], [ 0, %34 ], [ %33, %switch.edge.thread ], [ %18, %.thread ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %3) #4
  ret i32 %.036
}

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

; Function Attrs: nofree nounwind
declare noundef i64 @fread(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #2

declare i32 @vl_set_last_error(i32 noundef, ptr noundef, ...) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden i32 @remove_blanks(ptr noundef) local_unnamed_addr #0

declare i32 @__isoc99_fscanf(ptr noundef, ptr noundef, ...) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @fgetc(ptr nocapture noundef) 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) #1

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

!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, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = !{!11, !12, i64 0}
!11 = !{!"_VlPgmImage", !12, i64 0, !12, i64 8, !12, i64 16, !9, i64 24}
!12 = !{!"long long", !6, i64 0}
!13 = !{!11, !12, i64 8}
!14 = !{!11, !12, i64 16}
!15 = !{!11, !9, i64 24}


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