user: Demonstrate the C code that generates the assembly output below:

```asm
<ts_sdt_add_service_descriptor>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,-0x2c(%rbp)
  mov    %edx,%eax
  mov    %rcx,-0x38(%rbp)
  mov    %r8,-0x40(%rbp)
  mov    %al,-0x30(%rbp)
  cmpq   $0x0,-0x40(%rbp)
  jne    L147
  cmpq   $0x0,-0x38(%rbp)
  jne    L147
  mov    $0x0,%eax
  jmp    L180
L147:
  movl   $0x3,-0x14(%rbp)
  cmpq   $0x0,-0x38(%rbp)
  je     L118
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  lea    0x1(%rax),%edx
  jmp    L188
L118:
  mov    $0x1,%edx
L188:
  mov    -0x14(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x14(%rbp)
  cmpq   $0x0,-0x40(%rbp)
  je     L42
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  lea    0x1(%rax),%edx
  jmp    L239
L42:
  mov    $0x1,%edx
L239:
  mov    -0x14(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x14(%rbp)
  cmpl   $0x101,-0x14(%rbp)
  jle    L140
  mov    -0x14(%rbp),%eax
  mov    %eax,%esi
  lea    D0(%rip),%rax
  mov    %rax,%rdi
  call   <ts_LOGf@plt>
  mov    $0x0,%eax
  jmp    L180
L140:
  movl   $0x0,-0x18(%rbp)
  mov    -0x14(%rbp),%eax
  mov    %eax,%esi
  mov    $0x1,%edi
  call   <calloc@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x18(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x48,(%rax)
  mov    -0x14(%rbp),%eax
  lea    -0x2(%rax),%edx
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x1(%rax),%rcx
  mov    -0x8(%rbp),%rax
  add    %rcx,%rax
  mov    %dl,(%rax)
  cmpb   $0x0,-0x30(%rbp)
  je     L67
  mov    $0x1,%edx
  jmp    L21
L67:
  mov    $0x2,%edx
L21:
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x2(%rax),%rcx
  mov    -0x8(%rbp),%rax
  add    %rcx,%rax
  mov    %dl,(%rax)
  cmpq   $0x0,-0x38(%rbp)
  je     L75
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  jmp    L210
L75:
  mov    $0x0,%edx
L210:
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x3(%rax),%rcx
  mov    -0x8(%rbp),%rax
  add    %rcx,%rax
  mov    %dl,(%rax)
  addl   $0x4,-0x18(%rbp)
  cmpq   $0x0,-0x38(%rbp)
  je     L23
  mov    -0x38(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L2
L23:
  addl   $0x1,-0x18(%rbp)
  jmp    L235
L2:
  mov    -0x38(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  jmp    L216
L115:
  mov    -0x18(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x18(%rbp)
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rax,%rdx
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  addq   $0x1,-0x10(%rbp)
L216:
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L115
L235:
  cmpq   $0x0,-0x40(%rbp)
  je     L178
  mov    -0x40(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L194
L178:
  addl   $0x1,-0x18(%rbp)
  jmp    L27
L194:
  cmpq   $0x0,-0x40(%rbp)
  je     L63
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%ecx
  jmp    L74
L63:
  mov    $0x0,%ecx
L74:
  mov    -0x18(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x18(%rbp)
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    %cl,(%rax)
  mov    -0x40(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  jmp    L25
L245:
  mov    -0x18(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x18(%rbp)
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rax,%rdx
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  addq   $0x1,-0x10(%rbp)
L25:
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L245
L27:
  mov    -0x14(%rbp),%ecx
  mov    -0x8(%rbp),%rdx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <ts_sdt_add_stream@plt>
L180:
  leave
  ret
```

tool_calls: name: parse_data
arguments: tag: D0
data_type: string

tool: D0: SDT service_descriptor size > 255 is not supported (%d)!


assistant: ```c
int ts_sdt_add_service_descriptor(struct ts_sdt *sdt, uint16_t service_id, uint8_t video, char *provider_name, char *service_name) {
  char *name;
  if (!service_name && !provider_name)
    return 0;
  int desc_size = 2 + 1;
  desc_size += 1 + (provider_name ? strlen(provider_name) : 0);
  desc_size += 1 + (service_name ? strlen(service_name) : 0);
  if (desc_size > 257) {
    ts_LOGf("SDT service_descriptor size > 255 is not supported (%d)!\n", desc_size);
    return 0;
  }
  int dpos = 0;
  uint8_t *desc = calloc(1, desc_size);
  desc[dpos + 0] = 0x48;
  desc[dpos + 1] = desc_size - 2;
  desc[dpos + 2] = video ? 0x01 : 0x02;
  desc[dpos + 3] = (provider_name ? strlen(provider_name) : 0);
  dpos += 4;
  if (!provider_name || strlen(provider_name) == 0) {
    dpos++;
  } else {
    name = provider_name;
    while (name[0]) {
      desc[dpos++] = name[0];
      name++;
    }
  }
  if (!service_name || strlen(service_name) == 0) {
    dpos++;
  } else {
    desc[dpos++] = (service_name ? strlen(service_name) : 0);
    name = service_name;
    while (name[0]) {
      desc[dpos++] = name[0];
      name++;
    }
  }
  return ts_sdt_add_stream(sdt, service_id, desc, desc_size);
}
```