#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 */
struct arguments {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
double *LineSegmentDetection(int *, double *, int, int, double, double, double,
                             double, double, double, int, int /*<<< orphan*/ *,
                             int *, int *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fibras(double *, int, int, int, int, int, int, double *);
int /*<<< orphan*/ filtro_medula(int, int, double *);
int /*<<< orphan*/ *fopen(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ free(void *);
int /*<<< orphan*/ get_double(struct arguments *, char *);
int /*<<< orphan*/ get_str(struct arguments *, char *);
scalar_t__ is_assigned(struct arguments *, char *);
struct arguments *process_arguments(char *, int, char **);
double *read_pgm_image_double(int *, int *, int /*<<< orphan*/);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ *stdout;
scalar_t__ strcmp(int /*<<< orphan*/, char *);
int /*<<< orphan*/ write_eps(double *, int, int, int /*<<< orphan*/, int, int,
                             int /*<<< orphan*/);
int /*<<< orphan*/ write_svg(double *, int, int, int /*<<< orphan*/, int, int,
                             int /*<<< orphan*/);
int main(int argc, char **argv) {
  struct arguments *arg = process_arguments(
      "                                                                  "
      "#name: lsd                                                              "
      "       #author: rafael grompone von gioi <grompone@gmail.com>           "
      "              #version: 1.6 of November 11, 2011                        "
      "                     #year: 2007-2011                                   "
      "                            #desc: Line Segment Detector                "
      "                                   #opt: scale | s | double | 0.8 | 0.0 "
      "| |                                             Scale image by Gaussian "
      "filter before processing.                        #opt: sigma_coef | c | "
      "double | 0.6 | 0.0 | |                                        Sigma for "
      "Gaussian filter is computed as sigma_coef/scale.               #opt: "
      "quant | q | double | 2.0 | 0.0 | |                                      "
      "       Bound to quantization error on the gradient norm.                "
      "        #opt: ang_th | a | double | 22.5 | 0.0 | 180.0 |                "
      "                     Gradient angle tolerance in degrees.               "
      "                      #opt: log_eps | e | double | 0.0 | | | Detection "
      "threshold, -log10(max. NFA)   #opt: density_th | d | double | 0.7 | 0.0 "
      "| 1.0 |                                    Minimal density of region "
      "points in a rectangle to be accepted.          #opt: cota_superior | t "
      "| int | 1 | 1 | |                                                   "
      "Valor de cota superior de grosor permitido en pixels.               "
      "#opt: cota_inferior | T | int | 1 | 1 | |                               "
      "                    Valor de cota inferior de grosor permitido en "
      "pixels.               #opt: n_bins | b | int | 1024 | 1 | |             "
      "                                   Number of bins in 'ordering' of "
      "gradient modulus.                        #opt: reg | R | str | | | |    "
      "                                                      Output image: "
      "owner LS number at each pixel. Scaled size. (PGM)          #opt: "
      "epsfile | P | str | | | | Output line segments into EPS file 'epsfile'. "
      " #opt: svgfile | S | str | | | | Output line segments into SVG file "
      "'svgfile'.  #opt: width | W | double | 1.5 | | |                        "
      "                         LS width used in EPS and SVG files. If <=0, "
      "use detected values.         #req: in  | | str | | | | Input image "
      "(PGM)                                    #req: out | | str | | | |      "
      "                                                      Line Segment "
      "output (each ascii line: x1,y1,x2,y2,width,p,-log10(NFA) )  ",
      argc, argv);
  FILE *output;
  double *image;
  int n;
  int dim = 7;
  int regX, regY;
  int i, j;
  double scale, sigma_coef, quant, ang_th, log_eps, density_th;
  int n_bins;
  int X, Y;
  double *segs;
  int cota_superior = 50;
  int cota_inferior = 10;
  image = read_pgm_image_double(&X, &Y, get_str(arg, "in"));
  filtro_medula(X, Y, image);
  scale = 0.8;
  sigma_coef = 0.6;
  quant = 2.0;
  ang_th = 100.0;
  log_eps = 0.0;
  density_th = 0.7;
  n_bins = 1024;
  segs = LineSegmentDetection(&n, image, X, Y, scale, sigma_coef, quant, ang_th,
                              log_eps, density_th, n_bins, NULL, &regX, &regY);
  fibras(segs, n, dim, X, Y, cota_superior, cota_inferior, image);
  if (strcmp(get_str(arg, "out"), "-") == 0)
    output = stdout;
  else
    output = fopen(get_str(arg, "out"), "w");
  if (output == NULL) {
    fprintf(stderr, "Error: unable to open ASCII output file.\n");
    exit(EXIT_FAILURE);
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < dim; j++)
      fprintf(output, "%f ", segs[i * dim + j]);
    fprintf(output, "\n");
  }
  if (output != stdout && fclose(output) == EOF) {
    fprintf(stderr, "Error: unable to close file while output file.\n");
    exit(EXIT_FAILURE);
  }
  if (is_assigned(arg, "epsfile"))
    write_eps(segs, n, dim, get_str(arg, "epsfile"), X, Y,
              get_double(arg, "width"));
  if (is_assigned(arg, "svgfile"))
    write_svg(segs, n, dim, get_str(arg, "svgfile"), X, Y,
              get_double(arg, "width"));
  free((void *)image);
  free((void *)segs);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xe01(%rip),%rdi
call   10d0 <process_arguments@plt>
mov    %rax,-0x18(%rbp)
movl   $0x7,-0x30(%rbp)
movl   $0x32,-0x8c(%rbp)
movl   $0xa,-0x90(%rbp)
mov    -0x18(%rbp),%rdi
lea    0x17aa(%rip),%rsi
call   10e0 <get_str@plt>
mov    %eax,%edx
lea    -0x78(%rbp),%rdi
lea    -0x7c(%rbp),%rsi
call   1050 <read_pgm_image_double@plt>
mov    %rax,-0x28(%rbp)
mov    -0x78(%rbp),%edi
mov    -0x7c(%rbp),%esi
mov    -0x28(%rbp),%rdx
call   1100 <filtro_medula@plt>
movsd  0xd9b(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xd86(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xd71(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xd5c(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xd3f(%rip),%xmm0
movsd  %xmm0,-0x70(%rbp)
movl   $0x400,-0x74(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x78(%rbp),%edx
mov    -0x7c(%rbp),%ecx
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm3
movsd  -0x68(%rbp),%xmm4
movsd  -0x70(%rbp),%xmm5
mov    -0x74(%rbp),%r8d
lea    -0x2c(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%r9d
lea    -0x34(%rbp),%r10
lea    -0x38(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <LineSegmentDetection@plt>
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    -0x78(%rbp),%ecx
mov    -0x7c(%rbp),%r8d
mov    -0x8c(%rbp),%r9d
mov    -0x90(%rbp),%r10d
mov    -0x28(%rbp),%rax
mov    %r10d,(%rsp)
mov    %rax,0x8(%rsp)
call   10a0 <fibras@plt>
mov    -0x18(%rbp),%rdi
lea    0x16a5(%rip),%rsi
call   10e0 <get_str@plt>
mov    %eax,%edi
lea    0x169b(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    138e <main+0x18e>
mov    0x2c46(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    13b0 <main+0x1b0>
mov    -0x18(%rbp),%rdi
lea    0x166a(%rip),%rsi
call   10e0 <get_str@plt>
mov    %eax,%edi
lea    0x1662(%rip),%rsi
call   1110 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    13e1 <main+0x1e1>
mov    0x2c16(%rip),%rax
mov    (%rax),%rdi
lea    0x163f(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    0x2bf6(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1460 <main+0x260>
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    1440 <main+0x240>
mov    -0x20(%rbp),%rdi
mov    -0x88(%rbp),%rax
mov    -0x3c(%rbp),%ecx
imul   -0x30(%rbp),%ecx
add    -0x40(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0x160a(%rip),%rsi
mov    $0x1,%al
call   10c0 <fprintf@plt>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    13fb <main+0x1fb>
mov    -0x20(%rbp),%rdi
lea    0x15e8(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    13e8 <main+0x1e8>
mov    -0x20(%rbp),%rax
mov    0x2b5d(%rip),%rcx
cmp    (%rcx),%rax
je     14b3 <main+0x2b3>
mov    -0x20(%rbp),%rdi
call   1080 <fclose@plt>
mov    0x2b64(%rip),%rcx
cmp    (%rcx),%rax
jne    14b3 <main+0x2b3>
mov    0x2b44(%rip),%rax
mov    (%rax),%rdi
lea    0x159b(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    0x2b24(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
mov    -0x18(%rbp),%rdi
lea    0x15ab(%rip),%rsi
call   1060 <is_assigned@plt>
cmp    $0x0,%rax
je     1554 <main+0x354>
mov    -0x88(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0xa4(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0xa0(%rbp)
mov    -0x18(%rbp),%rdi
lea    0x1571(%rip),%rsi
call   10e0 <get_str@plt>
mov    %eax,-0x9c(%rbp)
mov    -0x78(%rbp),%eax
mov    %eax,-0x98(%rbp)
mov    -0x7c(%rbp),%eax
mov    %eax,-0x94(%rbp)
mov    -0x18(%rbp),%rdi
lea    0x1551(%rip),%rsi
call   1090 <get_double@plt>
mov    -0xb0(%rbp),%rdi
mov    -0xa4(%rbp),%esi
mov    -0xa0(%rbp),%edx
mov    -0x9c(%rbp),%ecx
mov    -0x98(%rbp),%r8d
mov    -0x94(%rbp),%r9d
mov    %eax,(%rsp)
call   10f0 <write_eps@plt>
mov    -0x18(%rbp),%rdi
lea    0x1518(%rip),%rsi
call   1060 <is_assigned@plt>
cmp    $0x0,%rax
je     15f5 <main+0x3f5>
mov    -0x88(%rbp),%rax
mov    %rax,-0xd0(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0xc4(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0xc0(%rbp)
mov    -0x18(%rbp),%rdi
lea    0x14de(%rip),%rsi
call   10e0 <get_str@plt>
mov    %eax,-0xbc(%rbp)
mov    -0x78(%rbp),%eax
mov    %eax,-0xb8(%rbp)
mov    -0x7c(%rbp),%eax
mov    %eax,-0xb4(%rbp)
mov    -0x18(%rbp),%rdi
lea    0x14b0(%rip),%rsi
call   1090 <get_double@plt>
mov    -0xd0(%rbp),%rdi
mov    -0xc4(%rbp),%esi
mov    -0xc0(%rbp),%edx
mov    -0xbc(%rbp),%ecx
mov    -0xb8(%rbp),%r8d
mov    -0xb4(%rbp),%r9d
mov    %eax,(%rsp)
call   1070 <write_svg@plt>
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
mov    -0x88(%rbp),%rdi
call   1040 <free@plt>
mov    0x29af(%rip),%rax
mov    (%rax),%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rdx
mov    %edi,%esi
lea    0xdee(%rip),%rdi
call   10e0 <process_arguments@plt>
mov    %rax,%r12
lea    0x17b7(%rip),%rsi
mov    %rax,%rdi
call   10f0 <get_str@plt>
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
mov    %eax,%edx
call   1050 <read_pgm_image_double@plt>
mov    %rax,%rbx
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
mov    %rax,%rdx
call   1110 <filtro_medula@plt>
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
lea    0x20(%rsp),%rax
lea    0x24(%rsp),%rbp
lea    0x14(%rsp),%rdi
movsd  0xd6c(%rip),%xmm0
movsd  0xd6c(%rip),%xmm1
movsd  0xd6c(%rip),%xmm2
movsd  0xd6c(%rip),%xmm3
movsd  0xd6c(%rip),%xmm5
xorps  %xmm4,%xmm4
mov    %rbx,%rsi
mov    $0x400,%r8d
xor    %r9d,%r9d
push   %rax
push   %rbp
call   1030 <LineSegmentDetection@plt>
add    $0x10,%rsp
mov    %rax,%r15
mov    0x14(%rsp),%esi
mov    0x10(%rsp),%ecx
mov    0xc(%rsp),%r8d
mov    %rax,%rdi
mov    $0x7,%edx
mov    $0x32,%r9d
mov    %rbx,0x18(%rsp)
push   %rbx
push   $0xa
call   10a0 <fibras@plt>
add    $0x10,%rsp
lea    0x16ff(%rip),%rsi
mov    %r12,%rdi
call   10f0 <get_str@plt>
lea    0x16f4(%rip),%rsi
mov    %eax,%edi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     1525 <main+0x305>
lea    0x16d9(%rip),%rsi
mov    %r12,%rdi
call   10f0 <get_str@plt>
lea    0x16d0(%rip),%rsi
mov    %eax,%edi
call   1120 <fopen@plt>
mov    %rax,%r14
test   %r14,%r14
je     1538 <main+0x318>
cmpl   $0x0,0x14(%rsp)
jle    1411 <main+0x1f1>
lea    0x30(%r15),%rbp
xor    %ebx,%ebx
lea    0x16d1(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  -0x30(%rbp),%xmm0
mov    %r14,%rdi
mov    %r13,%rsi
mov    $0x1,%al
call   10d0 <fprintf@plt>
movsd  -0x28(%rbp),%xmm0
mov    %r14,%rdi
mov    %r13,%rsi
mov    $0x1,%al
call   10d0 <fprintf@plt>
movsd  -0x20(%rbp),%xmm0
mov    %r14,%rdi
mov    %r13,%rsi
mov    $0x1,%al
call   10d0 <fprintf@plt>
movsd  -0x18(%rbp),%xmm0
mov    %r14,%rdi
mov    %r13,%rsi
mov    $0x1,%al
call   10d0 <fprintf@plt>
movsd  -0x10(%rbp),%xmm0
mov    %r14,%rdi
mov    %r13,%rsi
mov    $0x1,%al
call   10d0 <fprintf@plt>
movsd  -0x8(%rbp),%xmm0
mov    %r14,%rdi
mov    %r13,%rsi
mov    $0x1,%al
call   10d0 <fprintf@plt>
movsd  0x0(%rbp),%xmm0
mov    %r14,%rdi
mov    %r13,%rsi
mov    $0x1,%al
call   10d0 <fprintf@plt>
mov    $0xa,%edi
mov    %r14,%rsi
call   10b0 <fputc@plt>
add    $0x1,%rbx
movslq 0x14(%rsp),%rax
add    $0x38,%rbp
cmp    %rax,%rbx
jl     1370 <main+0x150>
mov    0x2bb0(%rip),%rax
cmp    (%rax),%r14
je     1435 <main+0x215>
mov    %r14,%rdi
call   1080 <fclose@plt>
mov    0x2bbc(%rip),%rcx
cmp    (%rcx),%rax
je     1550 <main+0x330>
lea    0x162d(%rip),%rsi
mov    %r12,%rdi
call   1060 <is_assigned@plt>
test   %rax,%rax
je     1498 <main+0x278>
mov    0x14(%rsp),%r13d
lea    0x1614(%rip),%rsi
mov    %r12,%rdi
call   10f0 <get_str@plt>
mov    %eax,%ebp
mov    0x10(%rsp),%ebx
mov    0xc(%rsp),%r14d
lea    0x1602(%rip),%rsi
mov    %r12,%rdi
call   1090 <get_double@plt>
sub    $0x8,%rsp
mov    %r15,%rdi
mov    %r13d,%esi
mov    $0x7,%edx
mov    %ebp,%ecx
mov    %ebx,%r8d
mov    %r14d,%r9d
push   %rax
call   1100 <write_eps@plt>
add    $0x10,%rsp
lea    0x15d8(%rip),%rsi
mov    %r12,%rdi
call   1060 <is_assigned@plt>
test   %rax,%rax
je     14fb <main+0x2db>
mov    0x14(%rsp),%r14d
lea    0x15bf(%rip),%rsi
mov    %r12,%rdi
call   10f0 <get_str@plt>
mov    %eax,%ebp
mov    0x10(%rsp),%ebx
mov    0xc(%rsp),%r13d
lea    0x159f(%rip),%rsi
mov    %r12,%rdi
call   1090 <get_double@plt>
sub    $0x8,%rsp
mov    %r15,%rdi
mov    %r14d,%esi
mov    $0x7,%edx
mov    %ebp,%ecx
mov    %ebx,%r8d
mov    %r13d,%r9d
push   %rax
call   1070 <write_svg@plt>
add    $0x10,%rsp
mov    0x18(%rsp),%rdi
call   1040 <free@plt>
mov    %r15,%rdi
call   1040 <free@plt>
mov    0x2aac(%rip),%rax
mov    (%rax),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2a9c(%rip),%rax
mov    (%rax),%r14
test   %r14,%r14
jne    134c <main+0x12c>
mov    0x2a99(%rip),%rax
mov    (%rax),%rcx
lea    0x14c2(%rip),%rdi
mov    $0x29,%esi
jmp    1566 <main+0x346>
mov    0x2a81(%rip),%rax
mov    (%rax),%rcx
lea    0x14d8(%rip),%rdi
mov    $0x2f,%esi
mov    $0x1,%edx
call   1140 <fwrite@plt>
mov    0x2a59(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>

LLVM IR (-O0):
%struct.arguments = type { i32 }
@.str = [2520 x i8] c" #name: lsd #author: rafael grompone von gioi <grompone@gmail.com> #version: 1.6 of November 11, 2011 #year: 2007-2011 #desc: Line Segment Detector #opt: scale | s | double | 0.8 | 0.0 | | Scale image by Gaussian filter before processing. #opt: sigma_coef | c | double | 0.6 | 0.0 | | Sigma for Gaussian filter is computed as sigma_coef/scale. #opt: quant | q | double | 2.0 | 0.0 | | Bound to quantization error on the gradient norm. #opt: ang_th | a | double | 22.5 | 0.0 | 180.0 | Gradient angle tolerance in degrees. #opt: log_eps | e | double | 0.0 | | | Detection threshold, -log10(max. NFA) #opt: density_th | d | double | 0.7 | 0.0 | 1.0 | Minimal density of region points in a rectangle to be accepted. #opt: cota_superior | t | int | 1 | 1 | | Valor de cota superior de grosor permitido en pixels. #opt: cota_inferior | T | int | 1 | 1 | | Valor de cota inferior de grosor permitido en pixels. #opt: n_bins | b | int | 1024 | 1 | | Number of bins in 'ordering' of gradient modulus. #opt: reg | R | str | | | | Output image: owner LS number at each pixel. Scaled size. (PGM) #opt: epsfile | P | str | | | | Output line segments into EPS file 'epsfile'. #opt: svgfile | S | str | | | | Output line segments into SVG file 'svgfile'. #opt: width | W | double | 1.5 | | | LS width used in EPS and SVG files. If <=0, use detected values. #req: in | | str | | | | Input image (PGM) #req: out | | str | | | | Line Segment output (each ascii line: x1,y1,x2,y2,width,p,-log10(NFA) ) \00"
@.str.1 = [3 x i8] c"in\00"
@.str.2 = [4 x i8] c"out\00"
@.str.3 = [2 x i8] c"-\00"
@stdout = global i32* null
@.str.4 = [2 x i8] c"w\00"
@stderr = global i32* null
@.str.5 = [42 x i8] c"Error: unable to open ASCII output file.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.6 = [4 x i8] c"%f \00"
@.str.7 = [2 x i8] c"\0A\00"
@EOF = global i64 0
@.str.8 = [48 x i8] c"Error: unable to close file while output file.\0A\00"
@.str.9 = [8 x i8] c"epsfile\00"
@.str.10 = [6 x i8] c"width\00"
@.str.11 = [8 x i8] c"svgfile\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.arguments*
%7 = alloca i32*
%8 = alloca double*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca double*
%25 = alloca i32
%26 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%27 = load i32, i32* %4
%28 = load i8**, i8*** %5
%29 = call %struct.arguments* @process_arguments(i8* getelementptr inbounds ([2520 x i8], [2520 x i8]* @.str, i64 0, i64 0), i32 %27, i8** %28)
store %struct.arguments* %29, %struct.arguments** %6
store i32 7, i32* %10
store i32 50, i32* %25
store i32 10, i32* %26
%30 = load %struct.arguments*, %struct.arguments** %6
%31 = call i32 @get_str(%struct.arguments* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%32 = call double* @read_pgm_image_double(i32* %22, i32* %23, i32 %31)
store double* %32, double** %8
%33 = load i32, i32* %22
%34 = load i32, i32* %23
%35 = load double*, double** %8
%36 = call i32 @filtro_medula(i32 %33, i32 %34, double* %35)
store double 8.000000e-01, double* %15
store double 6.000000e-01, double* %16
store double 2.000000e+00, double* %17
store double 1.000000e+02, double* %18
store double 0.000000e+00, double* %19
store double 0x3FE6666666666666, double* %20
store i32 1024, i32* %21
%37 = load double*, double** %8
%38 = load i32, i32* %22
%39 = load i32, i32* %23
%40 = load double, double* %15
%41 = load double, double* %16
%42 = load double, double* %17
%43 = load double, double* %18
%44 = load double, double* %19
%45 = load double, double* %20
%46 = load i32, i32* %21
%47 = call double* @LineSegmentDetection(i32* %9, double* %37, i32 %38, i32 %39, double %40, double %41, double %42, double %43, double %44, double %45, i32 %46, i32* null, i32* %11, i32* %12)
store double* %47, double** %24
%48 = load double*, double** %24
%49 = load i32, i32* %9
%50 = load i32, i32* %10
%51 = load i32, i32* %22
%52 = load i32, i32* %23
%53 = load i32, i32* %25
%54 = load i32, i32* %26
%55 = load double*, double** %8
%56 = call i32 @fibras(double* %48, i32 %49, i32 %50, i32 %51, i32 %52, i32 %53, i32 %54, double* %55)
%57 = load %struct.arguments*, %struct.arguments** %6
%58 = call i32 @get_str(%struct.arguments* %57, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%59 = call i64 @strcmp(i32 %58, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %2
%62 = load i32*, i32** @stdout
store i32* %62, i32** %7
br label %67
63: ; preds = %2
%64 = load %struct.arguments*, %struct.arguments** %6
%65 = call i32 @get_str(%struct.arguments* %64, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%66 = call i32* @fopen(i32 %65, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %66, i32** %7
br label %67
67: ; preds = %63, %61
%68 = load i32*, i32** %7
%69 = icmp eq i32* %68, null
br i1 %69, label %70, label %75
70: ; preds = %67
%71 = load i32*, i32** @stderr
%72 = call i32 (i32*, i8*, ...) @fprintf(i32* %71, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0))
%73 = load i32, i32* @EXIT_FAILURE
%74 = call i32 @exit(i32 %73)
unreachable
75: ; preds = %67
store i32 0, i32* %13
br label %76
76: ; preds = %103, %75
%77 = load i32, i32* %13
%78 = load i32, i32* %9
%79 = icmp slt i32 %77, %78
br i1 %79, label %80, label %106
80: ; preds = %76
store i32 0, i32* %14
br label %81
81: ; preds = %97, %80
%82 = load i32, i32* %14
%83 = load i32, i32* %10
%84 = icmp slt i32 %82, %83
br i1 %84, label %85, label %100
85: ; preds = %81
%86 = load i32*, i32** %7
%87 = load double*, double** %24
%88 = load i32, i32* %13
%89 = load i32, i32* %10
%90 = mul nsw i32 %88, %89
%91 = load i32, i32* %14
%92 = add nsw i32 %90, %91
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds double, double* %87, i64 %93
%95 = load double, double* %94
%96 = call i32 (i32*, i8*, ...) @fprintf(i32* %86, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double %95)
br label %97
97: ; preds = %85
%98 = load i32, i32* %14
%99 = add nsw i32 %98, 1
store i32 %99, i32* %14
br label %81
100: ; preds = %81
%101 = load i32*, i32** %7
%102 = call i32 (i32*, i8*, ...) @fprintf(i32* %101, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %103
103: ; preds = %100
%104 = load i32, i32* %13
%105 = add nsw i32 %104, 1
store i32 %105, i32* %13
br label %76
106: ; preds = %76
%107 = load i32*, i32** %7
%108 = load i32*, i32** @stdout
%109 = icmp ne i32* %107, %108
br i1 %109, label %110, label %120
110: ; preds = %106
%111 = load i32*, i32** %7
%112 = call i64 @fclose(i32* %111)
%113 = load i64, i64* @EOF
%114 = icmp eq i64 %112, %113
br i1 %114, label %115, label %120
115: ; preds = %110
%116 = load i32*, i32** @stderr
%117 = call i32 (i32*, i8*, ...) @fprintf(i32* %116, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.8, i64 0, i64 0))
%118 = load i32, i32* @EXIT_FAILURE
%119 = call i32 @exit(i32 %118)
unreachable
120: ; preds = %110, %106
%121 = load %struct.arguments*, %struct.arguments** %6
%122 = call i64 @is_assigned(%struct.arguments* %121, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%123 = icmp ne i64 %122, 0
br i1 %123, label %124, label %135
124: ; preds = %120
%125 = load double*, double** %24
%126 = load i32, i32* %9
%127 = load i32, i32* %10
%128 = load %struct.arguments*, %struct.arguments** %6
%129 = call i32 @get_str(%struct.arguments* %128, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%130 = load i32, i32* %22
%131 = load i32, i32* %23
%132 = load %struct.arguments*, %struct.arguments** %6
%133 = call i32 @get_double(%struct.arguments* %132, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%134 = call i32 @write_eps(double* %125, i32 %126, i32 %127, i32 %129, i32 %130, i32 %131, i32 %133)
br label %135
135: ; preds = %124, %120
%136 = load %struct.arguments*, %struct.arguments** %6
%137 = call i64 @is_assigned(%struct.arguments* %136, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0))
%138 = icmp ne i64 %137, 0
br i1 %138, label %139, label %150
139: ; preds = %135
%140 = load double*, double** %24
%141 = load i32, i32* %9
%142 = load i32, i32* %10
%143 = load %struct.arguments*, %struct.arguments** %6
%144 = call i32 @get_str(%struct.arguments* %143, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0))
%145 = load i32, i32* %22
%146 = load i32, i32* %23
%147 = load %struct.arguments*, %struct.arguments** %6
%148 = call i32 @get_double(%struct.arguments* %147, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%149 = call i32 @write_svg(double* %140, i32 %141, i32 %142, i32 %144, i32 %145, i32 %146, i32 %148)
br label %150
150: ; preds = %139, %135
%151 = load double*, double** %8
%152 = bitcast double* %151 to i8*
%153 = call i32 @free(i8* %152)
%154 = load double*, double** %24
%155 = bitcast double* %154 to i8*
%156 = call i32 @free(i8* %155)
%157 = load i32, i32* @EXIT_SUCCESS
ret i32 %157
}

LLVM IR (-O2):
%struct.arguments = type { i32 }
@.str = [2520 x i8] c" #name: lsd #author: rafael grompone von gioi <grompone@gmail.com> #version: 1.6 of November 11, 2011 #year: 2007-2011 #desc: Line Segment Detector #opt: scale | s | double | 0.8 | 0.0 | | Scale image by Gaussian filter before processing. #opt: sigma_coef | c | double | 0.6 | 0.0 | | Sigma for Gaussian filter is computed as sigma_coef/scale. #opt: quant | q | double | 2.0 | 0.0 | | Bound to quantization error on the gradient norm. #opt: ang_th | a | double | 22.5 | 0.0 | 180.0 | Gradient angle tolerance in degrees. #opt: log_eps | e | double | 0.0 | | | Detection threshold, -log10(max. NFA) #opt: density_th | d | double | 0.7 | 0.0 | 1.0 | Minimal density of region points in a rectangle to be accepted. #opt: cota_superior | t | int | 1 | 1 | | Valor de cota superior de grosor permitido en pixels. #opt: cota_inferior | T | int | 1 | 1 | | Valor de cota inferior de grosor permitido en pixels. #opt: n_bins | b | int | 1024 | 1 | | Number of bins in 'ordering' of gradient modulus. #opt: reg | R | str | | | | Output image: owner LS number at each pixel. Scaled size. (PGM) #opt: epsfile | P | str | | | | Output line segments into EPS file 'epsfile'. #opt: svgfile | S | str | | | | Output line segments into SVG file 'svgfile'. #opt: width | W | double | 1.5 | | | LS width used in EPS and SVG files. If <=0, use detected values. #req: in | | str | | | | Input image (PGM) #req: out | | str | | | | Line Segment output (each ascii line: x1,y1,x2,y2,width,p,-log10(NFA) ) \00"
@.str.1 = [3 x i8] c"in\00"
@.str.2 = [4 x i8] c"out\00"
@.str.3 = [2 x i8] c"-\00"
@stdout = global i32* null
@.str.4 = [2 x i8] c"w\00"
@stderr = global i32* null
@.str.5 = [42 x i8] c"Error: unable to open ASCII output file.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.6 = [4 x i8] c"%f \00"
@EOF = global i64 0
@.str.8 = [48 x i8] c"Error: unable to close file while output file.\0A\00"
@.str.9 = [8 x i8] c"epsfile\00"
@.str.10 = [6 x i8] c"width\00"
@.str.11 = [8 x i8] c"svgfile\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = tail call %struct.arguments* @process_arguments(i8* getelementptr inbounds ([2520 x i8], [2520 x i8]* @.str, i64 0, i64 0), i32 %0, i8** %1)
%9 = bitcast i32* %3 to i8*
%10 = bitcast i32* %4 to i8*
%11 = bitcast i32* %5 to i8*
%12 = bitcast i32* %6 to i8*
%13 = bitcast i32* %7 to i8*
%14 = tail call i32 @get_str(%struct.arguments* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = call double* @read_pgm_image_double(i32* %6, i32* %7, i32 %14)
%16 = load i32, i32* %6
%17 = load i32, i32* %7
%18 = call i32 @filtro_medula(i32 %16, i32 %17, double* %15)
%19 = load i32, i32* %6
%20 = load i32, i32* %7
%21 = call double* @LineSegmentDetection(i32* %3, double* %15, i32 %19, i32 %20, double 8.000000e-01, double 6.000000e-01, double 2.000000e+00, double 1.000000e+02, double 0.000000e+00, double 0x3FE6666666666666, i32 1024, i32* null, i32* %4, i32* %5)
%22 = load i32, i32* %3
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = call i32 @fibras(double* %21, i32 %22, i32 7, i32 %23, i32 %24, i32 50, i32 10, double* %15)
%26 = call i32 @get_str(%struct.arguments* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%27 = call i64 @strcmp(i32 %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %2
%30 = load i32*, i32** @stdout
br label %34
31: ; preds = %2
%32 = call i32 @get_str(%struct.arguments* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%33 = call i32* @fopen(i32 %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %34
34: ; preds = %31, %29
%35 = phi i32* [ %30, %29 ], [ %33, %31 ]
%36 = icmp eq i32* %35, null
br i1 %36, label %40, label %37
37: ; preds = %34
%38 = load i32, i32* %3
%39 = icmp sgt i32 %38, 0
br i1 %39, label %45, label %80
40: ; preds = %34
%41 = load i32*, i32** @stderr
%42 = call i64 @fwrite(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0), i64 41, i64 1, i32* %41)
%43 = load i32, i32* @EXIT_FAILURE
%44 = call i32 @exit(i32 %43)
unreachable
45: ; preds = %37, %45
%46 = phi i64 [ %76, %45 ], [ 0, %37 ]
%47 = mul nuw nsw i64 %46, 7
%48 = getelementptr inbounds double, double* %21, i64 %47
%49 = load double, double* %48
%50 = call i32 (i32*, i8*, ...) @fprintf(i32* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double %49)
%51 = add nuw nsw i64 %47, 1
%52 = getelementptr inbounds double, double* %21, i64 %51
%53 = load double, double* %52
%54 = call i32 (i32*, i8*, ...) @fprintf(i32* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double %53)
%55 = add nuw nsw i64 %47, 2
%56 = getelementptr inbounds double, double* %21, i64 %55
%57 = load double, double* %56
%58 = call i32 (i32*, i8*, ...) @fprintf(i32* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double %57)
%59 = add nuw nsw i64 %47, 3
%60 = getelementptr inbounds double, double* %21, i64 %59
%61 = load double, double* %60
%62 = call i32 (i32*, i8*, ...) @fprintf(i32* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double %61)
%63 = add nuw nsw i64 %47, 4
%64 = getelementptr inbounds double, double* %21, i64 %63
%65 = load double, double* %64
%66 = call i32 (i32*, i8*, ...) @fprintf(i32* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double %65)
%67 = add nuw nsw i64 %47, 5
%68 = getelementptr inbounds double, double* %21, i64 %67
%69 = load double, double* %68
%70 = call i32 (i32*, i8*, ...) @fprintf(i32* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double %69)
%71 = add nuw nsw i64 %47, 6
%72 = getelementptr inbounds double, double* %21, i64 %71
%73 = load double, double* %72
%74 = call i32 (i32*, i8*, ...) @fprintf(i32* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double %73)
%75 = call i32 @fputc(i32 10, i32* %35)
%76 = add nuw nsw i64 %46, 1
%77 = load i32, i32* %3
%78 = sext i32 %77 to i64
%79 = icmp slt i64 %76, %78
br i1 %79, label %45, label %80
80: ; preds = %45, %37
%81 = load i32*, i32** @stdout
%82 = icmp eq i32* %35, %81
br i1 %82, label %92, label %83
83: ; preds = %80
%84 = call i64 @fclose(i32* %35)
%85 = load i64, i64* @EOF
%86 = icmp eq i64 %84, %85
br i1 %86, label %87, label %92
87: ; preds = %83
%88 = load i32*, i32** @stderr
%89 = call i64 @fwrite(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.8, i64 0, i64 0), i64 47, i64 1, i32* %88)
%90 = load i32, i32* @EXIT_FAILURE
%91 = call i32 @exit(i32 %90)
unreachable
92: ; preds = %83, %80
%93 = call i64 @is_assigned(%struct.arguments* %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%94 = icmp eq i64 %93, 0
br i1 %94, label %102, label %95
95: ; preds = %92
%96 = load i32, i32* %3
%97 = call i32 @get_str(%struct.arguments* %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%98 = load i32, i32* %6
%99 = load i32, i32* %7
%100 = call i32 @get_double(%struct.arguments* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%101 = call i32 @write_eps(double* %21, i32 %96, i32 7, i32 %97, i32 %98, i32 %99, i32 %100)
br label %102
102: ; preds = %95, %92
%103 = call i64 @is_assigned(%struct.arguments* %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0))
%104 = icmp eq i64 %103, 0
br i1 %104, label %112, label %105
105: ; preds = %102
%106 = load i32, i32* %3
%107 = call i32 @get_str(%struct.arguments* %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0))
%108 = load i32, i32* %6
%109 = load i32, i32* %7
%110 = call i32 @get_double(%struct.arguments* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%111 = call i32 @write_svg(double* %21, i32 %106, i32 7, i32 %107, i32 %108, i32 %109, i32 %110)
br label %112
112: ; preds = %105, %102
%113 = bitcast double* %15 to i8*
%114 = call i32 @free(i8* %113)
%115 = bitcast double* %21 to i8*
%116 = call i32 @free(i8* %115)
%117 = load i32, i32* @EXIT_SUCCESS
ret i32 %117
}