user: What is the c source code of the assembly code below?

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x38(%rbp)
  movl   $0x0,-0x34(%rbp)
  movl   $0x0,-0x24(%rbp)
  movl   $0x0,-0x20(%rbp)
  movl   $0x0,-0xc(%rbp)
  movl   $0x0,-0x1c(%rbp)
  movl   $0x0,-0x30(%rbp)
  movl   $0x0,-0x18(%rbp)
  movl   $0x0,-0x2c(%rbp)
  movl   $0x0,-0x28(%rbp)
  movl   $0x0,-0x14(%rbp)
  movl   $0x0,-0x10(%rbp)
  lea    -0x38(%rbp),%rdx
  lea    -0x34(%rbp),%rax
  mov    %rax,%rsi
  lea    D66(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  jmp    L49
L98:
  lea    -0x28(%rbp),%rcx
  lea    -0x2c(%rbp),%rdx
  lea    -0x30(%rbp),%rax
  mov    %rax,%rsi
  lea    D26(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  mov    -0x30(%rbp),%edx
  mov    -0x38(%rbp),%eax
  cmp    %eax,%edx
  jg     L104
  mov    -0x28(%rbp),%eax
  mov    -0x2c(%rbp),%edx
  sub    %edx,%eax
  cmp    $0x2,%eax
  jne    L139
  mov    -0x2c(%rbp),%edx
  mov    -0x20(%rbp),%eax
  sub    %edx,%eax
  mov    %eax,%edx
  neg    %edx
  cmovns %edx,%eax
  and    $0x1,%eax
  test   %eax,%eax
  je     L139
  lea    D9(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x0,%eax
  jmp    L175
L139:
  cmpl   $0x0,-0x24(%rbp)
  jle    L52
  mov    -0x14(%rbp),%eax
  lea    -0x2(%rax),%ecx
  mov    -0x14(%rbp),%eax
  sub    -0x20(%rbp),%eax
  mov    %eax,%edx
  neg    %edx
  cmovns %edx,%eax
  and    $0x1,%eax
  lea    (%rcx,%rax,1),%edx
  mov    -0x30(%rbp),%eax
  add    %edx,%eax
  sub    -0x24(%rbp),%eax
  mov    %eax,%edx
  mov    -0x2c(%rbp),%eax
  cmp    %eax,%edx
  jg     L52
  lea    D9(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x0,%eax
  jmp    L175
L52:
  mov    -0x30(%rbp),%edx
  mov    -0x20(%rbp),%eax
  sub    %edx,%eax
  mov    %eax,%ecx
  mov    -0x24(%rbp),%eax
  add    %ecx,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x28(%rbp),%eax
  cmp    %eax,-0xc(%rbp)
  jl     L171
  lea    D9(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x0,%eax
  jmp    L175
L171:
  mov    -0x2c(%rbp),%eax
  cmp    %eax,-0xc(%rbp)
  jg     L58
  mov    -0x2c(%rbp),%edx
  mov    -0xc(%rbp),%eax
  sub    %edx,%eax
  mov    %eax,%edx
  neg    %edx
  cmovns %edx,%eax
  and    $0x1,%eax
  test   %eax,%eax
  jne    L45
  mov    -0x2c(%rbp),%eax
  add    $0x2,%eax
  mov    %eax,-0x18(%rbp)
  jmp    L120
L45:
  mov    -0x2c(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x18(%rbp)
L120:
  mov    -0x28(%rbp),%eax
  cmp    %eax,-0x18(%rbp)
  jl     L25
  lea    D9(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x0,%eax
  jmp    L175
L25:
  mov    -0x18(%rbp),%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x30(%rbp),%eax
  mov    %eax,-0x24(%rbp)
  mov    -0x18(%rbp),%eax
  sub    -0xc(%rbp),%eax
  sar    %eax
  add    %eax,-0x10(%rbp)
  jmp    L154
L58:
  mov    -0xc(%rbp),%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x30(%rbp),%eax
  mov    %eax,-0x24(%rbp)
L154:
  mov    -0x28(%rbp),%eax
  mov    %eax,-0x14(%rbp)
  addl   $0x1,-0x1c(%rbp)
L49:
  mov    -0x34(%rbp),%eax
  cmp    %eax,-0x1c(%rbp)
  jl     L98
  jmp    L90
L104:
  nop
L90:
  mov    -0x10(%rbp),%eax
  mov    %eax,%esi
  lea    D41(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x0,%eax
L175:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L127
  call   <__stack_chk_fail@plt>
L127:
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: tag: D66
datatype: string
name: retrieve_data
arguments: tag: D26
datatype: string
name: retrieve_data
arguments: tag: D9
datatype: string
name: retrieve_data
arguments: tag: D41
datatype: string

tool: D66: %d %d

tool: D26: %d %d %d

tool: D9: NIE

tool: D41: %d


assistant: ```c
int main() {
  int SurfaceLength = 0, ObstacleCount = 0, StartX = 0, StartY = 0, CurrentY = 0, ObstacleIndex = 0, ObstacleX = 0, ObstacleY = 0, ObstacleMinimum = 0, ObstacleMaximum = 0, LastObstacle = 0, StepCount = 0;
  scanf("%d %d", &ObstacleCount, &SurfaceLength);
  while (ObstacleIndex < ObstacleCount) {
    scanf("%d %d %d", &ObstacleX, &ObstacleMinimum, &ObstacleMaximum);
    if (ObstacleX > SurfaceLength) {
      break;
    }
    if (((ObstacleMaximum - ObstacleMinimum) == 2) && ((abs(StartY - ObstacleMinimum) % 2) == 1)) {
      printf("NIE\n");
      return 0;
    }
    if ((StartX > 0) && ((LastObstacle - 2 + (abs(LastObstacle - StartY) % 2) + ObstacleX - StartX) <= ObstacleMinimum)) {
      printf("NIE\n");
      return 0;
    }
    CurrentY = StartY - ObstacleX + StartX;
    if (CurrentY >= ObstacleMaximum) {
      printf("NIE\n");
      return 0;
    } else if (CurrentY <= ObstacleMinimum) {
      if ((abs(CurrentY - ObstacleMinimum) % 2) == 0) {
        ObstacleY = (ObstacleMinimum + 2);
      } else {
        ObstacleY = (ObstacleMinimum + 1);
      }
      if (ObstacleY >= ObstacleMaximum) {
        printf("NIE\n");
        return 0;
      }
      StartY = ObstacleY;
      StartX = ObstacleX;
      StepCount = StepCount + ((ObstacleY - CurrentY) >> 1);
    } else {
      StartY = CurrentY;
      StartX = ObstacleX;
    }
    LastObstacle = ObstacleMaximum;
    ObstacleIndex++;
  }
  printf("%d\n", StepCount);
  return 0;
}
```