// File: /workspace/github_cpp_makefile_star2_O2/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 $0x368, %rsp            # imm = 0x368
leaq -0x84(%rbp), %rax
movl %edi, (%rax)
leaq -0x90(%rbp), %rbx
movq %rsi, (%rbx)
movq %rax, %rdi
movq %rbx, %rsi
callq 0xfa80
movq (%rbx), %r13
movq 0x8(%r13), %rdi
leaq 0x245a(%rip), %rsi      # 0x120e8
leaq -0x80(%rbp), %rbx
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2130
cmpl $0x0, (%rbx)
jne 0xff8c
movq 0x10(%r13), %rdi
leaq 0x2438(%rip), %r15      # 0x120e8
leaq -0x7c(%rbp), %rbx
movq %r15, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2130
cvtsi2sdl (%rbx), %xmm0
mulsd 0x181b(%rip), %xmm0     # 0x114e8
movsd 0x17e3(%rip), %xmm1     # 0x114b8
movsd %xmm1, -0x48(%rbp)
divsd %xmm0, %xmm1
movapd %xmm1, -0x60(%rbp)
cvttsd2si %xmm1, %eax
movl %eax, -0x4c(%rbp)
movq 0x18(%r13), %rdi
leaq -0x3c(%rbp), %r14
movq %r15, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2130
movq 0x20(%r13), %rdi
leaq -0x38(%rbp), %r12
movq %r15, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2130
movl (%r14), %r15d
movl (%r12), %ebx
leal (%rbx,%r15), %eax
leal (%rax,%rax), %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
testl %eax, %eax
pushq $-0x1
popq %rdi
cmovnsq %rcx, %rdi
callq 0x2030
cvttpd2dq -0x60(%rbp), %xmm0
cvtdq2pd %xmm0, %xmm0
movq %rax, -0x60(%rbp)
movsd -0x48(%rbp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, -0x48(%rbp)
leaq -0x190(%rbp), %r12
xorl %r14d, %r14d
addl %r15d, %ebx
addl %ebx, %ebx
movslq %ebx, %rax
cmpq %rax, %r14
jge 0xfda4
movq 0x28(%r13,%r14,8), %rdi
leaq 0x2373(%rip), %rsi      # 0x120e8
movq %r12, %rdx
xorl %eax, %eax
callq 0x2130
cvtsi2sdl -0x190(%rbp), %xmm0
mulsd -0x48(%rbp), %xmm0
cvttsd2si %xmm0, %eax
movq -0x60(%rbp), %rcx
movl %eax, (%rcx,%r14,4)
incq %r14
movl -0x3c(%rbp), %r15d
movl -0x38(%rbp), %ebx
jmp 0xfd5c
leaq -0x78(%rbp), %rax
andq $0x0, (%rax)
leaq -0x190(%rbp), %r12
movl $0xff, %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0x20c0
leaq -0x34(%rbp), %rax
orl $-0x1, (%rax)
leaq -0x30(%rbp), %rax
orl $-0x1, (%rax)
leaq -0x2c(%rbp), %rax
orl $-0x1, (%rax)
pcmpeqd %xmm0, %xmm0
leaq -0x70(%rbp), %rax
movq %rax, %r14
movdqa %xmm0, (%rax)
leaq -0x390(%rbp), %r13
movl $0xff, %edx
movq %r13, %rdi
xorl %esi, %esi
callq 0x20c0
leaq -0x290(%rbp), %r15
movl $0xff, %edx
movq %r15, %rdi
xorl %esi, %esi
callq 0x20c0
movl -0x4c(%rbp), %ebx
movl -0x3c(%rbp), %ecx
movl -0x38(%rbp), %r8d
leaq -0x78(%rbp), %rdi
movq -0x60(%rbp), %rsi
movl %ebx, %edx
movq %r12, %r9
pushq %r15
pushq %r13
pushq %r14
leaq -0x2c(%rbp), %rax
pushq %rax
leaq -0x30(%rbp), %rax
pushq %rax
leaq -0x34(%rbp), %rax
pushq %rax
callq 0xf99f
addq $0x30, %rsp
cmpb $0x0, -0x190(%rbp)
je 0xff78
movq 0x5175(%rip), %rdi      # 0x14fd0
leaq 0x22a4(%rip), %rsi      # 0x12106
callq 0x2140
movq %rax, %rdi
movq %r12, %rsi
callq 0x2140
movq %rax, %rdi
leaq 0x2294(%rip), %rsi      # 0x12110
callq 0x2140
movl -0x34(%rbp), %esi
movq %rax, %rdi
callq 0x2220
movq %rax, %rdi
leaq 0x2283(%rip), %rsi      # 0x12119
callq 0x2140
movl -0x30(%rbp), %esi
movq %rax, %rdi
callq 0x2220
movq %rax, %rdi
leaq 0x2275(%rip), %rsi      # 0x12125
callq 0x2140
movl -0x2c(%rbp), %esi
movq %rax, %rdi
callq 0x2220
movq %rax, %rdi
leaq 0x2261(%rip), %rsi      # 0x1212b
callq 0x2140
movl -0x70(%rbp), %esi
movq %rax, %rdi
callq 0x2220
movq %rax, %rdi
leaq 0x224e(%rip), %rsi      # 0x12132
callq 0x2140
movl -0x6c(%rbp), %esi
movq %rax, %rdi
callq 0x2220
movq %rax, %rdi
leaq 0x223b(%rip), %rsi      # 0x12139
callq 0x2140
movl -0x68(%rbp), %esi
movq %rax, %rdi
callq 0x2220
movq %rax, %rdi
leaq 0x2228(%rip), %rsi      # 0x12140
callq 0x2140
movl -0x64(%rbp), %esi
movq %rax, %rdi
callq 0x2220
movq %rax, %rdi
leaq 0x2215(%rip), %rsi      # 0x12147
callq 0x2140
movq %rax, %rdi
movq %r13, %rsi
callq 0x2140
movq %rax, %rdi
leaq 0x2202(%rip), %rsi      # 0x1214e
callq 0x2140
movq %rax, %rdi
movq %r15, %rsi
callq 0x2140
movq %rax, %rdi
leaq 0x219e(%rip), %rsi      # 0x12104
callq 0x2140
cmpb $0x0, -0x190(%rbp)
jne 0xfe15
xorl %eax, %eax
addq $0x368, %rsp            # imm = 0x368
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x505d(%rip), %rdi      # 0x14ff0
leaq 0x2151(%rip), %rsi      # 0x120eb
callq 0x2140
pushq $0x1
popq %rdi
callq 0x21b0
nop