// File: /workspace/github_cpp_makefile_star2_O1/probonopd[P]decodeir/DecodeIR.cpp
// Function: main
int main(int argc, char* argv[]) 
{
  unsigned int i = 1; 
  int type; 

  raw_to_pronto(&argc, &argv);
  sscanf(argv[i++], "%x", &type); 
  if (type != 0) 
{
    std::cerr << "Can only handle type 0000\n"; 
    exit(1); 
    }
  int fcode; 
  sscanf(argv[i++], "%x", &fcode); 
  int frequency = (int) (1000000.0/((double)fcode * 0.241246)); 
  int intro_length, rep_length; 
  sscanf(argv[i++], "%x", &intro_length); 
  sscanf(argv[i++], "%x", &rep_length); 

  int *data = new int[2*(intro_length+rep_length)]; 
  for (int j = 0; j < 2*(intro_length+rep_length); j++) 
    {
    int ncycles; 
    sscanf(argv[i++], "%x", &ncycles); 
    data[j] = (int)(1000000.0/frequency*ncycles); 
    }
  unsigned int decodeir_context[2] = { 0, 0}; 
  char protocol[255] = ""; 
  int device = -1; 
  int subdevice = -1; 
  int obc = -1; 
  int hex[4] = { -1, -1, -1, -1}; 
  char misc_message[255] = ""; 
  char error_message[255] = ""; 
    
  do 
    {
    DecodeIR(decodeir_context, data, frequency, intro_length, rep_length, 
           protocol, &device, &subdevice, &obc, hex, misc_message, 
           error_message); 

    if (protocol[0] != '\0') 
      std::cout 
      << "protocol=" << protocol 
      << " device=" << device 
      << " subdevice=" << subdevice 
      << " obc=" << obc 
      << " hex0=" << hex[0] 
      << " hex1=" << hex[1] 
      << " hex2=" << hex[2] 
      << " hex3=" << hex[3] 
      << " misc=" << misc_message 
      << " error=" << error_message << "\n"; 
    }
  while (protocol[0] != '\0'); 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x358, %rsp            # imm = 0x358
leaq -0x74(%rbp), %rax
movl %edi, (%rax)
leaq -0x80(%rbp), %rbx
movq %rsi, (%rbx)
movq %rax, %rdi
movq %rbx, %rsi
callq 0x10e20
movq (%rbx), %r12
movq 0x8(%r12), %rdi
leaq 0x20b0(%rip), %rsi      # 0x130f1
leaq -0x70(%rbp), %rbx
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2110
cmpl $0x0, (%rbx)
jne 0x113b7
movq 0x10(%r12), %rdi
leaq 0x208d(%rip), %r14      # 0x130f1
leaq -0x6c(%rbp), %rbx
movq %r14, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2110
cvtsi2sdl (%rbx), %xmm0
mulsd 0x1467(%rip), %xmm0     # 0x124e8
movsd 0x142f(%rip), %xmm1     # 0x124b8
movsd %xmm1, -0x30(%rbp)
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %eax
movl %eax, -0x34(%rbp)
movq 0x18(%r12), %rdi
leaq -0x48(%rbp), %rbx
movq %r14, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2110
movq 0x20(%r12), %rdi
leaq -0x44(%rbp), %r15
movq %r14, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2110
movslq (%rbx), %rax
movslq (%r15), %rcx
addq %rax, %rcx
movq %rcx, %rax
shlq $0x3, %rax
testl %ecx, %ecx
movq $-0x1, %rdi
cmovnsq %rax, %rdi
callq 0x2030
movq %rax, %r14
movl (%r15), %eax
addl (%rbx), %eax
jle 0x11158
xorps %xmm0, %xmm0
cvtsi2sdl -0x34(%rbp), %xmm0
movsd -0x30(%rbp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
leaq 0x1fe3(%rip), %rbx      # 0x130f1
leaq -0x180(%rbp), %r15
xorl %r13d, %r13d
movq 0x28(%r12,%r13,8), %rdi
movq %rbx, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2110
xorps %xmm0, %xmm0
cvtsi2sdl -0x180(%rbp), %xmm0
mulsd -0x30(%rbp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, (%r14,%r13,4)
incq %r13
movslq -0x48(%rbp), %rax
movslq -0x44(%rbp), %rcx
addq %rax, %rcx
addq %rcx, %rcx
cmpq %rcx, %r13
jl 0x11118
movq %r14, -0x30(%rbp)
leaq -0x68(%rbp), %rax
movq $0x0, (%rax)
leaq -0x180(%rbp), %r13
movl $0xff, %edx
movq %r13, %rdi
xorl %esi, %esi
callq 0x20b0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq -0x40(%rbp), %rcx
movl %eax, (%rcx)
leaq -0x3c(%rbp), %rcx
movl %eax, (%rcx)
leaq -0x38(%rbp), %rcx
movl %eax, (%rcx)
pcmpeqd %xmm0, %xmm0
leaq -0x60(%rbp), %rax
movdqa %xmm0, (%rax)
leaq -0x380(%rbp), %r15
movl $0xff, %edx
movq %r15, %rdi
xorl %esi, %esi
callq 0x20b0
leaq -0x280(%rbp), %r14
movl $0xff, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x20b0
movq 0x4dfd(%rip), %rbx      # 0x15fd0
movl -0x48(%rbp), %ecx
movl -0x44(%rbp), %r8d
leaq -0x68(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x34(%rbp), %edx
movq %r13, %r9
pushq %r14
pushq %r15
leaq -0x60(%rbp), %rax
pushq %rax
leaq -0x38(%rbp), %rax
pushq %rax
leaq -0x3c(%rbp), %rax
pushq %rax
leaq -0x40(%rbp), %rax
pushq %rax
callq 0x10d3f
addq $0x30, %rsp
cmpb $0x0, -0x180(%rbp)
je 0x11396
movl $0x9, %edx
movq %rbx, %rdi
leaq 0x1eea(%rip), %rsi      # 0x1310f
callq 0x2160
movq %r13, %rdi
callq 0x2090
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x2160
movl $0x8, %edx
movq %rbx, %rdi
leaq 0x1eca(%rip), %rsi      # 0x13119
callq 0x2160
movl -0x40(%rbp), %esi
movq %rbx, %rdi
callq 0x2200
movq %rax, %r12
movl $0xb, %edx
movq %rax, %rdi
leaq 0x1eb1(%rip), %rsi      # 0x13122
callq 0x2160
movl -0x3c(%rbp), %esi
movq %r12, %rdi
callq 0x2200
movq %rax, %r12
movl $0x5, %edx
movq %rax, %rdi
leaq 0x1e9b(%rip), %rsi      # 0x1312e
callq 0x2160
movl -0x38(%rbp), %esi
movq %r12, %rdi
callq 0x2200
movq %rax, %r12
movl $0x6, %edx
movq %rax, %rdi
leaq 0x1e7f(%rip), %rsi      # 0x13134
callq 0x2160
movl -0x60(%rbp), %esi
movq %r12, %rdi
callq 0x2200
movq %rax, %r12
movl $0x6, %edx
movq %rax, %rdi
leaq 0x1e64(%rip), %rsi      # 0x1313b
callq 0x2160
movl -0x5c(%rbp), %esi
movq %r12, %rdi
callq 0x2200
movq %rax, %r12
movl $0x6, %edx
movq %rax, %rdi
leaq 0x1e49(%rip), %rsi      # 0x13142
callq 0x2160
movl -0x58(%rbp), %esi
movq %r12, %rdi
callq 0x2200
movq %rax, %r12
movl $0x6, %edx
movq %rax, %rdi
leaq 0x1e2e(%rip), %rsi      # 0x13149
callq 0x2160
movl -0x54(%rbp), %esi
movq %r12, %rdi
callq 0x2200
movq %rax, %r12
movl $0x6, %edx
movq %rax, %rdi
leaq 0x1e13(%rip), %rsi      # 0x13150
callq 0x2160
movq %r15, %rdi
callq 0x2090
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x2160
movl $0x7, %edx
movq %r12, %rdi
leaq 0x1df0(%rip), %rsi      # 0x13157
callq 0x2160
movq %r14, %rdi
callq 0x2090
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x2160
movl $0x1, %edx
movq %r12, %rdi
leaq 0x1d7c(%rip), %rsi      # 0x1310d
callq 0x2160
cmpb $0x0, -0x180(%rbp)
jne 0x111d3
xorl %eax, %eax
addq $0x358, %rsp            # imm = 0x358
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x4c32(%rip), %rdi      # 0x15ff0
leaq 0x1d2f(%rip), %rsi      # 0x130f4
callq 0x2120
movl $0x1, %edi
callq 0x2190