// File: 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:
subq $0x28, %rsp
movl %edi, 0x24(%rsp)
movl %esi, 0x20(%rsp)
movq 0x2fe8d(%rip), %rax     # 0x5bfb0
movq (%rax), %rax
movq %rax, 0x18(%rsp)
leaq 0x1f60c(%rip), %rdi     # 0x4b73e
callq 0x2bd90
movl 0x24(%rsp), %eax
andl $-0x40, %eax
cmpl $0x0, %eax
jne 0x2c2f4
cmpl $0x0, 0x30b86(%rip)     # 0x5ccd4
jne 0x2c165
movq 0x31b41(%rip), %rax     # 0x5dc98
movslq 0x24(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x24(%rsp)
jmp 0x2c195
cmpl $0x3, 0x30b68(%rip)     # 0x5ccd4
jne 0x2c183
movq 0x31b2b(%rip), %rax     # 0x5dca0
movslq 0x24(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x24(%rsp)
jmp 0x2c193
cmpl $0x1, 0x30b4a(%rip)     # 0x5ccd4
je 0x2c191
jmp 0x2c322
jmp 0x2c193
jmp 0x2c195
movl 0x31b35(%rip), %eax     # 0x5dcd0
cmpl $0x39, %eax
jne 0x2c259
movl 0x24(%rsp), %eax
sarl $0x4, %eax
addl $0x39, %eax
movl %eax, 0x14(%rsp)
movl 0x24(%rsp), %eax
andl $0xf, %eax
addl %eax, %eax
movl %eax, 0x10(%rsp)
movl 0x20(%rsp), %eax
movl %eax, 0x4(%rsp)
testl %eax, %eax
je 0x2c1e3
jmp 0x2c1cd
movl 0x4(%rsp), %eax
subl $0x1, %eax
je 0x2c1f7
jmp 0x2c1d8
movl 0x4(%rsp), %eax
subl $0x2, %eax
je 0x2c1ed
jmp 0x2c201
movl $0x0, 0x8(%rsp)
jmp 0x2c206
movl $0x1, 0x8(%rsp)
jmp 0x2c206
movl $0x2, 0x8(%rsp)
jmp 0x2c206
jmp 0x2c322
movq 0x31aa3(%rip), %rax     # 0x5dcb0
movslq 0x14(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0xc(%rsp)
movl 0x10(%rsp), %ecx
movl $0x3, %eax
shll %cl, %eax
xorl $-0x1, %eax
andl 0xc(%rsp), %eax
movl %eax, 0xc(%rsp)
movl 0x8(%rsp), %eax
movl 0x10(%rsp), %ecx
shll %cl, %eax
orl 0xc(%rsp), %eax
movl %eax, 0xc(%rsp)
movl 0xc(%rsp), %edx
movq 0x31a64(%rip), %rax     # 0x5dcb0
movslq 0x14(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x2c2f2
movl 0x20(%rsp), %ecx
andl $0x3, %ecx
movq 0x31a49(%rip), %rax     # 0x5dcb0
movl %ecx, 0x94(%rax)
movl $0x5, %edi
callq 0x22650
movl 0x24(%rsp), %ecx
andl $0x1f, %ecx
movl $0x1, %edx
shll %cl, %edx
movq 0x31a24(%rip), %rax     # 0x5dcb0
movslq 0x24(%rsp), %rsi
leaq 0x30b48(%rip), %rcx     # 0x5cde0
movzbl (%rcx,%rsi), %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl $0x5, %edi
callq 0x22650
movq 0x319fd(%rip), %rax     # 0x5dcb0
movl $0x0, 0x94(%rax)
movl $0x5, %edi
callq 0x22650
movq 0x319e2(%rip), %rax     # 0x5dcb0
movslq 0x24(%rsp), %rdx
leaq 0x30b06(%rip), %rcx     # 0x5cde0
movzbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movl $0x0, (%rax,%rcx,4)
movl $0x5, %edi
callq 0x22650
jmp 0x2c322
movl 0x24(%rsp), %edi
callq 0x22cd0
movq %rax, 0x18(%rsp)
cmpq $0x0, %rax
je 0x2c320
movq 0x18(%rsp), %rax
movq 0x28(%rax), %rax
movq 0x18(%rsp), %rdi
movl 0x24(%rsp), %esi
movl 0x20(%rsp), %edx
callq *%rax
jmp 0x2c322
addq $0x28, %rsp
retq
nopw (%rax,%rax)