#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 */
typedef int uint8_t;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
const char *parse(const char *s, uint8_t *port, uint8_t *mode, int bits) {
  int pos;
  *port = *mode = 0;
  pos = 0;
  while (pos != bits) {
    switch (*s++) {
    case '.':
      continue;
    case '1':
      *port |= 1 << pos;
    case '0':
      *mode |= 1 << pos;
      break;
    case 'r':
    case 'R':
      *port |= 1 << pos;
      break;
    case 0:
      fprintf(stderr, "not enough pin settings\n");
      exit(1);
    default:
      fprintf(stderr, "unrecognized pin setting \"%c\"\n", s[-1]);
      exit(1);
    }
    pos++;
  }
  return s;
}


x86 assembly (clang, -O0):
<parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     1278 <parse+0x158>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%eax
mov    %eax,-0x24(%rbp)
test   %eax,%eax
je     1220 <parse+0x100>
jmp    1180 <parse+0x60>
mov    -0x24(%rbp),%eax
sub    $0x2e,%eax
je     11d5 <parse+0xb5>
jmp    1191 <parse+0x71>
mov    -0x24(%rbp),%eax
sub    $0x30,%eax
je     11ee <parse+0xce>
jmp    11a2 <parse+0x82>
mov    -0x24(%rbp),%eax
sub    $0x31,%eax
je     11da <parse+0xba>
jmp    11b3 <parse+0x93>
mov    -0x24(%rbp),%eax
sub    $0x52,%eax
je     1207 <parse+0xe7>
jmp    11c4 <parse+0xa4>
mov    -0x24(%rbp),%eax
sub    $0x72,%eax
je     1207 <parse+0xe7>
jmp    1241 <parse+0x121>
jmp    1152 <parse+0x32>
mov    -0x20(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x20(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
jmp    126a <parse+0x14a>
mov    -0x20(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
jmp    126a <parse+0x14a>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
lea    0xdd0(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    0x2d98(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
movsbl -0x1(%rax),%edx
lea    0xdc0(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1152 <parse+0x32>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse>:
push   %rax
mov    %ecx,%r8d
movl   $0x0,(%rdx)
movl   $0x0,(%rsi)
xor    %ecx,%ecx
jmp    1150 <parse+0x30>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x1,%eax
shl    %cl,%eax
mov    %rsi,%r9
or     %eax,(%r9)
add    $0x1,%ecx
mov    %rdi,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    %r8d,%ecx
je     11aa <parse+0x8a>
movsbl (%rdi),%r9d
add    $0x1,%rdi
cmp    $0x2e,%r9d
je     1160 <parse+0x40>
cmp    $0x51,%r9d
jg     1190 <parse+0x70>
cmp    $0x30,%r9d
je     119e <parse+0x7e>
cmp    $0x31,%r9d
jne    11ac <parse+0x8c>
mov    $0x1,%eax
shl    %cl,%eax
or     %eax,(%rsi)
jmp    11a5 <parse+0x85>
cmp    $0x52,%r9d
je     1140 <parse+0x20>
cmp    $0x72,%r9d
je     1140 <parse+0x20>
jmp    11d2 <parse+0xb2>
mov    $0x1,%eax
shl    %cl,%eax
mov    %rdx,%r9
jmp    114a <parse+0x2a>
pop    %rcx
ret
test   %r9d,%r9d
jne    11d2 <parse+0xb2>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
lea    0xe3f(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
lea    0xe37(%rip),%rsi
mov    %r9d,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"not enough pin settings\0A\00"
@.str.1 = [31 x i8] c"unrecognized pin setting \22%c\22\0A\00"
define i8* @parse(i8* %0, i32* %1, i32* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32 %3, i32* %8
%10 = load i32*, i32** %7
store i32 0, i32* %10
%11 = load i32*, i32** %6
store i32 0, i32* %11
store i32 0, i32* %9
br label %12
12: ; preds = %52, %21, %4
%13 = load i32, i32* %9
%14 = load i32, i32* %8
%15 = icmp ne i32 %13, %14
br i1 %15, label %16, label %55
16: ; preds = %12
%17 = load i8*, i8** %5
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %5
%19 = load i8, i8* %17
%20 = sext i8 %19 to i32
switch i32 %20, label %44 [
i32 46, label %21
i32 49, label %22
i32 48, label %28
i32 114, label %34
i32 82, label %34
i32 0, label %40
]
21: ; preds = %16
br label %12
22: ; preds = %16
%23 = load i32, i32* %9
%24 = shl i32 1, %23
%25 = load i32*, i32** %6
%26 = load i32, i32* %25
%27 = or i32 %26, %24
store i32 %27, i32* %25
br label %28
28: ; preds = %16, %22
%29 = load i32, i32* %9
%30 = shl i32 1, %29
%31 = load i32*, i32** %7
%32 = load i32, i32* %31
%33 = or i32 %32, %30
store i32 %33, i32* %31
br label %52
34: ; preds = %16, %16
%35 = load i32, i32* %9
%36 = shl i32 1, %35
%37 = load i32*, i32** %6
%38 = load i32, i32* %37
%39 = or i32 %38, %36
store i32 %39, i32* %37
br label %52
40: ; preds = %16
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %16
%45 = load i32, i32* @stderr
%46 = load i8*, i8** %5
%47 = getelementptr inbounds i8, i8* %46, i64 -1
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %49)
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %34, %28
%53 = load i32, i32* %9
%54 = add nsw i32 %53, 1
store i32 %54, i32* %9
br label %12
55: ; preds = %12
%56 = load i8*, i8** %5
ret i8* %56
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"not enough pin settings\0A\00"
@.str.1 = [31 x i8] c"unrecognized pin setting \22%c\22\0A\00"
define i8* @parse(i8* %0, i32* nocapture %1, i32* nocapture %2, i32 %3) {
store i32 0, i32* %2
store i32 0, i32* %1
br label %5
5: ; preds = %32, %4
%6 = phi i8* [ %12, %32 ], [ %0, %4 ]
%7 = phi i32 [ %37, %32 ], [ 0, %4 ]
%8 = icmp eq i32 %7, %3
br label %9
9: ; preds = %5, %11
%10 = phi i8* [ %12, %11 ], [ %6, %5 ]
br i1 %8, label %38, label %11
11: ; preds = %9
%12 = getelementptr inbounds i8, i8* %10, i64 1
%13 = load i8, i8* %10
%14 = sext i8 %13 to i32
switch i32 %14, label %27 [
i32 46, label %9
i32 49, label %15
i32 48, label %19
i32 114, label %21
i32 82, label %21
i32 0, label %23
]
15: ; preds = %11
%16 = shl nuw i32 1, %7
%17 = load i32, i32* %1
%18 = or i32 %17, %16
store i32 %18, i32* %1
br label %32
19: ; preds = %11
%20 = shl nuw i32 1, %7
br label %32
21: ; preds = %11, %11
%22 = shl nuw i32 1, %7
br label %32
23: ; preds = %11
%24 = load i32, i32* @stderr
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%26 = tail call i32 @exit(i32 1)
unreachable
27: ; preds = %11
%28 = sext i8 %13 to i32
%29 = load i32, i32* @stderr
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%31 = tail call i32 @exit(i32 1)
unreachable
32: ; preds = %15, %19, %21
%33 = phi i32* [ %1, %21 ], [ %2, %19 ], [ %2, %15 ]
%34 = phi i32 [ %22, %21 ], [ %20, %19 ], [ %16, %15 ]
%35 = load i32, i32* %33
%36 = or i32 %35, %34
store i32 %36, i32* %33
%37 = add nuw nsw i32 %7, 1
br label %5
38: ; preds = %9
ret i8* %6
}