#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_dct(double *, double *, int, int, 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;
  switch (argc) {
  case 4:
    sigma = atof(argv[2]);
    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_dct(x, y, w, h, sigma);
  printImage(y, w, h, argv[3]);
  free(x);
  free(y);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x4,%eax
jne    11ae <main+0x3e>
jmp    1197 <main+0x27>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    11c1 <main+0x51>
mov    $0x0,%al
call   1090 <print_usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    123a <main+0xca>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1070 <read_image_to_gray@plt>
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
imul   -0x20(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
movsd  -0x18(%rbp),%xmm0
call   1050 <gaussconv_dct@plt>
mov    -0x30(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rcx
call   1080 <printImage@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x4,%edi
jne    11f6 <main+0x86>
mov    %rsi,%r15
mov    0x10(%rsi),%rdi
call   1040 <atof@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x8(%r15),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1070 <read_image_to_gray@plt>
mov    %rax,%r14
mov    0x4(%rsp),%edi
imul   (%rsp),%edi
shl    $0x3,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    0x4(%rsp),%edx
mov    (%rsp),%ecx
mov    %r14,%rdi
mov    %rax,%rsi
movsd  0x8(%rsp),%xmm0
call   1050 <gaussconv_dct@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
mov    0x18(%r15),%rcx
mov    %rbx,%rdi
call   1080 <printImage@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    1202 <main+0x92>
xor    %eax,%eax
call   1090 <print_usage@plt>
mov    $0xffffffff,%eax
add    $0x10,%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 i32
%8 = alloca i32
%9 = alloca double*
%10 = alloca double*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
switch i32 %11, label %17 [
i32 4, label %12
]
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 2
%15 = load i8*, i8** %14
%16 = call double @atof(i8* %15)
store double %16, double* %6
br label %19
17: ; preds = %2
%18 = call i32 (...) @print_usage()
store i32 -1, i32* %3
br label %49
19: ; preds = %12
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call double* @read_image_to_gray(i8* %22, i32* %7, i32* %8)
store double* %23, double** %9
%24 = load i32, i32* %7
%25 = load i32, i32* %8
%26 = mul nsw i32 %24, %25
%27 = sext i32 %26 to i64
%28 = mul i64 %27, 8
%29 = trunc i64 %28 to i32
%30 = call i64 @malloc(i32 %29)
%31 = inttoptr i64 %30 to double*
store double* %31, double** %10
%32 = load double*, double** %9
%33 = load double*, double** %10
%34 = load i32, i32* %7
%35 = load i32, i32* %8
%36 = load double, double* %6
%37 = call i32 @gaussconv_dct(double* %32, double* %33, i32 %34, i32 %35, double %36)
%38 = load double*, double** %10
%39 = load i32, i32* %7
%40 = load i32, i32* %8
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 3
%43 = load i8*, i8** %42
%44 = call i32 @printImage(double* %38, i32 %39, i32 %40, i8* %43)
%45 = load double*, double** %9
%46 = call i32 @free(double* %45)
%47 = load double*, double** %10
%48 = call i32 @free(double* %47)
store i32 0, i32* %3
br label %49
49: ; preds = %19, %17
%50 = load i32, i32* %3
ret i32 %50
}

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