#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 */

/* Variables and functions */
double atof(char *);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ gaussconv_lindeberg(double *, double *, int, int, double,
                                       double);
scalar_t__ malloc(int);
int /*<<< orphan*/ printImage(double *, int, int, char *);
int /*<<< orphan*/ print_usage();
double *read_image_to_gray(char *, int *, int *);
int main(int argc, char **argv) {
  double sigma;
  double g;
  switch (argc) {
  case 5:
    sigma = atof(argv[2]);
    g = atof(argv[3]);
    break;
  default:
    print_usage();
    return -1;
  }
  int w, h;
  double *x = read_image_to_gray(argv[1], &w, &h);
  double *y = (double *)malloc(w * h * sizeof(double));
  gaussconv_lindeberg(x, y, w, h, sigma, g);
  printImage(y, w, h, argv[4]);
  free(x);
  free(y);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x5,%eax
jne    11c0 <main+0x50>
jmp    1197 <main+0x27>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    11d3 <main+0x63>
mov    $0x0,%al
call   1090 <print_usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1251 <main+0xe1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x24(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1060 <read_image_to_gray@plt>
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%eax
imul   -0x28(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1070 <gaussconv_lindeberg@plt>
mov    -0x38(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rcx
call   1080 <printImage@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
cmp    $0x5,%edi
jne    1214 <main+0xa4>
mov    %rsi,%rbx
mov    0x10(%rsi),%rdi
call   1040 <atof@plt>
movsd  %xmm0,0x18(%rsp)
mov    0x18(%rbx),%rdi
call   1040 <atof@plt>
movsd  %xmm0,0x10(%rsp)
mov    0x8(%rbx),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1060 <read_image_to_gray@plt>
mov    %rax,%r14
mov    0xc(%rsp),%edi
imul   0x8(%rsp),%edi
shl    $0x3,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    %r14,%rdi
mov    %rax,%rsi
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   1070 <gaussconv_lindeberg@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    0x20(%rbx),%rcx
mov    %r15,%rdi
call   1080 <printImage@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    1220 <main+0xb0>
xor    %eax,%eax
call   1090 <print_usage@plt>
mov    $0xffffffff,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca double*
%11 = alloca double*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
switch i32 %12, label %22 [
i32 5, label %13
]
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
%17 = call double @atof(i8* %16)
store double %17, double* %6
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 3
%20 = load i8*, i8** %19
%21 = call double @atof(i8* %20)
store double %21, double* %7
br label %24
22: ; preds = %2
%23 = call i32 (...) @print_usage()
store i32 -1, i32* %3
br label %55
24: ; preds = %13
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call double* @read_image_to_gray(i8* %27, i32* %8, i32* %9)
store double* %28, double** %10
%29 = load i32, i32* %8
%30 = load i32, i32* %9
%31 = mul nsw i32 %29, %30
%32 = sext i32 %31 to i64
%33 = mul i64 %32, 8
%34 = trunc i64 %33 to i32
%35 = call i64 @malloc(i32 %34)
%36 = inttoptr i64 %35 to double*
store double* %36, double** %11
%37 = load double*, double** %10
%38 = load double*, double** %11
%39 = load i32, i32* %8
%40 = load i32, i32* %9
%41 = load double, double* %6
%42 = load double, double* %7
%43 = call i32 @gaussconv_lindeberg(double* %37, double* %38, i32 %39, i32 %40, double %41, double %42)
%44 = load double*, double** %11
%45 = load i32, i32* %8
%46 = load i32, i32* %9
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 4
%49 = load i8*, i8** %48
%50 = call i32 @printImage(double* %44, i32 %45, i32 %46, i8* %49)
%51 = load double*, double** %10
%52 = call i32 @free(double* %51)
%53 = load double*, double** %11
%54 = call i32 @free(double* %53)
store i32 0, i32* %3
br label %55
55: ; preds = %24, %22
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = icmp eq i32 %0, 5
br i1 %5, label %6, label %34
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call double @atof(i8* %8)
%10 = getelementptr inbounds i8*, i8** %1, i64 3
%11 = load i8*, i8** %10
%12 = tail call double @atof(i8* %11)
%13 = bitcast i32* %3 to i8*
%14 = bitcast i32* %4 to i8*
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = call double* @read_image_to_gray(i8* %16, i32* %3, i32* %4)
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = shl i32 %18, 3
%21 = mul i32 %20, %19
%22 = call i64 @malloc(i32 %21)
%23 = inttoptr i64 %22 to double*
%24 = load i32, i32* %3
%25 = load i32, i32* %4
%26 = call i32 @gaussconv_lindeberg(double* %17, double* %23, i32 %24, i32 %25, double %9, double %12)
%27 = load i32, i32* %3
%28 = load i32, i32* %4
%29 = getelementptr inbounds i8*, i8** %1, i64 4
%30 = load i8*, i8** %29
%31 = call i32 @printImage(double* %23, i32 %27, i32 %28, i8* %30)
%32 = call i32 @free(double* %17)
%33 = call i32 @free(double* %23)
br label %36
34: ; preds = %2
%35 = tail call i32 (...) @print_usage()
br label %36
36: ; preds = %6, %34
%37 = phi i32 [ 0, %6 ], [ -1, %34 ]
ret i32 %37
}