#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ double_threshold(int, int, int, int, unsigned int **,
                                    unsigned int **);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char);
int /*<<< orphan*/ gaussian_blur(int, int, unsigned int **, unsigned int **);
int /*<<< orphan*/ non_maximum_suppression(int, int, unsigned int **,
                                           unsigned int **, unsigned int **);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ sobel(int, int, unsigned int **, unsigned int **,
                         unsigned int **, int);
int filter_frame(unsigned int **pu8charDir, unsigned int **pu8charGrad,
                 unsigned int **pu8char, int i32Width, int i32Height) {
  FILE *fp1;
  int p, i, j, u32low = 0, u32high = 0;
  fp1 = fopen("F:\Info_R1.bin", "w");
  if (fp1 == NULL) {
    printf("File Open 2 failed.\n");
    return -1;
  } else
    printf("\t\t\t File Open 2 success.\n");
  printf("=============================================================\n");
  printf("..................1st Stage --  Gaussian Filtering -----\n\n");
  gaussian_blur(i32Width, i32Height, pu8charGrad, pu8char);
  printf("=============================================================\n");
  printf("..................2nd Stage --  Gradient & Direction using Sobel "
         "Gradient Filtering -----\n\n");
  printf("\n");
  printf("\n");
  sobel(i32Width, i32Height, pu8char, pu8charDir, pu8charGrad, i32Width);
  printf("=============================================================\n");
  printf(
      "..................3rd Stage --  Non-Maximal Suppression Stage --\n\n");
  for (j = 0; j < i32Height; j++) {
    for (i = 0; i < i32Width; i++)
      pu8charGrad[j][i] = 0;
  }
  non_maximum_suppression(i32Width, i32Height, pu8charGrad, pu8charDir,
                          pu8char);
  printf("\n");
  printf("\n");
  printf("-------------------------------------------------------------\n");
  printf("=============================================================\n");
  printf("..................4th Stage --  Hystersis Thresholding Stage --\n\n");
  printf("Enter the Lower Threshold, L [default:0]: ");
  scanf("%d", &u32low);
  printf("Enter the Higher Threshold, H [default:255]: ");
  scanf("%d", &u32high);
  printf("\n");
  printf("\n");
  double_threshold(u32low, u32high, i32Width, i32Height, pu8char, pu8charGrad);
  printf("=============================================================\n");
  for (j = 0; j < i32Height; j++) {
    for (i = 0; i < i32Width; i++) {
      fprintf(fp1, "%d ", pu8char[j][i]);
    }
    fprintf(fp1, "%c", '\n');
  }
  fclose(fp1);
  printf("Output Image buffer successfully written to :\n");
  printf("F:\Info_R1.bin\n\n");
}


x86 assembly (clang, -O0):
<filter_frame>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
lea    0xe40(%rip),%rdi
lea    0xe47(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11f3 <filter_frame+0x63>
lea    0xe2e(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1451 <filter_frame+0x2c1>
lea    0xe2b(%rip),%rdi
call   1040 <printf@plt>
lea    0xe39(%rip),%rdi
call   1040 <printf@plt>
lea    0xe6c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1060 <gaussian_blur@plt>
lea    0xe0e(%rip),%rdi
call   1040 <printf@plt>
lea    0xe7c(%rip),%rdi
call   1040 <printf@plt>
lea    0xf8e(%rip),%rdi
call   1040 <printf@plt>
lea    0xf82(%rip),%rdi
call   1040 <printf@plt>
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x24(%rbp),%r9d
call   1050 <sobel@plt>
lea    0xdc3(%rip),%rdi
call   1040 <printf@plt>
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    12eb <filter_frame+0x15b>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12d8 <filter_frame+0x148>
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    12a7 <filter_frame+0x117>
jmp    12dd <filter_frame+0x14d>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1294 <filter_frame+0x104>
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   10a0 <non_maximum_suppression@plt>
lea    0xece(%rip),%rdi
call   1040 <printf@plt>
lea    0xec2(%rip),%rdi
call   1040 <printf@plt>
lea    0xe37(%rip),%rdi
call   1040 <printf@plt>
lea    0xd12(%rip),%rdi
call   1040 <printf@plt>
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb3(%rip),%rdi
lea    -0x40(%rbp),%rsi
call   1090 <scanf@plt>
lea    0xea6(%rip),%rdi
call   1040 <printf@plt>
lea    0xe97(%rip),%rdi
lea    -0x44(%rbp),%rsi
call   1090 <scanf@plt>
lea    0xe5a(%rip),%rdi
call   1040 <printf@plt>
lea    0xe4e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x40(%rbp),%edi
mov    -0x44(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x20(%rbp),%r8
mov    -0x18(%rbp),%r9
call   1080 <double_threshold@plt>
lea    0xc91(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1430 <filter_frame+0x2a0>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    140d <filter_frame+0x27d>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
lea    0xe3e(%rip),%rsi
movsbl %al,%edx
call   1070 <fprintf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    13cd <filter_frame+0x23d>
mov    -0x30(%rbp),%rdi
lea    0xe21(%rip),%rsi
mov    $0xa,%edx
call   1070 <fprintf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    13ba <filter_frame+0x22a>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xdfc(%rip),%rdi
call   1040 <printf@plt>
lea    0xe1f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filter_frame>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r8d,%ebp
mov    %ecx,%ebx
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
lea    0xdfd(%rip),%rdi
lea    0xe04(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     147b <filter_frame+0x2ab>
mov    %rax,%r14
lea    0xe4e(%rip),%rdi
call   1040 <puts@plt>
lea    0xfb1(%rip),%rdi
call   1040 <puts@plt>
lea    0xe4f(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r12,%rdx
mov    %r15,%rcx
call   10a0 <gaussian_blur@plt>
lea    0xf8a(%rip),%rdi
call   1040 <puts@plt>
lea    0xe62(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r15,%rdx
mov    %r13,0x38(%rsp)
mov    %r13,%rcx
mov    %r12,0x18(%rsp)
mov    %r12,%r8
mov    %ebx,%r9d
call   1070 <sobel@plt>
lea    0xf3f(%rip),%rdi
call   1040 <puts@plt>
lea    0xe72(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,0xc(%rsp)
mov    %ebx,%r12d
mov    %ebp,%eax
mov    %rax,0x30(%rsp)
mov    %ebp,0x24(%rsp)
test   %ebp,%ebp
jle    1332 <filter_frame+0x162>
lea    0x0(,%r12,4),%r13
mov    0x30(%rsp),%rcx
lea    -0x1(%rcx),%rax
mov    %ecx,%edx
and    $0x3,%edx
mov    %rdx,0x28(%rsp)
cmp    $0x3,%rax
jae    149b <filter_frame+0x2cb>
xor    %ebx,%ebx
cmpq   $0x0,0x28(%rsp)
je     1332 <filter_frame+0x162>
mov    0x18(%rsp),%rax
lea    (%rax,%rbx,8),%rbx
xor    %ebp,%ebp
jmp    131b <filter_frame+0x14b>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbp
cmp    %rbp,0x28(%rsp)
je     1332 <filter_frame+0x162>
cmpl   $0x0,0xc(%rsp)
jle    1310 <filter_frame+0x140>
mov    (%rbx,%rbp,8),%rdi
xor    %esi,%esi
mov    %r13,%rdx
call   1080 <memset@plt>
jmp    1310 <filter_frame+0x140>
mov    0xc(%rsp),%ebx
mov    %ebx,%edi
mov    0x24(%rsp),%ebp
mov    %ebp,%esi
mov    0x18(%rsp),%rdx
mov    0x38(%rsp),%rcx
mov    %r15,%r8
call   10e0 <non_maximum_suppression@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xdf5(%rip),%rdi
call   1040 <puts@plt>
lea    0xe68(%rip),%rdi
call   1040 <puts@plt>
lea    0xe1b(%rip),%rdi
call   1040 <puts@plt>
lea    0xc81(%rip),%rdi
call   1060 <printf@plt>
lea    0xca0(%rip),%r13
lea    0x14(%rsp),%rsi
mov    %r13,%rdi
call   10d0 <scanf@plt>
lea    0xc8f(%rip),%rdi
call   1060 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %r13,%rdi
call   10d0 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x14(%rsp),%edi
mov    0x10(%rsp),%esi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    %r15,%r8
mov    0x18(%rsp),%r9
call   10c0 <double_threshold@plt>
lea    0xdea(%rip),%rdi
call   1040 <puts@plt>
test   %ebp,%ebp
jle    145e <filter_frame+0x28e>
xor    %ebp,%ebp
lea    0xc65(%rip),%r13
jmp    1428 <filter_frame+0x258>
nopl   0x0(%rax)
mov    $0xa,%edi
mov    %r14,%rsi
call   1090 <fputc@plt>
add    $0x1,%rbp
cmp    0x30(%rsp),%rbp
je     145e <filter_frame+0x28e>
cmpl   $0x0,0xc(%rsp)
jle    1410 <filter_frame+0x240>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbp,8),%rax
movsbl (%rax,%rbx,4),%edx
mov    %r14,%rdi
mov    %r13,%rsi
call   10b0 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1440 <filter_frame+0x270>
jmp    1410 <filter_frame+0x240>
mov    %r14,%rdi
call   1050 <fclose@plt>
lea    0xdb0(%rip),%rdi
call   1040 <puts@plt>
lea    0xdd2(%rip),%rdi
jmp    1482 <filter_frame+0x2b2>
lea    0xdd8(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
and    $0xfffffffc,%ecx
mov    %rcx,0x40(%rsp)
xor    %ebx,%ebx
mov    0x18(%rsp),%rbp
jmp    14bf <filter_frame+0x2ef>
nopl   0x0(%rax)
add    $0x4,%rbx
cmp    %rbx,0x40(%rsp)
je     12ee <filter_frame+0x11e>
cmpl   $0x0,0xc(%rsp)
jle    14b0 <filter_frame+0x2e0>
mov    0x0(%rbp,%rbx,8),%rdi
xor    %esi,%esi
mov    %r13,%rdx
call   1080 <memset@plt>
mov    0x8(%rbp,%rbx,8),%rdi
xor    %esi,%esi
mov    %r13,%rdx
call   1080 <memset@plt>
mov    0x10(%rbp,%rbx,8),%rdi
xor    %esi,%esi
mov    %r13,%rdx
call   1080 <memset@plt>
mov    0x18(%rbp,%rbx,8),%rdi
xor    %esi,%esi
mov    %r13,%rdx
call   1080 <memset@plt>
jmp    14b0 <filter_frame+0x2e0>

LLVM IR (-O0):
@.str = [14 x i8] c"F:Info_R1.bin\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [21 x i8] c"File Open 2 failed.\0A\00"
@.str.3 = [26 x i8] c"\09\09\09 File Open 2 success.\0A\00"
@.str.4 = [63 x i8] c"=============================================================\0A\00"
@.str.5 = [59 x i8] c"..................1st Stage -- Gaussian Filtering -----\0A\0A\00"
@.str.6 = [92 x i8] c"..................2nd Stage -- Gradient & Direction using Sobel Gradient Filtering -----\0A\0A\00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [67 x i8] c"..................3rd Stage -- Non-Maximal Suppression Stage --\0A\0A\00"
@.str.9 = [63 x i8] c"-------------------------------------------------------------\0A\00"
@.str.10 = [66 x i8] c"..................4th Stage -- Hystersis Thresholding Stage --\0A\0A\00"
@.str.11 = [43 x i8] c"Enter the Lower Threshold, L [default:0]: \00"
@.str.12 = [3 x i8] c"%d\00"
@.str.13 = [46 x i8] c"Enter the Higher Threshold, H [default:255]: \00"
@.str.14 = [4 x i8] c"%d \00"
@.str.15 = [3 x i8] c"%c\00"
@.str.16 = [47 x i8] c"Output Image buffer successfully written to :\0A\00"
@.str.17 = [16 x i8] c"F:Info_R1.bin\0A\0A\00"
define i32 @filter_frame(i32** %0, i32** %1, i32** %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32**
%8 = alloca i32**
%9 = alloca i32**
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store i32** %0, i32*** %7
store i32** %1, i32*** %8
store i32** %2, i32*** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 0, i32* %16
store i32 0, i32* %17
%18 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %12
%19 = load i32*, i32** %12
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %23
21: ; preds = %5
%22 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %6
br label %133
23: ; preds = %5
%24 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %25
25: ; preds = %23
%26 = call i32 @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.4, i64 0, i64 0))
%27 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0))
%28 = load i32, i32* %10
%29 = load i32, i32* %11
%30 = load i32**, i32*** %8
%31 = load i32**, i32*** %9
%32 = call i32 @gaussian_blur(i32 %28, i32 %29, i32** %30, i32** %31)
%33 = call i32 @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.4, i64 0, i64 0))
%34 = call i32 @printf(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.6, i64 0, i64 0))
%35 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%36 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%37 = load i32, i32* %10
%38 = load i32, i32* %11
%39 = load i32**, i32*** %9
%40 = load i32**, i32*** %7
%41 = load i32**, i32*** %8
%42 = load i32, i32* %10
%43 = call i32 @sobel(i32 %37, i32 %38, i32** %39, i32** %40, i32** %41, i32 %42)
%44 = call i32 @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.4, i64 0, i64 0))
%45 = call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %15
br label %46
46: ; preds = %68, %25
%47 = load i32, i32* %15
%48 = load i32, i32* %11
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %71
50: ; preds = %46
store i32 0, i32* %14
br label %51
51: ; preds = %64, %50
%52 = load i32, i32* %14
%53 = load i32, i32* %10
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %67
55: ; preds = %51
%56 = load i32**, i32*** %8
%57 = load i32, i32* %15
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i32*, i32** %56, i64 %58
%60 = load i32*, i32** %59
%61 = load i32, i32* %14
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i32, i32* %60, i64 %62
store i32 0, i32* %63
br label %64
64: ; preds = %55
%65 = load i32, i32* %14
%66 = add nsw i32 %65, 1
store i32 %66, i32* %14
br label %51
67: ; preds = %51
br label %68
68: ; preds = %67
%69 = load i32, i32* %15
%70 = add nsw i32 %69, 1
store i32 %70, i32* %15
br label %46
71: ; preds = %46
%72 = load i32, i32* %10
%73 = load i32, i32* %11
%74 = load i32**, i32*** %8
%75 = load i32**, i32*** %7
%76 = load i32**, i32*** %9
%77 = call i32 @non_maximum_suppression(i32 %72, i32 %73, i32** %74, i32** %75, i32** %76)
%78 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%79 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%80 = call i32 @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.9, i64 0, i64 0))
%81 = call i32 @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.4, i64 0, i64 0))
%82 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.10, i64 0, i64 0))
%83 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.11, i64 0, i64 0))
%84 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i32* %16)
%85 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.13, i64 0, i64 0))
%86 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i32* %17)
%87 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%88 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%89 = load i32, i32* %16
%90 = load i32, i32* %17
%91 = load i32, i32* %10
%92 = load i32, i32* %11
%93 = load i32**, i32*** %9
%94 = load i32**, i32*** %8
%95 = call i32 @double_threshold(i32 %89, i32 %90, i32 %91, i32 %92, i32** %93, i32** %94)
%96 = call i32 @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %15
br label %97
97: ; preds = %125, %71
%98 = load i32, i32* %15
%99 = load i32, i32* %11
%100 = icmp slt i32 %98, %99
br i1 %100, label %101, label %128
101: ; preds = %97
store i32 0, i32* %14
br label %102
102: ; preds = %119, %101
%103 = load i32, i32* %14
%104 = load i32, i32* %10
%105 = icmp slt i32 %103, %104
br i1 %105, label %106, label %122
106: ; preds = %102
%107 = load i32*, i32** %12
%108 = load i32**, i32*** %9
%109 = load i32, i32* %15
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds i32*, i32** %108, i64 %110
%112 = load i32*, i32** %111
%113 = load i32, i32* %14
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds i32, i32* %112, i64 %114
%116 = load i32, i32* %115
%117 = trunc i32 %116 to i8
%118 = call i32 @fprintf(i32* %107, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i8 signext %117)
br label %119
119: ; preds = %106
%120 = load i32, i32* %14
%121 = add nsw i32 %120, 1
store i32 %121, i32* %14
br label %102
122: ; preds = %102
%123 = load i32*, i32** %12
%124 = call i32 @fprintf(i32* %123, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), i8 signext 10)
br label %125
125: ; preds = %122
%126 = load i32, i32* %15
%127 = add nsw i32 %126, 1
store i32 %127, i32* %15
br label %97
128: ; preds = %97
%129 = load i32*, i32** %12
%130 = call i32 @fclose(i32* %129)
%131 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.16, i64 0, i64 0))
%132 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.17, i64 0, i64 0))
br label %133
133: ; preds = %128, %21
%134 = load i32, i32* %6
ret i32 %134
}

LLVM IR (-O2):
@.str = [14 x i8] c"F:Info_R1.bin\00"
@.str.1 = [2 x i8] c"w\00"
@.str.11 = [43 x i8] c"Enter the Lower Threshold, L [default:0]: \00"
@.str.12 = [3 x i8] c"%d\00"
@.str.13 = [46 x i8] c"Enter the Higher Threshold, H [default:255]: \00"
@.str.14 = [4 x i8] c"%d \00"
@str = [25 x i8] c"\09\09\09 File Open 2 success.\00"
@str.19 = [58 x i8] c"..................1st Stage -- Gaussian Filtering -----\0A\00"
@str.21 = [91 x i8] c"..................2nd Stage -- Gradient & Direction using Sobel Gradient Filtering -----\0A\00"
@str.23 = [66 x i8] c"..................3rd Stage -- Non-Maximal Suppression Stage --\0A\00"
@str.24 = [62 x i8] c"-------------------------------------------------------------\00"
@str.26 = [65 x i8] c"..................4th Stage -- Hystersis Thresholding Stage --\0A\00"
@str.27 = [62 x i8] c"=============================================================\00"
@str.28 = [46 x i8] c"Output Image buffer successfully written to :\00"
@str.29 = [15 x i8] c"F:Info_R1.bin\0A\00"
@str.30 = [20 x i8] c"File Open 2 failed.\00"
define i32 @filter_frame(i32** %0, i32** %1, i32** %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%9 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%10 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %5
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.30, i64 0, i64 0))
br label %116
14: ; preds = %5
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str.27, i64 0, i64 0))
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str.19, i64 0, i64 0))
%18 = tail call i32 @gaussian_blur(i32 %3, i32 %4, i32** %1, i32** %2)
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str.27, i64 0, i64 0))
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([91 x i8], [91 x i8]* @str.21, i64 0, i64 0))
%21 = tail call i32 @putchar(i32 10)
%22 = tail call i32 @putchar(i32 10)
%23 = tail call i32 @sobel(i32 %3, i32 %4, i32** %2, i32** %0, i32** %1, i32 %3)
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str.27, i64 0, i64 0))
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str.23, i64 0, i64 0))
%26 = icmp sgt i32 %4, 0
br i1 %26, label %27, label %74
27: ; preds = %14
%28 = icmp sgt i32 %3, 0
%29 = zext i32 %3 to i64
%30 = shl nuw nsw i64 %29, 2
%31 = zext i32 %4 to i64
%32 = add nsw i64 %31, -1
%33 = and i64 %31, 3
%34 = icmp ult i64 %32, 3
br i1 %34, label %60, label %35
35: ; preds = %27
%36 = and i64 %31, 4294967292
br label %37
37: ; preds = %56, %35
%38 = phi i64 [ 0, %35 ], [ %57, %56 ]
%39 = phi i64 [ 0, %35 ], [ %58, %56 ]
br i1 %28, label %40, label %56
40: ; preds = %37
%41 = getelementptr inbounds i32*, i32** %1, i64 %38
%42 = bitcast i32** %41 to i8**
%43 = load i8*, i8** %42
%44 = or i64 %38, 1
%45 = getelementptr inbounds i32*, i32** %1, i64 %44
%46 = bitcast i32** %45 to i8**
%47 = load i8*, i8** %46
%48 = or i64 %38, 2
%49 = getelementptr inbounds i32*, i32** %1, i64 %48
%50 = bitcast i32** %49 to i8**
%51 = load i8*, i8** %50
%52 = or i64 %38, 3
%53 = getelementptr inbounds i32*, i32** %1, i64 %52
%54 = bitcast i32** %53 to i8**
%55 = load i8*, i8** %54
br label %56
56: ; preds = %37, %40
%57 = add nuw nsw i64 %38, 4
%58 = add i64 %39, 4
%59 = icmp eq i64 %58, %36
br i1 %59, label %60, label %37
60: ; preds = %56, %27
%61 = phi i64 [ 0, %27 ], [ %57, %56 ]
%62 = icmp eq i64 %33, 0
br i1 %62, label %74, label %63
63: ; preds = %60, %70
%64 = phi i64 [ %71, %70 ], [ %61, %60 ]
%65 = phi i64 [ %72, %70 ], [ 0, %60 ]
br i1 %28, label %66, label %70
66: ; preds = %63
%67 = getelementptr inbounds i32*, i32** %1, i64 %64
%68 = bitcast i32** %67 to i8**
%69 = load i8*, i8** %68
br label %70
70: ; preds = %66, %63
%71 = add nuw nsw i64 %64, 1
%72 = add i64 %65, 1
%73 = icmp eq i64 %72, %33
br i1 %73, label %74, label %63
74: ; preds = %60, %70, %14
%75 = tail call i32 @non_maximum_suppression(i32 %3, i32 %4, i32** %1, i32** %0, i32** %2)
%76 = tail call i32 @putchar(i32 10)
%77 = tail call i32 @putchar(i32 10)
%78 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str.24, i64 0, i64 0))
%79 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str.27, i64 0, i64 0))
%80 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str.26, i64 0, i64 0))
%81 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.11, i64 0, i64 0))
%82 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i32* %6)
%83 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.13, i64 0, i64 0))
%84 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i32* %7)
%85 = call i32 @putchar(i32 10)
%86 = call i32 @putchar(i32 10)
%87 = load i32, i32* %6
%88 = load i32, i32* %7
%89 = call i32 @double_threshold(i32 %87, i32 %88, i32 %3, i32 %4, i32** %2, i32** %1)
%90 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str.27, i64 0, i64 0))
br i1 %26, label %91, label %112
91: ; preds = %74
%92 = icmp sgt i32 %3, 0
%93 = zext i32 %4 to i64
%94 = zext i32 %3 to i64
br label %95
95: ; preds = %91, %108
%96 = phi i64 [ 0, %91 ], [ %110, %108 ]
br i1 %92, label %97, label %108
97: ; preds = %95
%98 = getelementptr inbounds i32*, i32** %2, i64 %96
br label %99
99: ; preds = %97, %99
%100 = phi i64 [ 0, %97 ], [ %106, %99 ]
%101 = load i32*, i32** %98
%102 = getelementptr inbounds i32, i32* %101, i64 %100
%103 = load i32, i32* %102
%104 = trunc i32 %103 to i8
%105 = call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i8 signext %104)
%106 = add nuw nsw i64 %100, 1
%107 = icmp eq i64 %106, %94
br i1 %107, label %108, label %99
108: ; preds = %99, %95
%109 = call i32 @fputc(i32 10, i32* %10)
%110 = add nuw nsw i64 %96, 1
%111 = icmp eq i64 %110, %93
br i1 %111, label %112, label %95
112: ; preds = %108, %74
%113 = call i32 @fclose(i32* %10)
%114 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.28, i64 0, i64 0))
%115 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.29, i64 0, i64 0))
br label %116
116: ; preds = %112, %12
ret i32 -1
}