#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 */
int /*<<< orphan*/ abort();
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fir_test(int, int, int, int, int);
scalar_t__ fir_valid(int, int, int, int);
char getopt(int, char **, char *);
char *optarg;
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  char ch;
  int debug = 0;
  int m = 0, n = 0, repeat = 0, check = 0, verbose = 0, algorithm_id = 0;
  while ((ch = getopt(argc, argv, "a:m:n:r:cv")) != -1)
    switch (ch) {
    case 'a':
      if (debug) {
        printf("-a %s\n", optarg);
      }
      algorithm_id = atoi(optarg);
      break;
    case 'm':
      if (debug) {
        printf("-m %s\n", optarg);
      }
      m = atoi(optarg);
      break;
    case 'n':
      if (debug) {
        printf("-n %s\n", optarg);
      }
      n = atoi(optarg);
      break;
    case 'r':
      if (debug) {
        printf("-r %s\n", optarg);
      }
      repeat = atoi(optarg);
      break;
    case 'c':
      if (debug) {
        printf("-c\n");
      }
      check = 1;
      break;
    case 'v':
      if (debug) {
        printf("-v\n");
      }
      verbose = 1;
      break;
    case '?':
      printf("Usage: %s -n -m -r -a [-c -v]\n"
             "\t -n : input series length\n"
             "\t -m : short filter length\n"
             "\t -r : repeat times\n"
             "\t -a : algorithm id\n"
             "\t -c : check algorithm against basic one\n"
             "\t -v : verbose print\n",
             argv[0]);
      break;
    default:
      abort();
    }
  if (check && fir_valid(n, m, algorithm_id, verbose)) {
    printf("fir_valid!\n");
    if (verbose)
      printf("Failed algorithm=%d, result is wrong!\n", algorithm_id);
    exit(1);
  }
  fir_test(n, m, repeat, algorithm_id, verbose);
  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)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xf1b(%rip),%rdx
call   1060 <getopt@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
cmp    $0xffffffff,%eax
je     1355 <main+0x1e5>
movsbl -0x11(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x37,%eax
ja     1349 <main+0x1d9>
mov    -0x38(%rbp),%rax
lea    0xe06(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x0,-0x18(%rbp)
je     1225 <main+0xb5>
mov    0x2de4(%rip),%rax
mov    (%rax),%rsi
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2dcc(%rip),%rax
mov    (%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x30(%rbp)
jmp    1350 <main+0x1e0>
cmpl   $0x0,-0x18(%rbp)
je     125e <main+0xee>
mov    0x2dab(%rip),%rax
mov    (%rax),%rsi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d93(%rip),%rax
mov    (%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x1c(%rbp)
jmp    1350 <main+0x1e0>
cmpl   $0x0,-0x18(%rbp)
je     1297 <main+0x127>
mov    0x2d72(%rip),%rax
mov    (%rax),%rsi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d5a(%rip),%rax
mov    (%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x20(%rbp)
jmp    1350 <main+0x1e0>
cmpl   $0x0,-0x18(%rbp)
je     12d0 <main+0x160>
mov    0x2d39(%rip),%rax
mov    (%rax),%rsi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d21(%rip),%rax
mov    (%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x24(%rbp)
jmp    1350 <main+0x1e0>
cmpl   $0x0,-0x18(%rbp)
je     12ff <main+0x18f>
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x28(%rbp)
jmp    1350 <main+0x1e0>
cmpl   $0x0,-0x18(%rbp)
je     1323 <main+0x1b3>
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x2c(%rbp)
jmp    1350 <main+0x1e0>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1350 <main+0x1e0>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    11b7 <main+0x47>
cmpl   $0x0,-0x28(%rbp)
je     13ad <main+0x23d>
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    -0x2c(%rbp),%ecx
call   1090 <fir_valid@plt>
cmp    $0x0,%rax
je     13ad <main+0x23d>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x2c(%rbp)
je     13a3 <main+0x233>
mov    -0x30(%rbp),%esi
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x30(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
call   1050 <fir_test@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbp
mov    %edi,%r14d
lea    0xf45(%rip),%rdx
call   1070 <getopt@plt>
cmp    $0xff,%al
je     12cc <main+0x14c>
lea    0xe51(%rip),%r12
lea    0xf2a(%rip),%r15
movl   $0x0,0x4(%rsp)
movl   $0x0,0x14(%rsp)
xor    %ebx,%ebx
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
jmp    1219 <main+0x99>
mov    0x2e0f(%rip),%rax
mov    (%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,0x4(%rsp)
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13d,%ebx
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %r15,%rdx
call   1070 <getopt@plt>
cmp    $0xff,%al
je     129c <main+0x11c>
movsbl %al,%eax
add    $0xffffffc1,%eax
cmp    $0x37,%eax
ja     1310 <main+0x190>
mov    %ebx,%r13d
mov    $0x1,%ebx
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
mov    0x0(%rbp),%rsi
lea    0xea7(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1200 <main+0x80>
mov    0x2da4(%rip),%rax
mov    (%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,0x8(%rsp)
jmp    1200 <main+0x80>
mov    0x2d8f(%rip),%rax
mov    (%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,0xc(%rsp)
jmp    1200 <main+0x80>
mov    0x2d7a(%rip),%rax
mov    (%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,0x10(%rsp)
jmp    1200 <main+0x80>
movl   $0x1,0x14(%rsp)
jmp    1200 <main+0x80>
test   %ebx,%ebx
je     12da <main+0x15a>
mov    0xc(%rsp),%ebp
mov    %ebp,%edi
mov    0x8(%rsp),%ebx
mov    %ebx,%esi
mov    0x4(%rsp),%r15d
mov    %r15d,%edx
mov    0x14(%rsp),%r14d
mov    %r14d,%ecx
call   10a0 <fir_valid@plt>
test   %rax,%rax
jne    1317 <main+0x197>
mov    0x10(%rsp),%edx
jmp    12f0 <main+0x170>
xor    %r15d,%r15d
xor    %r14d,%r14d
xor    %edx,%edx
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    12f0 <main+0x170>
mov    0x4(%rsp),%r15d
mov    0x14(%rsp),%r14d
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ebp
mov    0x8(%rsp),%ebx
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r15d,%ecx
mov    %r14d,%r8d
call   1060 <fir_test@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1030 <abort@plt>
lea    0xeaf(%rip),%rdi
call   1040 <puts@plt>
test   %r14d,%r14d
je     133a <main+0x1ba>
lea    0xe77(%rip),%rdi
mov    0x4(%rsp),%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"a:m:n:r:cv\00"
@.str.1 = [7 x i8] c"-a %s\0A\00"
@optarg = global i8* null
@.str.2 = [7 x i8] c"-m %s\0A\00"
@.str.3 = [7 x i8] c"-n %s\0A\00"
@.str.4 = [7 x i8] c"-r %s\0A\00"
@.str.5 = [4 x i8] c"-c\0A\00"
@.str.6 = [4 x i8] c"-v\0A\00"
@.str.7 = [187 x i8] c"Usage: %s -n -m -r -a [-c -v]\0A\09 -n : input series length\0A\09 -m : short filter length\0A\09 -r : repeat times\0A\09 -a : algorithm id\0A\09 -c : check algorithm against basic one\0A\09 -v : verbose print\0A\00"
@.str.8 = [12 x i8] c"fir_valid!\0A\00"
@.str.9 = [39 x i8] c"Failed algorithm=%d, result is wrong!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
br label %14
14: ; preds = %78, %2
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = call signext i8 @getopt(i32 %15, i8** %16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i8 %17, i8* %6
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, -1
br i1 %19, label %20, label %79
20: ; preds = %14
%21 = load i8, i8* %6
%22 = sext i8 %21 to i32
switch i32 %22, label %76 [
i32 97, label %23
i32 109, label %32
i32 110, label %41
i32 114, label %50
i32 99, label %59
i32 118, label %65
i32 63, label %71
]
23: ; preds = %20
%24 = load i32, i32* %7
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i8*, i8** @optarg
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %27)
br label %29
29: ; preds = %26, %23
%30 = load i8*, i8** @optarg
%31 = call i32 @atoi(i8* %30)
store i32 %31, i32* %13
br label %78
32: ; preds = %20
%33 = load i32, i32* %7
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load i8*, i8** @optarg
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %35, %32
%39 = load i8*, i8** @optarg
%40 = call i32 @atoi(i8* %39)
store i32 %40, i32* %8
br label %78
41: ; preds = %20
%42 = load i32, i32* %7
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %41
%45 = load i8*, i8** @optarg
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %45)
br label %47
47: ; preds = %44, %41
%48 = load i8*, i8** @optarg
%49 = call i32 @atoi(i8* %48)
store i32 %49, i32* %9
br label %78
50: ; preds = %20
%51 = load i32, i32* %7
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %50
%54 = load i8*, i8** @optarg
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %54)
br label %56
56: ; preds = %53, %50
%57 = load i8*, i8** @optarg
%58 = call i32 @atoi(i8* %57)
store i32 %58, i32* %10
br label %78
59: ; preds = %20
%60 = load i32, i32* %7
%61 = icmp ne i32 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %59
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %64
64: ; preds = %62, %59
store i32 1, i32* %11
br label %78
65: ; preds = %20
%66 = load i32, i32* %7
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %70
68: ; preds = %65
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %70
70: ; preds = %68, %65
store i32 1, i32* %12
br label %78
71: ; preds = %20
%72 = load i8**, i8*** %5
%73 = getelementptr inbounds i8*, i8** %72, i64 0
%74 = load i8*, i8** %73
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([187 x i8], [187 x i8]* @.str.7, i64 0, i64 0), i8* %74)
br label %78
76: ; preds = %20
%77 = call i32 (...) @abort()
unreachable
78: ; preds = %71, %70, %64, %56, %47, %38, %29
br label %14
79: ; preds = %14
%80 = load i32, i32* %11
%81 = icmp ne i32 %80, 0
br i1 %81, label %82, label %98
82: ; preds = %79
%83 = load i32, i32* %9
%84 = load i32, i32* %8
%85 = load i32, i32* %13
%86 = load i32, i32* %12
%87 = call i64 @fir_valid(i32 %83, i32 %84, i32 %85, i32 %86)
%88 = icmp ne i64 %87, 0
br i1 %88, label %89, label %98
89: ; preds = %82
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0))
%91 = load i32, i32* %12
%92 = icmp ne i32 %91, 0
br i1 %92, label %93, label %96
93: ; preds = %89
%94 = load i32, i32* %13
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.9, i64 0, i64 0), i32 %94)
br label %96
96: ; preds = %93, %89
%97 = call i32 @exit(i32 1)
unreachable
98: ; preds = %82, %79
%99 = load i32, i32* %9
%100 = load i32, i32* %8
%101 = load i32, i32* %10
%102 = load i32, i32* %13
%103 = load i32, i32* %12
%104 = call i32 @fir_test(i32 %99, i32 %100, i32 %101, i32 %102, i32 %103)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"a:m:n:r:cv\00"
@optarg = global i8* null
@.str.7 = [187 x i8] c"Usage: %s -n -m -r -a [-c -v]\0A\09 -n : input series length\0A\09 -m : short filter length\0A\09 -r : repeat times\0A\09 -a : algorithm id\0A\09 -c : check algorithm against basic one\0A\09 -v : verbose print\0A\00"
@.str.9 = [39 x i8] c"Failed algorithm=%d, result is wrong!\0A\00"
@str = [11 x i8] c"fir_valid!\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8 %3, -1
br i1 %4, label %53, label %5
5: ; preds = %2, %32
%6 = phi i8 [ %39, %32 ], [ %3, %2 ]
%7 = phi i32 [ %38, %32 ], [ 0, %2 ]
%8 = phi i32 [ %37, %32 ], [ 0, %2 ]
%9 = phi i32 [ %36, %32 ], [ 0, %2 ]
%10 = phi i32 [ %35, %32 ], [ 0, %2 ]
%11 = phi i32 [ %34, %32 ], [ 0, %2 ]
%12 = phi i32 [ %33, %32 ], [ 0, %2 ]
%13 = sext i8 %6 to i32
switch i32 %13, label %30 [
i32 97, label %14
i32 109, label %17
i32 110, label %20
i32 114, label %23
i32 99, label %32
i32 118, label %26
i32 63, label %27
]
14: ; preds = %5
%15 = load i8*, i8** @optarg
%16 = tail call i32 @atoi(i8* %15)
br label %32
17: ; preds = %5
%18 = load i8*, i8** @optarg
%19 = tail call i32 @atoi(i8* %18)
br label %32
20: ; preds = %5
%21 = load i8*, i8** @optarg
%22 = tail call i32 @atoi(i8* %21)
br label %32
23: ; preds = %5
%24 = load i8*, i8** @optarg
%25 = tail call i32 @atoi(i8* %24)
br label %32
26: ; preds = %5
br label %32
27: ; preds = %5
%28 = load i8*, i8** %1
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([187 x i8], [187 x i8]* @.str.7, i64 0, i64 0), i8* %28)
br label %32
30: ; preds = %5
%31 = tail call i32 (...) @abort()
unreachable
32: ; preds = %5, %27, %26, %23, %20, %17, %14
%33 = phi i32 [ %12, %27 ], [ %12, %26 ], [ %12, %23 ], [ %12, %20 ], [ %19, %17 ], [ %12, %14 ], [ %12, %5 ]
%34 = phi i32 [ %11, %27 ], [ %11, %26 ], [ %11, %23 ], [ %22, %20 ], [ %11, %17 ], [ %11, %14 ], [ %11, %5 ]
%35 = phi i32 [ %10, %27 ], [ %10, %26 ], [ %25, %23 ], [ %10, %20 ], [ %10, %17 ], [ %10, %14 ], [ %10, %5 ]
%36 = phi i32 [ %9, %27 ], [ %9, %26 ], [ %9, %23 ], [ %9, %20 ], [ %9, %17 ], [ %9, %14 ], [ 1, %5 ]
%37 = phi i32 [ %8, %27 ], [ 1, %26 ], [ %8, %23 ], [ %8, %20 ], [ %8, %17 ], [ %8, %14 ], [ %8, %5 ]
%38 = phi i32 [ %7, %27 ], [ %7, %26 ], [ %7, %23 ], [ %7, %20 ], [ %7, %17 ], [ %16, %14 ], [ %7, %5 ]
%39 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%40 = icmp eq i8 %39, -1
br i1 %40, label %41, label %5
41: ; preds = %32
%42 = icmp eq i32 %36, 0
br i1 %42, label %53, label %43
43: ; preds = %41
%44 = tail call i64 @fir_valid(i32 %34, i32 %33, i32 %38, i32 %37)
%45 = icmp eq i64 %44, 0
br i1 %45, label %53, label %46
46: ; preds = %43
%47 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%48 = icmp eq i32 %37, 0
br i1 %48, label %51, label %49
49: ; preds = %46
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.9, i64 0, i64 0), i32 %38)
br label %51
51: ; preds = %49, %46
%52 = tail call i32 @exit(i32 1)
unreachable
53: ; preds = %2, %43, %41
%54 = phi i32 [ %38, %43 ], [ %38, %41 ], [ 0, %2 ]
%55 = phi i32 [ %37, %43 ], [ %37, %41 ], [ 0, %2 ]
%56 = phi i32 [ %35, %43 ], [ %35, %41 ], [ 0, %2 ]
%57 = phi i32 [ %34, %43 ], [ %34, %41 ], [ 0, %2 ]
%58 = phi i32 [ %33, %43 ], [ %33, %41 ], [ 0, %2 ]
%59 = tail call i32 @fir_test(i32 %57, i32 %58, i32 %56, i32 %54, i32 %55)
ret i32 0
}