// File: /workspace/github_cpp_makefile_star2_O1/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
subq $0x10, %rsp
movl %esi, %ebp
movl %edi, %ebx
leaq 0x11940(%rip), %rdi     # 0x35a93
callq 0x2412c
cmpl $0x3f, %ebx
ja 0x24181
movl 0x23611(%rip), %eax     # 0x47774
testl %eax, %eax
je 0x241c0
movl %ebx, %r14d
cmpl $0x1, %eax
je 0x241d0
cmpl $0x3, %eax
jne 0x2439a
leaq 0x24301(%rip), %rax     # 0x48480
jmp 0x241c7
movq 0x22e30(%rip), %rax     # 0x46fb8
movq (%rax), %rdi
testq %rdi, %rdi
je 0x2419f
cmpl %ebx, (%rdi)
jg 0x24199
cmpl %ebx, 0x4(%rdi)
jge 0x241a1
movq 0x58(%rdi), %rdi
jmp 0x2418b
xorl %edi, %edi
testq %rdi, %rdi
je 0x2439a
movq 0x20(%rdi), %rax
movl %ebx, %esi
movl %ebp, %edx
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmpq *%rax
leaq 0x242b1(%rip), %rax     # 0x48478
movq (%rax), %rax
movl %ebx, %ecx
movl (%rax,%rcx,4), %r14d
movl %ebx, %edi
callq 0x1f4d0
movl %ebx, %edi
callq 0x1f3b0
cmpl $0x6, %ebp
ja 0x2439a
movslq %r14d, %rax
leaq 0x1103f(%rip), %rcx     # 0x35230
movzbl (%rax,%rcx), %r12d
leaq 0x11073(%rip), %rcx     # 0x35270
movzbl (%rax,%rcx), %r15d
movl %ebp, %ecx
leaq 0x10fc5(%rip), %rdx     # 0x351d0
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movq 0x24275(%rip), %rax     # 0x48490
movl $0x7, %edx
movl %r15d, %ecx
shll %cl, %edx
notl %edx
andl %edx, (%rax,%r12,4)
jmp 0x2439a
movl %ebx, %edi
xorl %esi, %esi
movl $0x64, %edx
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x1f110
leaq 0x111df(%rip), %rcx     # 0x35430
movzbl (%rax,%rcx), %ebx
testl %ebx, %ebx
je 0x2439a
leaq 0x11837(%rip), %rdi     # 0x35a9b
callq 0x243a7
movq 0x24220(%rip), %rax     # 0x48490
movl $0x7, %edx
movl %r15d, %ecx
shll %cl, %edx
notl %edx
andl (%rax,%r12,4), %edx
shll %cl, %ebx
orl %edx, %ebx
movl %ebx, (%rax,%r12,4)
movq %rsp, %rdi
movq $0x0, (%rdi)
movq $0x1adb0, 0x8(%rdi)     # imm = 0x1ADB0
xorl %esi, %esi
callq 0x1f160
movl 0x234cd(%rip), %eax     # 0x47774
cmpl $0x3, %eax
ja 0x242be
cmpl $0x2, %eax
je 0x242be
movq 0x241e0(%rip), %rax     # 0x48498
movl $0x101, (%rax)          # imm = 0x101
movl $0x400, %edi            # imm = 0x400
callq 0x1f330
movl $0x20, %edi
callq 0x1f540
jmp 0x2439a
leaq 0x11192(%rip), %rcx     # 0x35470
movzbl (%rax,%rcx), %ebx
testl %ebx, %ebx
je 0x2439a
leaq 0x117b6(%rip), %rdi     # 0x35aa7
callq 0x243a7
movq 0x24193(%rip), %rax     # 0x48490
movl $0x7, %edx
movl %r15d, %ecx
shll %cl, %edx
notl %edx
andl (%rax,%r12,4), %edx
shll %cl, %ebx
orl %edx, %ebx
movl %ebx, (%rax,%r12,4)
movq %rsp, %rdi
movq $0x0, (%rdi)
movq $0x1adb0, 0x8(%rdi)     # imm = 0x1ADB0
xorl %esi, %esi
callq 0x1f160
movl %r14d, %edi
movl $0x186a0, %esi          # imm = 0x186A0
callq 0x1f6f0
jmp 0x2439a
movq 0x2414c(%rip), %rax     # 0x48490
movl $0x7, %edx
movl %r15d, %ecx
shll %cl, %edx
notl %edx
andl (%rax,%r12,4), %edx
btsl %r15d, %edx
movl %edx, (%rax,%r12,4)
jmp 0x2439a
movl %ebx, %edi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x1f3d0
movl %ebx, %edi
movl $0x2, %esi
callq 0x1f310
movl 0x233f1(%rip), %eax     # 0x47774
cmpl $0x3, %eax
ja 0x2439a
cmpl $0x2, %eax
je 0x2439a
movq 0x24104(%rip), %rax     # 0x48498
movl $0x8181, (%rax)         # imm = 0x8181
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq