// File: /workspace/github_cpp_makefile_star2_O1/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 %rbx
pushq %rax
movl %esi, %ebp
movl %edi, %ebx
leaq 0x116f0(%rip), %rdi     # 0x35ab5
callq 0x2412c
cmpl $0x3f, %ebx
ja 0x243f0
movl 0x2339f(%rip), %eax     # 0x47774
testl %eax, %eax
je 0x24425
cmpl $0x1, %eax
je 0x24434
cmpl $0x3, %eax
jne 0x2447b
leaq 0x24092(%rip), %rax     # 0x48480
jmp 0x2442c
movq 0x22bc1(%rip), %rax     # 0x46fb8
movq (%rax), %rdi
testq %rdi, %rdi
je 0x2440e
cmpl %ebx, (%rdi)
jg 0x24408
cmpl %ebx, 0x4(%rdi)
jge 0x24410
movq 0x58(%rdi), %rdi
jmp 0x243fa
xorl %edi, %edi
testq %rdi, %rdi
je 0x2447b
movq 0x28(%rdi), %rax
movl %ebx, %esi
movl %ebp, %edx
addq $0x8, %rsp
popq %rbx
popq %rbp
jmpq *%rax
leaq 0x2404c(%rip), %rax     # 0x48478
movq (%rax), %rax
movl %ebx, %ecx
movl (%rax,%rcx,4), %ebx
movl 0x24076(%rip), %eax     # 0x484b0
cmpl $0x39, %eax
jne 0x24482
cmpl $0x2, %ebp
ja 0x2447b
leal (%rbx,%rbx), %ecx
sarl $0x4, %ebx
movl %ebp, %eax
leaq 0x1109d(%rip), %rdx     # 0x354f0
movl (%rdx,%rax,4), %eax
movq 0x24033(%rip), %rdx     # 0x48490
movslq %ebx, %rsi
movl $0x3, %edi
shll %cl, %edi
notl %edi
shll %cl, %eax
andl 0xe4(%rdx,%rsi,4), %edi
orl %edi, %eax
movl %eax, 0xe4(%rdx,%rsi,4)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
andl $0x3, %ebp
movq 0x24004(%rip), %rax     # 0x48490
movl %ebp, 0x94(%rax)
movl $0x5, %edi
callq 0x1f240
movl $0x1, %eax
movl %ebx, %ecx
shll %cl, %eax
movq 0x23fe4(%rip), %rcx     # 0x48490
movslq %ebx, %rdx
leaq 0x10e7a(%rip), %rsi     # 0x35330
movzbl (%rdx,%rsi), %ebx
shll $0x2, %ebx
movl %eax, (%rcx,%rbx)
movl $0x5, %edi
callq 0x1f240
movq 0x23fbf(%rip), %rax     # 0x48490
xorl %ebp, %ebp
movl %ebp, 0x94(%rax)
movl $0x5, %edi
callq 0x1f240
movq 0x23fa6(%rip), %rax     # 0x48490
movl %ebp, (%rax,%rbx)
movl $0x5, %edi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x1f240