// File: /workspace/github_cpp_makefile_star2_O2/mrlordkaj[P]i2cdevlib-pi/Arduino/wiringPi/wiringPi.c
// Function: pinMode
void pinMode (int pin, int mode)
{
  int    fSel, shift, alt ;
  struct wiringPiNodeStruct *node = wiringPiNodes ;
  int origPin = pin ;

  setupCheck ("pinMode") ;

  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 ;

    softPwmStop  (origPin) ;
    softToneStop (origPin) ;

    fSel    = gpioToGPFSEL [pin] ;
    shift   = gpioToShift  [pin] ;

    /**/ if (mode == INPUT)
      *(gpio + fSel) = (*(gpio + fSel) & ~(7 << shift)) ; // Sets bits to zero = input
    else if (mode == OUTPUT)
      *(gpio + fSel) = (*(gpio + fSel) & ~(7 << shift)) | (1 << shift) ;
    else if (mode == SOFT_PWM_OUTPUT)
      softPwmCreate (origPin, 0, 100) ;
    else if (mode == SOFT_TONE_OUTPUT)
      softToneCreate (origPin) ;
    else if (mode == PWM_TONE_OUTPUT)
    {
      pinMode (origPin, PWM_OUTPUT) ;	// Call myself to enable PWM mode
      pwmSetMode (PWM_MODE_MS) ;
    }
    else if (mode == PWM_OUTPUT)
    {
      if ((alt = gpioToPwmALT [pin]) == 0)	// Not a hardware capable PWM pin
	return ;

      usingGpioMemCheck ("pinMode PWM") ;

// Set pin to PWM mode

      *(gpio + fSel) = (*(gpio + fSel) & ~(7 << shift)) | (alt << shift) ;
      delayMicroseconds (110) ;		// See comments in pwmSetClockWPi

      pwmSetMode  (PWM_MODE_BAL) ;	// Pi default mode
      pwmSetRange (1024) ;		// Default range of 1024
      pwmSetClock (32) ;		// 19.2 / 32 = 600KHz - Also starts the PWM
    }
    else if (mode == GPIO_CLOCK)
    {
      if ((alt = gpioToGpClkALT0 [pin]) == 0)	// Not a GPIO_CLOCK pin
	return ;

      usingGpioMemCheck ("pinMode CLOCK") ;

// Set pin to GPIO_CLOCK mode and set the clock frequency to 100KHz

      *(gpio + fSel) = (*(gpio + fSel) & ~(7 << shift)) | (alt << shift) ;
      delayMicroseconds (110) ;
      gpioClockSet      (pin, 100000) ;
    }
  }
  else
  {
    if ((node = wiringPiFindNode (pin)) != NULL)
      node->pinMode (node, pin, mode) ;
    return ;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebp
movl %edi, %ebx
leaq 0xfae3(%rip), %rdi      # 0x33a93
callq 0x23f6f
cmpl $0x3f, %ebx
ja 0x23fde
movl 0x25a74(%rip), %eax     # 0x49a34
testl %eax, %eax
je 0x24003
movl %ebx, %r15d
cmpl $0x1, %eax
je 0x24013
cmpl $0x3, %eax
jne 0x241ae
leaq 0x26764(%rip), %rax     # 0x4a740
jmp 0x2400a
movl %ebx, %edi
callq 0x1f9a0
testq %rax, %rax
je 0x241ae
movq 0x20(%rax), %rcx
movq %rax, %rdi
movl %ebx, %esi
movl %ebp, %edx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmpq *%rcx
leaq 0x2672e(%rip), %rax     # 0x4a738
movq (%rax), %rax
movl %ebx, %ecx
movl (%rax,%rcx,4), %r15d
movl %ebx, %edi
callq 0x1f6a0
movl %ebx, %edi
callq 0x1f530
cmpl $0x6, %ebp
ja 0x241ae
movslq %r15d, %rax
leaq 0xf1fc(%rip), %rcx      # 0x33230
movzbl (%rax,%rcx), %r12d
leaq 0xf230(%rip), %rcx      # 0x33270
movzbl (%rax,%rcx), %r14d
movl %ebp, %ecx
leaq 0xf182(%rip), %rdx      # 0x331d0
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movq 0x266f2(%rip), %rax     # 0x4a750
pushq $0x7
popq %rdx
movl %r14d, %ecx
shll %cl, %edx
notl %edx
andl %edx, (%rax,%r12,4)
jmp 0x241ae
pushq $0x64
popq %rdx
movl %ebx, %edi
xorl %esi, %esi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x1f180
leaq 0xf3a4(%rip), %rcx      # 0x33430
movzbl (%rax,%rcx), %ebx
testl %ebx, %ebx
je 0x241ae
leaq 0xf9fc(%rip), %rdi      # 0x33a9b
callq 0x241b7
movq 0x266a5(%rip), %rax     # 0x4a750
pushq $0x7
popq %rdx
movl %r14d, %ecx
shll %cl, %edx
notl %edx
shll %cl, %ebx
andl (%rax,%r12,4), %edx
orl %edx, %ebx
movl %ebx, (%rax,%r12,4)
pushq $0x6e
popq %rdi
callq 0x1f430
movl 0x25965(%rip), %eax     # 0x49a34
cmpl $0x3, %eax
ja 0x240e6
cmpl $0x2, %eax
je 0x240e6
movq 0x26678(%rip), %rax     # 0x4a758
movl $0x101, (%rax)          # imm = 0x101
movl $0x400, %edi            # imm = 0x400
callq 0x1f4b0
pushq $0x20
popq %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x1f750
leaq 0xf369(%rip), %rcx      # 0x33470
movzbl (%rax,%rcx), %ebx
testl %ebx, %ebx
je 0x241ae
leaq 0xf98d(%rip), %rdi      # 0x33aa7
callq 0x241b7
movq 0x2662a(%rip), %rax     # 0x4a750
pushq $0x7
popq %rdx
movl %r14d, %ecx
shll %cl, %edx
notl %edx
shll %cl, %ebx
andl (%rax,%r12,4), %edx
orl %edx, %ebx
movl %ebx, (%rax,%r12,4)
pushq $0x6e
popq %rdi
callq 0x1f430
movl %r15d, %edi
movl $0x186a0, %esi          # imm = 0x186A0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x1f9d0
movq 0x265f0(%rip), %rax     # 0x4a750
pushq $0x7
popq %rdx
movl %r14d, %ecx
shll %cl, %edx
notl %edx
andl (%rax,%r12,4), %edx
btsl %r14d, %edx
movl %edx, (%rax,%r12,4)
jmp 0x241ae
movl %ebx, %edi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x1f560
pushq $0x2
popq %rsi
movl %ebx, %edi
callq 0x1f450
movl 0x2589d(%rip), %eax     # 0x49a34
cmpl $0x3, %eax
ja 0x241ae
cmpl $0x2, %eax
je 0x241ae
movq 0x265b0(%rip), %rax     # 0x4a758
movl $0x8181, (%rax)         # imm = 0x8181
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq