// File: /workspace/github_cpp_makefile_star2_O2/mrlordkaj[P]i2cdevlib-pi/Arduino/wiringPi/wiringPi.c
// Function: pullUpDnControl
void pullUpDnControl (int pin, int pud)
{
  struct wiringPiNodeStruct *node = wiringPiNodes ;

  setupCheck ("pullUpDnControl") ;

  if ((pin & PI_GPIO_MASK) == 0)		// On-Board Pin
  {
    /**/ if (wiringPiMode == WPI_MODE_PINS)
      pin = pinToGpio [pin] ;
    else if (wiringPiMode == WPI_MODE_PHYS)
      pin = physToGpio [pin] ;
    else if (wiringPiMode != WPI_MODE_GPIO)
      return ;

    if (piGpioPupOffset == GPPUPPDN0)
    {
      // Pi 4B pull up/down method
      int pullreg = GPPUPPDN0 + (pin>>4);
      int pullshift = (pin & 0xf) << 1;
      unsigned int pullbits;
      unsigned int pull;

      switch (pud)
      {
        case PUD_OFF: pull = 0; break;
        case PUD_UP: pull = 1; break;
        case PUD_DOWN: pull = 2; break;
        default: return ; /* An illegal value */
      }

      pullbits = *(gpio + pullreg);
      pullbits &= ~(3 << pullshift);
      pullbits |= (pull << pullshift);
      *(gpio + pullreg) = pullbits;
    }
    else
    {
      // legacy pull up/down method
      *(gpio + GPPUD)              = pud & 3 ;		delayMicroseconds (5) ;
      *(gpio + gpioToPUDCLK [pin]) = 1 << (pin & 31) ;	delayMicroseconds (5) ;

      *(gpio + GPPUD)              = 0 ;			delayMicroseconds (5) ;
      *(gpio + gpioToPUDCLK [pin]) = 0 ;			delayMicroseconds (5) ;
    }
  }
  else						// Extension module
  {
    if ((node = wiringPiFindNode (pin)) != NULL)
      node->pullUpDnControl (node, pin, pud) ;
    return ;
  }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movl %edi, %ebx
leaq 0xf8c1(%rip), %rdi      # 0x33ab5
callq 0x23f6f
cmpl $0x3f, %ebx
ja 0x2421b
movl 0x25830(%rip), %eax     # 0x49a34
testl %eax, %eax
je 0x24238
cmpl $0x1, %eax
je 0x24247
cmpl $0x3, %eax
jne 0x2428c
leaq 0x26527(%rip), %rax     # 0x4a740
jmp 0x2423f
movl %ebx, %edi
callq 0x1f9a0
testq %rax, %rax
je 0x2428c
movq 0x28(%rax), %rcx
movq %rax, %rdi
movl %ebx, %esi
movl %ebp, %edx
popq %rbx
popq %r14
popq %rbp
jmpq *%rcx
leaq 0x264f9(%rip), %rax     # 0x4a738
movq (%rax), %rax
movl %ebx, %ecx
movl (%rax,%rcx,4), %ebx
movl 0x26523(%rip), %eax     # 0x4a770
cmpl $0x39, %eax
jne 0x24291
cmpl $0x2, %ebp
ja 0x2428c
leal (%rbx,%rbx), %ecx
sarl $0x4, %ebx
movl %ebp, %eax
leaq 0xf28a(%rip), %rdx      # 0x334f0
movl (%rdx,%rax,4), %eax
movq 0x264e0(%rip), %rdx     # 0x4a750
movslq %ebx, %rsi
pushq $0x3
popq %rdi
shll %cl, %edi
notl %edi
shll %cl, %eax
andl 0xe4(%rdx,%rsi,4), %edi
orl %edi, %eax
movl %eax, 0xe4(%rdx,%rsi,4)
popq %rbx
popq %r14
popq %rbp
retq
andl $0x3, %ebp
movq 0x264b5(%rip), %rax     # 0x4a750
movl %ebp, 0x94(%rax)
pushq $0x5
popq %rbp
movl %ebp, %edi
callq 0x1f430
pushq $0x1
popq %rax
movl %ebx, %ecx
shll %cl, %eax
movq 0x26497(%rip), %rcx     # 0x4a750
movslq %ebx, %rdx
leaq 0xf06d(%rip), %rsi      # 0x33330
movzbl (%rdx,%rsi), %ebx
shll $0x2, %ebx
movl %eax, (%rcx,%rbx)
movl %ebp, %edi
callq 0x1f430
movq 0x26475(%rip), %rax     # 0x4a750
xorl %r14d, %r14d
movl %r14d, 0x94(%rax)
movl %ebp, %edi
callq 0x1f430
movq 0x2645d(%rip), %rax     # 0x4a750
movl %r14d, (%rax,%rbx)
movl %ebp, %edi
popq %rbx
popq %r14
popq %rbp
jmp 0x1f430