// File: /workspace/github_cpp_makefile_star2_O2/mrlordkaj[P]i2cdevlib-pi/Arduino/wiringPi/wiringPi.c
// Function: piGpioLayout
int piGpioLayout (void)
{
  FILE *cpuFd ;
  char line [120] ;
  char *c ;
  static int  gpioLayout = -1 ;

  if (gpioLayout != -1)	// No point checking twice
    return gpioLayout ;

  if ((cpuFd = fopen ("/proc/cpuinfo", "r")) == NULL)
    piGpioLayoutOops ("Unable to open /proc/cpuinfo") ;

// Start by looking for the Architecture to make sure we're really running
//	on a Pi. I'm getting fed-up with people whinging at me because
//	they can't get it to work on weirdFruitPi boards...

  while (fgets (line, 120, cpuFd) != NULL)
    if (strncmp (line, "Hardware", 8) == 0)
      break ;

  if (strncmp (line, "Hardware", 8) != 0)
    piGpioLayoutOops ("No \"Hardware\" line") ;

  if (wiringPiDebug)
    printf ("piGpioLayout: Hardware: %s\n", line) ;

// See if it's BCM2708 or BCM2709 or the new BCM2835.

// OK. As of Kernel 4.8,  we have BCM2835 only, regardless of model.
//	However I still want to check because it will trap the cheapskates and rip-
//	off merchants who want to use wiringPi on non-Raspberry Pi platforms - which
//	I do not support so don't email me your bleating whinges about anything
//	other than a genuine Raspberry Pi.

#ifdef	DONT_CARE_ANYMORE
  if (! (strstr (line, "BCM2708") || strstr (line, "BCM2709") || strstr (line, "BCM2835")))
  {
    fprintf (stderr, "Unable to determine hardware version. I see: %s,\n", line) ;
    fprintf (stderr, " - expecting BCM2708, BCM2709 or BCM2835.\n") ;
    fprintf (stderr, "If this is a genuine Raspberry Pi then please report this\n") ;
    fprintf (stderr, "at GitHub.com/wiringPi/wiringPi. If this is not a Raspberry Pi then you\n") ;
    fprintf (stderr, "are on your own as wiringPi is designed to support the\n") ;
    fprintf (stderr, "Raspberry Pi ONLY.\n") ;
    exit (EXIT_FAILURE) ;
  }
#endif

// Actually... That has caused me more than 10,000 emails so-far. Mosty by
//	people who think they know better by creating a statically linked
//	version that will not run with a new 4.9 kernel. I utterly hate and
//	despise those people.
//
//	I also get bleats from people running other than Raspbian with another
//	distros compiled kernel rather than a foundation compiled kernel, so
//	this might actually help them. It might not - I only have the capacity
//	to support Raspbian.
//
//	However, I've decided to leave this check out and rely purely on the
//	Revision: line for now. It will not work on a non-pi hardware or weird
//	kernels that don't give you a suitable revision line.

// So - we're Probably on a Raspberry Pi. Check the revision field for the real
//	hardware type
//	In-future, I ought to use the device tree as there are now Pi entries in
//	/proc/device-tree/ ...
//	but I'll leave that for the next revision. Or the next.

// Isolate the Revision line

  rewind (cpuFd) ;
  while (fgets (line, 120, cpuFd) != NULL)
    if (strncmp (line, "Revision", 8) == 0)
      break ;

  fclose (cpuFd) ;

  if (strncmp (line, "Revision", 8) != 0)
    piGpioLayoutOops ("No \"Revision\" line") ;

// Chomp trailing CR/NL

  for (c = &line [strlen (line) - 1] ; (*c == '\n') || (*c == '\r') ; --c)
    *c = 0 ;

  if (wiringPiDebug)
    printf ("piGpioLayout: Revision string: %s\n", line) ;

// Scan to the first character of the revision number

  for (c = line ; *c ; ++c)
    if (*c == ':')
      break ;

  if (*c != ':')
    piGpioLayoutOops ("Bogus \"Revision\" line (no colon)") ;

// Chomp spaces

  ++c ;
  while (isspace (*c))
    ++c ;

  if (!isxdigit (*c))
    piGpioLayoutOops ("Bogus \"Revision\" line (no hex digit at start of revision)") ;

// Make sure its long enough

  if (strlen (c) < 4)
    piGpioLayoutOops ("Bogus revision line (too small)") ;

// Isolate  last 4 characters: (in-case of overvolting or new encoding scheme)

  c = c + strlen (c) - 4 ;

  if (wiringPiDebug)
    printf ("piGpioLayout: last4Chars are: \"%s\"\n", c) ;

  if ( (strcmp (c, "0002") == 0) || (strcmp (c, "0003") == 0))
    gpioLayout = 1 ;
  else
    gpioLayout = 2 ;	// Covers everything else from the B revision 2 to the B+, the Pi v2, v3, zero and CM's.

  if (wiringPiDebug)
    printf ("piGpioLayoutOops: Returning revision: %d\n", gpioLayout) ;

  return gpioLayout ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x80, %rsp
movl 0x2683e(%rip), %eax     # 0x49a30
cmpl $-0x1, %eax
jne 0x233a3
leaq 0x104b9(%rip), %rdi     # 0x336bb
leaq 0x104a1(%rip), %rsi     # 0x336aa
callq 0x1f990
testq %rax, %rax
je 0x233bf
movq %rax, %r14
movq %rsp, %rbx
pushq $0x78
popq %rbp
movabsq $0x6572617764726148, %r15 # imm = 0x6572617764726148
movq %rbx, %rdi
movl %ebp, %esi
movq %r14, %rdx
callq 0x1fd60
movq (%rsp), %rcx
testq %rax, %rax
je 0x23245
cmpq %r15, %rcx
jne 0x2322a
cmpq %r15, %rcx
jne 0x233cb
movq 0x25d0b(%rip), %r15     # 0x48f60
cmpl $0x0, (%r15)
je 0x2326c
leaq 0x1047a(%rip), %rdi     # 0x336dc
movq %rsp, %rsi
xorl %eax, %eax
callq 0x1f050
movabsq $0x6e6f697369766552, %r12 # imm = 0x6E6F697369766552
movq %r14, %rdi
callq 0x1f090
movq %rsp, %rbx
pushq $0x78
popq %rbp
movq %rbx, %rdi
movl %ebp, %esi
movq %r14, %rdx
callq 0x1fd60
testq %rax, %rax
je 0x2329c
cmpq %r12, (%rsp)
jne 0x23284
movq %r14, %rdi
callq 0x1f7d0
cmpq %r12, (%rsp)
jne 0x233d7
movq %rbx, %rdi
callq 0x1f2c0
addq %rbx, %rax
decq %rax
movzbl (%rax), %ecx
cmpl $0xd, %ecx
je 0x232c9
cmpl $0xa, %ecx
jne 0x232d1
movb $0x0, (%rax)
decq %rax
jmp 0x232bc
cmpl $0x0, (%r15)
je 0x232f5
leaq 0x1042d(%rip), %rdi     # 0x3370b
movq %rsp, %rsi
xorl %eax, %eax
callq 0x1f050
jmp 0x232f5
testl %eax, %eax
je 0x233b3
incq %rbx
movzbl (%rbx), %eax
cmpl $0x3a, %eax
jne 0x232ea
callq 0x1f8c0
movq (%rax), %rax
movsbq 0x1(%rbx), %rcx
incq %rbx
movzwl (%rax,%rcx,2), %ecx
btl $0xd, %ecx
jb 0x23305
btl $0xc, %ecx
jae 0x233e3
movq %rbx, %rdi
callq 0x1f2c0
cmpq $0x3, %rax
jbe 0x233ef
addq %rax, %rbx
addq $-0x4, %rbx
cmpl $0x0, (%r15)
je 0x23351
leaq 0x10462(%rip), %rdi     # 0x337a9
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1f050
leaq 0x10475(%rip), %rsi     # 0x337cd
movq %rbx, %rdi
callq 0x1fb80
testl %eax, %eax
je 0x2337e
leaq 0x10467(%rip), %rsi     # 0x337d2
movq %rbx, %rdi
callq 0x1fb80
cmpl $0x1, %eax
pushq $0x2
popq %rax
sbbl $0x0, %eax
jmp 0x23381
pushq $0x1
popq %rax
movl %eax, 0x266a9(%rip)     # 0x49a30
cmpl $0x0, (%r15)
je 0x233a3
leaq 0x10443(%rip), %rdi     # 0x337d7
movl %eax, %esi
xorl %eax, %eax
callq 0x1f050
movl 0x2668d(%rip), %eax     # 0x49a30
addq $0x80, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10374(%rip), %rdi     # 0x3372e
callq 0x233fb
leaq 0x102e6(%rip), %rdi     # 0x336ac
callq 0x233fb
leaq 0x102f7(%rip), %rdi     # 0x336c9
callq 0x233fb
leaq 0x1031a(%rip), %rdi     # 0x336f8
callq 0x233fb
leaq 0x10365(%rip), %rdi     # 0x3374f
callq 0x233fb
leaq 0x10393(%rip), %rdi     # 0x33789
callq 0x233fb