#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *);
int rpi_version();
int /*<<< orphan*/ stderr;
int rpi_gpio_header_type() {
  switch (rpi_version()) {
  case 0x000002:
  case 0x000003:
  case 0x000004:
  case 0x000005:
  case 0x000006:
  case 0x000007:
  case 0x000008:
  case 0x000009:
  case 0x00000d:
  case 0x00000e:
  case 0x00000f:
    printf("26-pin GPIO header detected\n");
    return 0x00;
  case 0x000011:
  case 0x000014:
  case 0xa020a0:
    fprintf(stderr, "compute module not supported\n");
    exit(EXIT_FAILURE);
  case 0x000010:
  case 0x000012:
  case 0x000013:
  case 0x000015:
  case 0x900021:
  case 0x900032:
  case 0x900092:
  case 0x900093:
  case 0x9000c1:
  case 0x920093:
  case 0xa01040:
  case 0xa01041:
  case 0xa02082:
  case 0xa21041:
  case 0xa22042:
  case 0xa22082:
  case 0xa32082:
    printf("40-pin GPIO header detected\n");
    return 0x01;
  default:
    printf("assuming 40-pin GPIO header\n");
    return 0x01;
  }
}


x86 assembly (clang, -O0):
<rpi_gpio_header_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %eax,%eax
call   1050 <rpi_version@plt>
mov    %eax,%ecx
mov    %ecx,%eax
add    $0xfffffffe,%eax
mov    %ecx,-0x8(%rbp)
sub    $0x8,%eax
jb     12bd <rpi_gpio_header_type+0x17d>
jmp    1167 <rpi_gpio_header_type+0x27>
mov    -0x8(%rbp),%eax
add    $0xfffffff3,%eax
sub    $0x3,%eax
jb     12bd <rpi_gpio_header_type+0x17d>
jmp    117b <rpi_gpio_header_type+0x3b>
mov    -0x8(%rbp),%eax
sub    $0x10,%eax
je     12f8 <rpi_gpio_header_type+0x1b8>
jmp    118c <rpi_gpio_header_type+0x4c>
mov    -0x8(%rbp),%eax
sub    $0x11,%eax
je     12d5 <rpi_gpio_header_type+0x195>
jmp    119d <rpi_gpio_header_type+0x5d>
mov    -0x8(%rbp),%eax
add    $0xffffffee,%eax
sub    $0x2,%eax
jb     12f8 <rpi_gpio_header_type+0x1b8>
jmp    11b1 <rpi_gpio_header_type+0x71>
mov    -0x8(%rbp),%eax
sub    $0x14,%eax
je     12d5 <rpi_gpio_header_type+0x195>
jmp    11c2 <rpi_gpio_header_type+0x82>
mov    -0x8(%rbp),%eax
sub    $0x15,%eax
je     12f8 <rpi_gpio_header_type+0x1b8>
jmp    11d3 <rpi_gpio_header_type+0x93>
mov    -0x8(%rbp),%eax
sub    $0x900021,%eax
je     12f8 <rpi_gpio_header_type+0x1b8>
jmp    11e6 <rpi_gpio_header_type+0xa6>
mov    -0x8(%rbp),%eax
sub    $0x900032,%eax
je     12f8 <rpi_gpio_header_type+0x1b8>
jmp    11f9 <rpi_gpio_header_type+0xb9>
mov    -0x8(%rbp),%eax
add    $0xff6fff6e,%eax
sub    $0x2,%eax
jb     12f8 <rpi_gpio_header_type+0x1b8>
jmp    120f <rpi_gpio_header_type+0xcf>
mov    -0x8(%rbp),%eax
sub    $0x9000c1,%eax
je     12f8 <rpi_gpio_header_type+0x1b8>
jmp    1222 <rpi_gpio_header_type+0xe2>
mov    -0x8(%rbp),%eax
sub    $0x920093,%eax
je     12f8 <rpi_gpio_header_type+0x1b8>
jmp    1235 <rpi_gpio_header_type+0xf5>
mov    -0x8(%rbp),%eax
add    $0xff5fefc0,%eax
sub    $0x2,%eax
jb     12f8 <rpi_gpio_header_type+0x1b8>
jmp    124b <rpi_gpio_header_type+0x10b>
mov    -0x8(%rbp),%eax
sub    $0xa02082,%eax
je     12f8 <rpi_gpio_header_type+0x1b8>
jmp    125e <rpi_gpio_header_type+0x11e>
mov    -0x8(%rbp),%eax
sub    $0xa020a0,%eax
je     12d5 <rpi_gpio_header_type+0x195>
jmp    1271 <rpi_gpio_header_type+0x131>
mov    -0x8(%rbp),%eax
sub    $0xa21041,%eax
je     12f8 <rpi_gpio_header_type+0x1b8>
jmp    1284 <rpi_gpio_header_type+0x144>
mov    -0x8(%rbp),%eax
sub    $0xa22042,%eax
je     12f8 <rpi_gpio_header_type+0x1b8>
jmp    1297 <rpi_gpio_header_type+0x157>
mov    -0x8(%rbp),%eax
sub    $0xa22082,%eax
je     12f8 <rpi_gpio_header_type+0x1b8>
jmp    12aa <rpi_gpio_header_type+0x16a>
mov    -0x8(%rbp),%eax
sub    $0xa32082,%eax
je     12f8 <rpi_gpio_header_type+0x1b8>
jmp    1310 <rpi_gpio_header_type+0x1d0>
lea    0xd3c(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1323 <rpi_gpio_header_type+0x1e3>
mov    0x2d04(%rip),%rax
mov    (%rax),%edi
lea    0xd38(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2ce7(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
lea    0xd3c(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1323 <rpi_gpio_header_type+0x1e3>
lea    0xd41(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rpi_gpio_header_type>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <rpi_version@plt>
cmp    $0x900091,%eax
jg     116c <rpi_gpio_header_type+0x2c>
cmp    $0x15,%eax
ja     11c4 <rpi_gpio_header_type+0x84>
mov    $0xe3fc,%ecx
bt     %eax,%ecx
jae    11b0 <rpi_gpio_header_type+0x70>
lea    0xed3(%rip),%rdi
jmp    1200 <rpi_gpio_header_type+0xc0>
cmp    $0xa02081,%eax
jg     1192 <rpi_gpio_header_type+0x52>
lea    -0x900092(%rax),%ecx
cmp    $0x2f,%ecx
jbe    11d4 <rpi_gpio_header_type+0x94>
lea    -0xa01040(%rax),%ecx
cmp    $0x2,%ecx
jb     11f4 <rpi_gpio_header_type+0xb4>
cmp    $0x920093,%eax
je     11f4 <rpi_gpio_header_type+0xb4>
jmp    1210 <rpi_gpio_header_type+0xd0>
cmp    $0xa22041,%eax
jle    11e6 <rpi_gpio_header_type+0xa6>
cmp    $0xa22042,%eax
je     11f4 <rpi_gpio_header_type+0xb4>
cmp    $0xa22082,%eax
je     11f4 <rpi_gpio_header_type+0xb4>
cmp    $0xa32082,%eax
je     11f4 <rpi_gpio_header_type+0xb4>
jmp    1210 <rpi_gpio_header_type+0xd0>
mov    $0x2d0000,%ecx
bt     %eax,%ecx
jb     11f4 <rpi_gpio_header_type+0xb4>
mov    $0x120000,%ecx
bt     %eax,%ecx
jb     121e <rpi_gpio_header_type+0xde>
cmp    $0x900021,%eax
je     11f4 <rpi_gpio_header_type+0xb4>
cmp    $0x900032,%eax
je     11f4 <rpi_gpio_header_type+0xb4>
jmp    1210 <rpi_gpio_header_type+0xd0>
movabs $0x800000000003,%rdx
bt     %rcx,%rdx
jb     11f4 <rpi_gpio_header_type+0xb4>
jmp    117e <rpi_gpio_header_type+0x3e>
cmp    $0xa02082,%eax
je     11f4 <rpi_gpio_header_type+0xb4>
cmp    $0xa21041,%eax
jne    1209 <rpi_gpio_header_type+0xc9>
mov    $0x1,%ebx
lea    0xe1e(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
ret
cmp    $0xa020a0,%eax
je     121e <rpi_gpio_header_type+0xde>
mov    $0x1,%ebx
lea    0xe3a(%rip),%rdi
jmp    1200 <rpi_gpio_header_type+0xc0>
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
lea    0xdd2(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"26-pin GPIO header detected\0A\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"compute module not supported\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [29 x i8] c"40-pin GPIO header detected\0A\00"
@.str.3 = [29 x i8] c"assuming 40-pin GPIO header\0A\00"
define i32 @rpi_gpio_header_type() {
%1 = alloca i32
%2 = call i32 (...) @rpi_version()
switch i32 %2, label %12 [
i32 2, label %3
i32 3, label %3
i32 4, label %3
i32 5, label %3
i32 6, label %3
i32 7, label %3
i32 8, label %3
i32 9, label %3
i32 13, label %3
i32 14, label %3
i32 15, label %3
i32 17, label %5
i32 20, label %5
i32 10494112, label %5
i32 16, label %10
i32 18, label %10
i32 19, label %10
i32 21, label %10
i32 9437217, label %10
i32 9437234, label %10
i32 9437330, label %10
i32 9437331, label %10
i32 9437377, label %10
i32 9568403, label %10
i32 10489920, label %10
i32 10489921, label %10
i32 10494082, label %10
i32 10620993, label %10
i32 10625090, label %10
i32 10625154, label %10
i32 10690690, label %10
]
3: ; preds = %0, %0, %0, %0, %0, %0, %0, %0, %0, %0, %0
%4 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %14
5: ; preds = %0, %0, %0
%6 = load i32, i32* @stderr
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
%9 = call i32 @exit(i32 %8)
unreachable
10: ; preds = %0, %0, %0, %0, %0, %0, %0, %0, %0, %0, %0, %0, %0, %0, %0, %0, %0
%11 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %14
12: ; preds = %0
%13 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %1
br label %14
14: ; preds = %12, %10, %3
%15 = load i32, i32* %1
ret i32 %15
}

LLVM IR (-O2):
@stderr = global i32 0
@.str.1 = [30 x i8] c"compute module not supported\0A\00"
@EXIT_FAILURE = global i32 0
@str = [28 x i8] c"40-pin GPIO header detected\00"
@str.4 = [28 x i8] c"26-pin GPIO header detected\00"
@str.5 = [28 x i8] c"assuming 40-pin GPIO header\00"
define i32 @rpi_gpio_header_type() {
%1 = tail call i32 (...) @rpi_version()
switch i32 %1, label %8 [
i32 2, label %9
i32 3, label %9
i32 4, label %9
i32 5, label %9
i32 6, label %9
i32 7, label %9
i32 8, label %9
i32 9, label %9
i32 13, label %9
i32 14, label %9
i32 15, label %9
i32 17, label %2
i32 20, label %2
i32 10494112, label %2
i32 16, label %7
i32 18, label %7
i32 19, label %7
i32 21, label %7
i32 9437217, label %7
i32 9437234, label %7
i32 9437330, label %7
i32 9437331, label %7
i32 9437377, label %7
i32 9568403, label %7
i32 10489920, label %7
i32 10489921, label %7
i32 10494082, label %7
i32 10620993, label %7
i32 10625090, label %7
i32 10625154, label %7
i32 10690690, label %7
]
2: ; preds = %0, %0, %0
%3 = load i32, i32* @stderr
%4 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%5 = load i32, i32* @EXIT_FAILURE
%6 = tail call i32 @exit(i32 %5)
unreachable
7: ; preds = %0, %0, %0, %0, %0, %0, %0, %0, %0, %0, %0, %0, %0, %0, %0, %0, %0
br label %9
8: ; preds = %0
br label %9
9: ; preds = %0, %0, %0, %0, %0, %0, %0, %0, %0, %0, %0, %8, %7
%10 = phi i8* [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.5, i64 0, i64 0), %8 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0), %7 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.4, i64 0, i64 0), %0 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.4, i64 0, i64 0), %0 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.4, i64 0, i64 0), %0 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.4, i64 0, i64 0), %0 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.4, i64 0, i64 0), %0 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.4, i64 0, i64 0), %0 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.4, i64 0, i64 0), %0 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.4, i64 0, i64 0), %0 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.4, i64 0, i64 0), %0 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.4, i64 0, i64 0), %0 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.4, i64 0, i64 0), %0 ]
%11 = phi i32 [ 1, %8 ], [ 1, %7 ], [ 0, %0 ], [ 0, %0 ], [ 0, %0 ], [ 0, %0 ], [ 0, %0 ], [ 0, %0 ], [ 0, %0 ], [ 0, %0 ], [ 0, %0 ], [ 0, %0 ], [ 0, %0 ]
%12 = tail call i32 @puts(i8* dereferenceable(1) %10)
ret i32 %11
}