#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*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ isdigit(char const);
char *parse_mapspec(char const *, int);
int /*<<< orphan*/ stderr;
void js_set_nesmaps(const char *s) {
  while (*s) {
    if (isdigit(*s) && *(s + 1) == ':') {
      int stick = *s - '1';
      s += 2;
      if (stick < 0 || stick > 2) {
        fprintf(stderr,
                "ignoring joystick map (limited to joystick 1 and 2)\n");
        continue;
      }
      s = parse_mapspec(s, stick);
    } else {
      ++s;
    }
  }
}


x86 assembly (clang, -O0):
<js_set_nesmaps>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11dd <js_set_nesmaps+0xad>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11cc <js_set_nesmaps+0x9c>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x3a,%eax
jne    11cc <js_set_nesmaps+0x9c>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
sub    $0x31,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     119d <js_set_nesmaps+0x6d>
cmpl   $0x2,-0xc(%rbp)
jle    11b7 <js_set_nesmaps+0x87>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe53(%rip),%rsi
call   1040 <fprintf@plt>
jmp    113c <js_set_nesmaps+0xc>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <parse_mapspec@plt>
mov    %rax,-0x8(%rbp)
jmp    11d8 <js_set_nesmaps+0xa8>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    113c <js_set_nesmaps+0xc>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<js_set_nesmaps>:
push   %r15
push   %r14
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     1199 <js_set_nesmaps+0x69>
mov    %rdi,%rbx
mov    0x2e9b(%rip),%r15
lea    0xeb4(%rip),%r14
jmp    115b <js_set_nesmaps+0x2b>
xchg   %ax,%ax
add    $0x1,%rbx
movzbl (%rbx),%eax
test   %al,%al
je     1199 <js_set_nesmaps+0x69>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1150 <js_set_nesmaps+0x20>
cmpb   $0x3a,0x1(%rbx)
jne    1150 <js_set_nesmaps+0x20>
movzbl (%rbx),%esi
add    $0x2,%rbx
lea    -0x34(%rsi),%eax
cmp    $0xfd,%al
jae    1189 <js_set_nesmaps+0x59>
mov    (%r15),%edi
mov    %r14,%rsi
call   1040 <fprintf@plt>
jmp    1154 <js_set_nesmaps+0x24>
add    $0xffffffcf,%esi
mov    %rbx,%rdi
call   1050 <parse_mapspec@plt>
mov    %rax,%rbx
jmp    1154 <js_set_nesmaps+0x24>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [53 x i8] c"ignoring joystick map (limited to joystick 1 and 2)\0A\00"
define void @js_set_nesmaps(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
br label %4
4: ; preds = %41, %31, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 0
br i1 %7, label %8, label %42
8: ; preds = %4
%9 = load i8*, i8** %2
%10 = load i8, i8* %9
%11 = call i64 @isdigit(i8 signext %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %38
13: ; preds = %8
%14 = load i8*, i8** %2
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 58
br i1 %18, label %19, label %38
19: ; preds = %13
%20 = load i8*, i8** %2
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = sub nsw i32 %22, 49
store i32 %23, i32* %3
%24 = load i8*, i8** %2
%25 = getelementptr inbounds i8, i8* %24, i64 2
store i8* %25, i8** %2
%26 = load i32, i32* %3
%27 = icmp slt i32 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %19
%29 = load i32, i32* %3
%30 = icmp sgt i32 %29, 2
br i1 %30, label %31, label %34
31: ; preds = %28, %19
%32 = load i32, i32* @stderr
%33 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
br label %4
34: ; preds = %28
%35 = load i8*, i8** %2
%36 = load i32, i32* %3
%37 = call i8* @parse_mapspec(i8* %35, i32 %36)
store i8* %37, i8** %2
br label %41
38: ; preds = %13, %8
%39 = load i8*, i8** %2
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %2
br label %41
41: ; preds = %38, %34
br label %4
42: ; preds = %4
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [53 x i8] c"ignoring joystick map (limited to joystick 1 and 2)\0A\00"
define void @js_set_nesmaps(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %31, label %4
4: ; preds = %1, %27
%5 = phi i8 [ %29, %27 ], [ %2, %1 ]
%6 = phi i8* [ %28, %27 ], [ %0, %1 ]
%7 = tail call i64 @isdigit(i8 signext %5)
%8 = icmp eq i64 %7, 0
br i1 %8, label %25, label %9
9: ; preds = %4
%10 = getelementptr inbounds i8, i8* %6, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 58
br i1 %12, label %13, label %25
13: ; preds = %9
%14 = load i8, i8* %6
%15 = getelementptr inbounds i8, i8* %6, i64 2
%16 = add i8 %14, -52
%17 = icmp ult i8 %16, -3
br i1 %17, label %22, label %18
18: ; preds = %13
%19 = zext i8 %14 to i32
%20 = add nsw i32 %19, -49
%21 = tail call i8* @parse_mapspec(i8* %15, i32 %20)
br label %27
22: ; preds = %13
%23 = load i32, i32* @stderr
%24 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
br label %27
25: ; preds = %9, %4
%26 = getelementptr inbounds i8, i8* %6, i64 1
br label %27
27: ; preds = %25, %18, %22
%28 = phi i8* [ %15, %22 ], [ %26, %25 ], [ %21, %18 ]
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
br i1 %30, label %31, label %4
31: ; preds = %27, %1
ret void
}