user: Please show me the C implementation that matches the assembly code listed below:

```asm
<couponcode>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,-0x2c(%rbp)
  mov    %edx,-0x30(%rbp)
  mov    %ecx,-0x34(%rbp)
  mov    %r8d,-0x38(%rbp)
  mov    %r9,-0x40(%rbp)
  mov    0x10(%rbp),%rax
  mov    %rax,-0x48(%rbp)
  mov    0x18(%rbp),%rax
  mov    %rax,-0x50(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x15,-0x18(%rbp)
  mov    -0x30(%rbp),%eax
  sub    %eax,-0x2c(%rbp)
  mov    -0x2c(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  jge    L607
  mov    $0x0,%eax
  jmp    L693
L607:
  cmpl   $0x0,-0x2c(%rbp)
  je     L841
  mov    -0x2c(%rbp),%eax
  cmp    -0x18(%rbp),%eax
  jge    L841
  mov    -0x40(%rbp),%rax
  movl   $0x4,(%rax)
  mov    $0x0,%eax
  jmp    L693
L841:
  cmpl   $0x0,0x20(%rbp)
  jne    L369
  cmpl   $0x0,-0x2c(%rbp)
  je     L369
  mov    -0x30(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x30(%rbp),%eax
  add    %eax,-0x2c(%rbp)
  mov    -0x10(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rsp
  push   -0x50(%rbp)
  push   -0x48(%rbp)
  push   -0x40(%rbp)
  push   $0x0
  push   $0x6
  mov    $0x0,%r9d
  mov    $0x6,%r8d
  lea    D115(%rip),%rcx
  mov    %rax,%rdi
  call   <coupon_vli@plt>
  add    $0x30,%rsp
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L150
  mov    $0x0,%eax
  jmp    L693
L150:
  mov    -0x10(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rsp
  push   -0x50(%rbp)
  push   -0x48(%rbp)
  push   -0x40(%rbp)
  mov    $0x0,%r9d
  mov    $0x6,%r8d
  lea    D51(%rip),%rcx
  mov    %rax,%rdi
  call   <coupon_val@plt>
  add    $0x20,%rsp
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L392
  mov    $0x0,%eax
  jmp    L693
L392:
  mov    -0x10(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rsp
  push   -0x50(%rbp)
  push   -0x48(%rbp)
  push   -0x40(%rbp)
  push   $0x0
  push   $0x5
  mov    $0x1,%r9d
  mov    $0x0,%r8d
  lea    D150(%rip),%rcx
  mov    %rax,%rdi
  call   <coupon_vli@plt>
  add    $0x30,%rsp
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L753
  mov    $0x0,%eax
  jmp    L693
L753:
  mov    -0x10(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rsp
  push   -0x50(%rbp)
  push   -0x48(%rbp)
  push   -0x40(%rbp)
  push   $0x0
  push   $0x5
  mov    $0x1,%r9d
  mov    $0x0,%r8d
  lea    D166(%rip),%rcx
  mov    %rax,%rdi
  call   <coupon_vli@plt>
  add    $0x30,%rsp
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L315
  mov    $0x0,%eax
  jmp    L693
L315:
  lea    -0x1c(%rbp),%rcx
  mov    -0x10(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rsp
  push   -0x50(%rbp)
  push   -0x48(%rbp)
  push   -0x40(%rbp)
  mov    %rcx,%r9
  mov    $0x1,%r8d
  lea    D146(%rip),%rcx
  mov    %rax,%rdi
  call   <coupon_val@plt>
  add    $0x20,%rsp
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L297
  mov    $0x0,%eax
  jmp    L693
L297:
  mov    -0x1c(%rbp),%eax
  cmp    $0x5,%eax
  jle    L38
  mov    -0x1c(%rbp),%eax
  cmp    $0x8,%eax
  jg     L38
  mov    -0x40(%rbp),%rax
  movl   $0x3,(%rax)
  mov    -0x10(%rbp),%rax
  sub    $0x1,%rax
  sub    -0x28(%rbp),%rax
  add    $0x1,%eax
  mov    %eax,%edx
  mov    -0x48(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x10(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x50(%rbp),%rax
  lea    D100(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  mov    $0x0,%eax
  jmp    L693
L38:
  mov    -0x10(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rsp
  push   -0x50(%rbp)
  push   -0x48(%rbp)
  push   -0x40(%rbp)
  mov    $0x0,%r9d
  mov    $0x3,%r8d
  lea    D108(%rip),%rcx
  mov    %rax,%rdi
  call   <coupon_val@plt>
  add    $0x20,%rsp
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L192
  mov    $0x0,%eax
  jmp    L693
L645:
  mov    -0x10(%rbp),%rax
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <to_int@plt>
  mov    %eax,-0x14(%rbp)
  addq   $0x1,-0x10(%rbp)
  cmpl   $0x1,-0x14(%rbp)
  jne    L344
  lea    -0x1c(%rbp),%rcx
  mov    -0x10(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rsp
  push   -0x50(%rbp)
  push   -0x48(%rbp)
  push   -0x40(%rbp)
  mov    %rcx,%r9
  mov    $0x1,%r8d
  lea    D286(%rip),%rcx
  mov    %rax,%rdi
  call   <coupon_val@plt>
  add    $0x20,%rsp
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L91
  mov    $0x0,%eax
  jmp    L693
L91:
  mov    -0x1c(%rbp),%eax
  cmp    $0x3,%eax
  jle    L463
  mov    -0x40(%rbp),%rax
  movl   $0x3,(%rax)
  mov    -0x10(%rbp),%rax
  sub    $0x1,%rax
  sub    -0x28(%rbp),%rax
  add    $0x1,%eax
  mov    %eax,%edx
  mov    -0x48(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x10(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x50(%rbp),%rax
  lea    D47(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  mov    $0x0,%eax
  jmp    L693
L463:
  mov    -0x10(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rsp
  push   -0x50(%rbp)
  push   -0x48(%rbp)
  push   -0x40(%rbp)
  push   $0x0
  push   $0x5
  mov    $0x1,%r9d
  mov    $0x0,%r8d
  lea    D217(%rip),%rcx
  mov    %rax,%rdi
  call   <coupon_vli@plt>
  add    $0x30,%rsp
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L616
  mov    $0x0,%eax
  jmp    L693
L616:
  lea    -0x1c(%rbp),%rcx
  mov    -0x10(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rsp
  push   -0x50(%rbp)
  push   -0x48(%rbp)
  push   -0x40(%rbp)
  mov    %rcx,%r9
  mov    $0x1,%r8d
  lea    D180(%rip),%rcx
  mov    %rax,%rdi
  call   <coupon_val@plt>
  add    $0x20,%rsp
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L707
  mov    $0x0,%eax
  jmp    L693
L707:
  mov    -0x1c(%rbp),%eax
  cmp    $0x4,%eax
  jle    L107
  mov    -0x1c(%rbp),%eax
  cmp    $0x8,%eax
  jg     L107
  mov    -0x40(%rbp),%rax
  movl   $0x3,(%rax)
  mov    -0x10(%rbp),%rax
  sub    $0x1,%rax
  sub    -0x28(%rbp),%rax
  add    $0x1,%eax
  mov    %eax,%edx
  mov    -0x48(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x10(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x50(%rbp),%rax
  lea    D168(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  mov    $0x0,%eax
  jmp    L693
L107:
  mov    -0x10(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rsp
  push   -0x50(%rbp)
  push   -0x48(%rbp)
  push   -0x40(%rbp)
  mov    $0x0,%r9d
  mov    $0x3,%r8d
  lea    D200(%rip),%rcx
  mov    %rax,%rdi
  call   <coupon_val@plt>
  add    $0x20,%rsp
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L270
  mov    $0x0,%eax
  jmp    L693
L270:
  mov    -0x10(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rsp
  push   -0x50(%rbp)
  push   -0x48(%rbp)
  push   -0x40(%rbp)
  push   $0x1
  push   $0x6
  mov    $0x0,%r9d
  mov    $0x6,%r8d
  lea    D46(%rip),%rcx
  mov    %rax,%rdi
  call   <coupon_vli@plt>
  add    $0x30,%rsp
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L192
  mov    $0x0,%eax
  jmp    L693
L344:
  cmpl   $0x2,-0x14(%rbp)
  jne    L510
  mov    -0x10(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rsp
  push   -0x50(%rbp)
  push   -0x48(%rbp)
  push   -0x40(%rbp)
  push   $0x0
  push   $0x5
  mov    $0x1,%r9d
  mov    $0x0,%r8d
  lea    D172(%rip),%rcx
  mov    %rax,%rdi
  call   <coupon_vli@plt>
  add    $0x30,%rsp
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L263
  mov    $0x0,%eax
  jmp    L693
L263:
  lea    -0x1c(%rbp),%rcx
  mov    -0x10(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rsp
  push   -0x50(%rbp)
  push   -0x48(%rbp)
  push   -0x40(%rbp)
  mov    %rcx,%r9
  mov    $0x1,%r8d
  lea    D78(%rip),%rcx
  mov    %rax,%rdi
  call   <coupon_val@plt>
  add    $0x20,%rsp
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L148
  mov    $0x0,%eax
  jmp    L693
L148:
  mov    -0x1c(%rbp),%eax
  cmp    $0x4,%eax
  jle    L151
  mov    -0x1c(%rbp),%eax
  cmp    $0x8,%eax
  jg     L151
  mov    -0x40(%rbp),%rax
  movl   $0x3,(%rax)
  mov    -0x10(%rbp),%rax
  sub    $0x1,%rax
  sub    -0x28(%rbp),%rax
  add    $0x1,%eax
  mov    %eax,%edx
  mov    -0x48(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x10(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x50(%rbp),%rax
  lea    D260(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  mov    $0x0,%eax
  jmp    L693
L151:
  mov    -0x10(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rsp
  push   -0x50(%rbp)
  push   -0x48(%rbp)
  push   -0x40(%rbp)
  mov    $0x0,%r9d
  mov    $0x3,%r8d
  lea    D88(%rip),%rcx
  mov    %rax,%rdi
  call   <coupon_val@plt>
  add    $0x20,%rsp
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L22
  mov    $0x0,%eax
  jmp    L693
L22:
  mov    -0x10(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rsp
  push   -0x50(%rbp)
  push   -0x48(%rbp)
  push   -0x40(%rbp)
  push   $0x1
  push   $0x6
  mov    $0x0,%r9d
  mov    $0x6,%r8d
  lea    D58(%rip),%rcx
  mov    %rax,%rdi
  call   <coupon_vli@plt>
  add    $0x30,%rsp
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L192
  mov    $0x0,%eax
  jmp    L693
L510:
  cmpl   $0x3,-0x14(%rbp)
  jne    L570
  mov    -0x10(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rsp
  push   -0x50(%rbp)
  push   -0x48(%rbp)
  push   -0x40(%rbp)
  mov    $0x0,%r9d
  mov    $0x6,%r8d
  lea    D111(%rip),%rcx
  mov    %rax,%rdi
  call   <coupon_val@plt>
  add    $0x20,%rsp
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L324
  mov    $0x0,%eax
  jmp    L693
L324:
  mov    -0x10(%rbp),%rax
  sub    $0x6,%rax
  sub    -0x28(%rbp),%rax
  mov    %eax,%edi
  mov    -0x40(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rsp
  push   $0x0
  push   -0x50(%rbp)
  push   -0x48(%rbp)
  mov    %rdx,%r9
  mov    $0x6,%r8d
  mov    $0x6,%ecx
  mov    %edi,%edx
  mov    %rax,%rdi
  call   <yymmd0@plt>
  add    $0x20,%rsp
  test   %eax,%eax
  jne    L192
  mov    $0x0,%eax
  jmp    L693
L570:
  cmpl   $0x4,-0x14(%rbp)
  jne    L122
  mov    -0x10(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rsp
  push   -0x50(%rbp)
  push   -0x48(%rbp)
  push   -0x40(%rbp)
  mov    $0x0,%r9d
  mov    $0x6,%r8d
  lea    D14(%rip),%rcx
  mov    %rax,%rdi
  call   <coupon_val@plt>
  add    $0x20,%rsp
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L68
  mov    $0x0,%eax
  jmp    L693
L68:
  mov    -0x10(%rbp),%rax
  sub    $0x6,%rax
  sub    -0x28(%rbp),%rax
  mov    %eax,%edi
  mov    -0x40(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rsp
  push   $0x0
  push   -0x50(%rbp)
  push   -0x48(%rbp)
  mov    %rdx,%r9
  mov    $0x6,%r8d
  mov    $0x6,%ecx
  mov    %edi,%edx
  mov    %rax,%rdi
  call   <yymmd0@plt>
  add    $0x20,%rsp
  test   %eax,%eax
  jne    L192
  mov    $0x0,%eax
  jmp    L693
L122:
  cmpl   $0x5,-0x14(%rbp)
  jne    L737
  mov    -0x10(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rsp
  push   -0x50(%rbp)
  push   -0x48(%rbp)
  push   -0x40(%rbp)
  push   $0x0
  push   $0x9
  mov    $0x0,%r9d
  mov    $0x6,%r8d
  lea    D216(%rip),%rcx
  mov    %rax,%rdi
  call   <coupon_vli@plt>
  add    $0x30,%rsp
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L192
  mov    $0x0,%eax
  jmp    L693
L737:
  cmpl   $0x6,-0x14(%rbp)
  jne    L84
  mov    -0x10(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rsp
  push   -0x50(%rbp)
  push   -0x48(%rbp)
  push   -0x40(%rbp)
  push   $0x0
  push   $0x7
  mov    $0x1,%r9d
  mov    $0x6,%r8d
  lea    D165(%rip),%rcx
  mov    %rax,%rdi
  call   <coupon_vli@plt>
  add    $0x30,%rsp
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L192
  mov    $0x0,%eax
  jmp    L693
L84:
  cmpl   $0x9,-0x14(%rbp)
  jne    L471
  lea    -0x1c(%rbp),%rcx
  mov    -0x10(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rsp
  push   -0x50(%rbp)
  push   -0x48(%rbp)
  push   -0x40(%rbp)
  mov    %rcx,%r9
  mov    $0x1,%r8d
  lea    D112(%rip),%rcx
  mov    %rax,%rdi
  call   <coupon_val@plt>
  add    $0x20,%rsp
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L767
  mov    $0x0,%eax
  jmp    L693
L767:
  mov    -0x1c(%rbp),%eax
  cmp    $0x2,%eax
  jle    L140
  mov    -0x1c(%rbp),%eax
  cmp    $0x4,%eax
  jle    L378
L140:
  mov    -0x1c(%rbp),%eax
  cmp    $0x6,%eax
  jle    L763
L378:
  mov    -0x40(%rbp),%rax
  movl   $0x3,(%rax)
  mov    -0x10(%rbp),%rax
  sub    $0x1,%rax
  sub    -0x28(%rbp),%rax
  add    $0x1,%eax
  mov    %eax,%edx
  mov    -0x48(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x10(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x50(%rbp),%rax
  lea    D118(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  mov    $0x0,%eax
  jmp    L693
L763:
  lea    -0x1c(%rbp),%rcx
  mov    -0x10(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rsp
  push   -0x50(%rbp)
  push   -0x48(%rbp)
  push   -0x40(%rbp)
  mov    %rcx,%r9
  mov    $0x1,%r8d
  lea    D255(%rip),%rcx
  mov    %rax,%rdi
  call   <coupon_val@plt>
  add    $0x20,%rsp
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L761
  mov    $0x0,%eax
  jmp    L693
L761:
  mov    -0x1c(%rbp),%eax
  cmp    $0x2,%eax
  jle    L739
  mov    -0x40(%rbp),%rax
  movl   $0x3,(%rax)
  mov    -0x10(%rbp),%rax
  sub    $0x1,%rax
  sub    -0x28(%rbp),%rax
  add    $0x1,%eax
  mov    %eax,%edx
  mov    -0x48(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x10(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x50(%rbp),%rax
  lea    D139(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  mov    $0x0,%eax
  jmp    L693
L739:
  mov    -0x10(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rsp
  push   -0x50(%rbp)
  push   -0x48(%rbp)
  push   -0x40(%rbp)
  mov    $0x0,%r9d
  mov    $0x1,%r8d
  lea    D128(%rip),%rcx
  mov    %rax,%rdi
  call   <coupon_val@plt>
  add    $0x20,%rsp
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L781
  mov    $0x0,%eax
  jmp    L693
L781:
  lea    -0x1c(%rbp),%rcx
  mov    -0x10(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rsp
  push   -0x50(%rbp)
  push   -0x48(%rbp)
  push   -0x40(%rbp)
  mov    %rcx,%r9
  mov    $0x1,%r8d
  lea    D230(%rip),%rcx
  mov    %rax,%rdi
  call   <coupon_val@plt>
  add    $0x20,%rsp
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L436
  mov    $0x0,%eax
  jmp    L693
L436:
  mov    -0x1c(%rbp),%eax
  cmp    $0x1,%eax
  jle    L192
  mov    -0x40(%rbp),%rax
  movl   $0x3,(%rax)
  mov    -0x10(%rbp),%rax
  sub    $0x1,%rax
  sub    -0x28(%rbp),%rax
  add    $0x1,%eax
  mov    %eax,%edx
  mov    -0x48(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x10(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x50(%rbp),%rax
  lea    D263(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  mov    $0x0,%eax
  jmp    L693
L471:
  mov    -0x40(%rbp),%rax
  movl   $0x3,(%rax)
  mov    -0x10(%rbp),%rax
  sub    $0x1,%rax
  sub    -0x28(%rbp),%rax
  add    $0x1,%eax
  mov    %eax,%edx
  mov    -0x48(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x10(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  cmpl   $0x0,-0x14(%rbp)
  jns    L250
  lea    D196(%rip),%rax
  jmp    L768
L250:
  lea    D37(%rip),%rax
L768:
  mov    -0x50(%rbp),%rcx
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <sprintf@plt>
  mov    $0x0,%eax
  jmp    L693
L192:
  mov    -0x10(%rbp),%rax
  sub    -0x28(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x2c(%rbp),%eax
  cltq
  cmp    %rax,%rdx
  jl     L645
L369:
  mov    $0x1,%eax
L693:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L241
  call   <__stack_chk_fail@plt>
L241:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: label: D115
data_type: string
name: unpack_data
arguments: label: D51
data_type: string
name: unpack_data
arguments: label: D150
data_type: string
name: unpack_data
arguments: label: D166
data_type: string
name: unpack_data
arguments: label: D146
data_type: string
name: unpack_data
arguments: label: D100
data_type: string
name: unpack_data
arguments: label: D108
data_type: string
name: unpack_data
arguments: label: D286
data_type: string
name: unpack_data
arguments: label: D47
data_type: string
name: unpack_data
arguments: label: D217
data_type: string
name: unpack_data
arguments: label: D180
data_type: string
name: unpack_data
arguments: label: D168
data_type: string
name: unpack_data
arguments: label: D200
data_type: string
name: unpack_data
arguments: label: D46
data_type: string
name: unpack_data
arguments: label: D172
data_type: string
name: unpack_data
arguments: label: D78
data_type: string
name: unpack_data
arguments: label: D260
data_type: string
name: unpack_data
arguments: label: D88
data_type: string
name: unpack_data
arguments: label: D58
data_type: string
name: unpack_data
arguments: label: D111
data_type: string
name: unpack_data
arguments: label: D14
data_type: string
name: unpack_data
arguments: label: D216
data_type: string
name: unpack_data
arguments: label: D165
data_type: string
name: unpack_data
arguments: label: D112
data_type: string
name: unpack_data
arguments: label: D118
data_type: string
name: unpack_data
arguments: label: D255
data_type: string
name: unpack_data
arguments: label: D139
data_type: string
name: unpack_data
arguments: label: D128
data_type: string
name: unpack_data
arguments: label: D230
data_type: string
name: unpack_data
arguments: label: D263
data_type: string
name: unpack_data
arguments: label: D196
data_type: string
name: unpack_data
arguments: label: D37
data_type: string

tool: D115: Primary GS1 Co. Prefix

tool: D51: Offer Code

tool: D150: Save Value

tool: D166: Primary Purch. Req.

tool: D146: Primary Purch. Req. Code

tool: D100: Invalid Primary Purch. Req. Code '%c'

tool: D108: Primary Purch. Family Code

tool: D286: Add. Purch. Rules Code

tool: D47: Invalid Add. Purch. Rules Code '%c'

tool: D217: 2nd Purch. Req.

tool: D180: 2nd Purch. Req. Code

tool: D168: Invalid 2nd Purch. Req. Code '%c'

tool: D200: 2nd Purch. Family Code

tool: D46: 2nd Purch. GS1 Co. Prefix

tool: D172: 3rd Purch. Req.

tool: D78: 3rd Purch. Req. Code

tool: D260: Invalid 3rd Purch. Req. Code '%c'

tool: D88: 3rd Purch. Family Code

tool: D58: 3rd Purch. GS1 Co. Prefix

tool: D111: Expiration Date

tool: D14: Start Date

tool: D216: Serial Number

tool: D165: Retailer ID

tool: D112: Save Value Code

tool: D118: Invalid Save Value Code '%c'

tool: D255: Save Value Applies To

tool: D139: Invalid Save Value Applies To '%c'

tool: D128: Store Coupon Flag

tool: D230: Don't Multiply Flag

tool: D263: Invalid Don't Multiply Flag '%c'

tool: D196: Non-numeric Data Field '%c'

tool: D37: Invalid Data Field '%c'

assistant: ```c
int couponcode(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no, int *p_err_posn, char err_msg[50], const int length_only) {
  const int min_req_len = 1 + 6 + 6 + 1 + 1 + 1 + 1 + 1 + 3;
  (void)max;
  data_len -= offset;
  if (data_len < min) {
    return 0;
  }
  if (data_len && data_len < min_req_len) {
    *p_err_no = 4;
    return 0;
  }
  if (!length_only && data_len) {
    const unsigned char *d = data + offset;
    int val;
    data_len += offset;
    d = coupon_vli(data, data_len, d, "Primary GS1 Co. Prefix", 6, 0, 6, 0, p_err_no, p_err_posn, err_msg);
    if (d == NULL) {
      return 0;
    }
    d = coupon_val(data, data_len, d, "Offer Code", 6, NULL, p_err_no, p_err_posn, err_msg);
    if (d == NULL) {
      return 0;
    }
    d = coupon_vli(data, data_len, d, "Save Value", 0, 1, 5, 0, p_err_no, p_err_posn, err_msg);
    if (d == NULL) {
      return 0;
    }
    d = coupon_vli(data, data_len, d, "Primary Purch. Req.", 0, 1, 5, 0, p_err_no, p_err_posn, err_msg);
    if (d == NULL) {
      return 0;
    }
    d = coupon_val(data, data_len, d, "Primary Purch. Req. Code", 1, &val, p_err_no, p_err_posn, err_msg);
    if (d == NULL) {
      return 0;
    }
    if (val > 5 && val < 9) {
      *p_err_no = 3;
      *p_err_posn = d - 1 - data + 1;
      sprintf(err_msg, "Invalid Primary Purch. Req. Code '%c'", *(d - 1));
      return 0;
    }
    d = coupon_val(data, data_len, d, "Primary Purch. Family Code", 3, NULL, p_err_no, p_err_posn, err_msg);
    if (d == NULL) {
      return 0;
    }
    while (d - data < data_len) {
      int data_field = to_int(d, 1);
      d++;
      if (data_field == 1) {
        d = coupon_val(data, data_len, d, "Add. Purch. Rules Code", 1, &val, p_err_no, p_err_posn, err_msg);
        if (d == NULL) {
          return 0;
        }
        if (val > 3) {
          *p_err_no = 3;
          *p_err_posn = d - 1 - data + 1;
          sprintf(err_msg, "Invalid Add. Purch. Rules Code '%c'", *(d - 1));
          return 0;
        }
        d = coupon_vli(data, data_len, d, "2nd Purch. Req.", 0, 1, 5, 0, p_err_no, p_err_posn, err_msg);
        if (d == NULL) {
          return 0;
        }
        d = coupon_val(data, data_len, d, "2nd Purch. Req. Code", 1, &val, p_err_no, p_err_posn, err_msg);
        if (d == NULL) {
          return 0;
        }
        if (val > 4 && val < 9) {
          *p_err_no = 3;
          *p_err_posn = d - 1 - data + 1;
          sprintf(err_msg, "Invalid 2nd Purch. Req. Code '%c'", *(d - 1));
          return 0;
        }
        d = coupon_val(data, data_len, d, "2nd Purch. Family Code", 3, NULL, p_err_no, p_err_posn, err_msg);
        if (d == NULL) {
          return 0;
        }
        d = coupon_vli(data, data_len, d, "2nd Purch. GS1 Co. Prefix", 6, 0, 6, 1, p_err_no, p_err_posn, err_msg);
        if (d == NULL) {
          return 0;
        }
      } else if (data_field == 2) {
        d = coupon_vli(data, data_len, d, "3rd Purch. Req.", 0, 1, 5, 0, p_err_no, p_err_posn, err_msg);
        if (d == NULL) {
          return 0;
        }
        d = coupon_val(data, data_len, d, "3rd Purch. Req. Code", 1, &val, p_err_no, p_err_posn, err_msg);
        if (d == NULL) {
          return 0;
        }
        if (val > 4 && val < 9) {
          *p_err_no = 3;
          *p_err_posn = d - 1 - data + 1;
          sprintf(err_msg, "Invalid 3rd Purch. Req. Code '%c'", *(d - 1));
          return 0;
        }
        d = coupon_val(data, data_len, d, "3rd Purch. Family Code", 3, NULL, p_err_no, p_err_posn, err_msg);
        if (d == NULL) {
          return 0;
        }
        d = coupon_vli(data, data_len, d, "3rd Purch. GS1 Co. Prefix", 6, 0, 6, 1, p_err_no, p_err_posn, err_msg);
        if (d == NULL) {
          return 0;
        }
      } else if (data_field == 3) {
        d = coupon_val(data, data_len, d, "Expiration Date", 6, NULL, p_err_no, p_err_posn, err_msg);
        if (d == NULL) {
          return 0;
        }
        if (!yymmd0(data, data_len, d - 6 - data, 6, 6, p_err_no, p_err_posn, err_msg, 0)) {
          return 0;
        }
      } else if (data_field == 4) {
        d = coupon_val(data, data_len, d, "Start Date", 6, NULL, p_err_no, p_err_posn, err_msg);
        if (d == NULL) {
          return 0;
        }
        if (!yymmd0(data, data_len, d - 6 - data, 6, 6, p_err_no, p_err_posn, err_msg, 0)) {
          return 0;
        }
      } else if (data_field == 5) {
        d = coupon_vli(data, data_len, d, "Serial Number", 6, 0, 9, 0, p_err_no, p_err_posn, err_msg);
        if (d == NULL) {
          return 0;
        }
      } else if (data_field == 6) {
        d = coupon_vli(data, data_len, d, "Retailer ID", 6, 1, 7, 0, p_err_no, p_err_posn, err_msg);
        if (d == NULL) {
          return 0;
        }
      } else if (data_field == 9) {
        d = coupon_val(data, data_len, d, "Save Value Code", 1, &val, p_err_no, p_err_posn, err_msg);
        if (d == NULL) {
          return 0;
        }
        if ((val > 2 && val < 5) || val > 6) {
          *p_err_no = 3;
          *p_err_posn = d - 1 - data + 1;
          sprintf(err_msg, "Invalid Save Value Code '%c'", *(d - 1));
          return 0;
        }
        d = coupon_val(data, data_len, d, "Save Value Applies To", 1, &val, p_err_no, p_err_posn, err_msg);
        if (d == NULL) {
          return 0;
        }
        if (val > 2) {
          *p_err_no = 3;
          *p_err_posn = d - 1 - data + 1;
          sprintf(err_msg, "Invalid Save Value Applies To '%c'", *(d - 1));
          return 0;
        }
        d = coupon_val(data, data_len, d, "Store Coupon Flag", 1, NULL, p_err_no, p_err_posn, err_msg);
        if (d == NULL) {
          return 0;
        }
        d = coupon_val(data, data_len, d, "Don't Multiply Flag", 1, &val, p_err_no, p_err_posn, err_msg);
        if (d == NULL) {
          return 0;
        }
        if (val > 1) {
          *p_err_no = 3;
          *p_err_posn = d - 1 - data + 1;
          sprintf(err_msg, "Invalid Don't Multiply Flag '%c'", *(d - 1));
          return 0;
        }
      } else {
        *p_err_no = 3;
        *p_err_posn = d - 1 - data + 1;
        sprintf(err_msg, data_field < 0 ? "Non-numeric Data Field '%c'" : "Invalid Data Field '%c'", *(d - 1));
        return 0;
      }
    }
  }
  return 1;
}
```