#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*/ bind_key(char *, char *, int);
int /*<<< orphan*/ io_error_msg(char *, ...);
scalar_t__ isspace(char);
int string_to_char(char **);
int /*<<< orphan*/ unbind_key(char *, int);
void bind_or_unbind_set(char *keymap, char *command, char *keyset) {
  int first;
  int last;
  first = string_to_char(&keyset);
  if (first < 0) {
    io_error_msg("Invalid character set.");
    return;
  }
  while (isspace(*keyset))
    ++keyset;
  if (*keyset == '-') {
    ++keyset;
    last = string_to_char(&keyset);
    if (last < 0) {
      io_error_msg("Unterminated character set.");
      return;
    }
  } else if (*keyset) {
    io_error_msg("Extra characters in keyset: `%s'.", keyset);
    return;
  } else
    last = first;
  while (first <= last) {
    if (command != "0")
      bind_key(keymap, command, first);
    else
      unbind_key(keymap, first);
    ++first;
  }
}


x86 assembly (clang, -O0):
<bind_or_unbind_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
call   1030 <string_to_char@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    118d <bind_or_unbind_set+0x3d>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1070 <io_error_msg@plt>
jmp    1283 <bind_or_unbind_set+0x133>
jmp    1192 <bind_or_unbind_set+0x42>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1060 <isspace@plt>
cmp    $0x0,%rax
je     11b9 <bind_or_unbind_set+0x69>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1192 <bind_or_unbind_set+0x42>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1203 <bind_or_unbind_set+0xb3>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
call   1030 <string_to_char@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    11fe <bind_or_unbind_set+0xae>
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1070 <io_error_msg@plt>
jmp    1283 <bind_or_unbind_set+0x133>
jmp    1232 <bind_or_unbind_set+0xe2>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1227 <bind_or_unbind_set+0xd7>
mov    -0x18(%rbp),%rsi
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1070 <io_error_msg@plt>
jmp    1283 <bind_or_unbind_set+0x133>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1232 <bind_or_unbind_set+0xe2>
jmp    1237 <bind_or_unbind_set+0xe7>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     1283 <bind_or_unbind_set+0x133>
lea    0xe0b(%rip),%rax
cmp    %rax,-0x10(%rbp)
je     1269 <bind_or_unbind_set+0x119>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1050 <bind_key@plt>
jmp    1275 <bind_or_unbind_set+0x125>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <unbind_key@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1237 <bind_or_unbind_set+0xe7>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bind_or_unbind_set>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rdx,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1030 <string_to_char@plt>
test   %eax,%eax
js     1212 <bind_or_unbind_set+0xc2>
mov    %eax,%ebp
mov    0x8(%rsp),%rax
movsbl (%rax),%edi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1060 <isspace@plt>
test   %rax,%rax
je     11ae <bind_or_unbind_set+0x5e>
mov    0x8(%rsp),%rax
lea    0x1(%rax),%rcx
mov    %rcx,0x8(%rsp)
movsbl 0x1(%rax),%edi
jmp    1190 <bind_or_unbind_set+0x40>
mov    0x8(%rsp),%rsi
mov    (%rsi),%al
mov    %ebp,%ebx
test   %al,%al
je     11dc <bind_or_unbind_set+0x8c>
cmp    $0x2d,%al
jne    1222 <bind_or_unbind_set+0xd2>
add    $0x1,%rsi
mov    %rsi,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1030 <string_to_char@plt>
test   %eax,%eax
js     123d <bind_or_unbind_set+0xed>
mov    %eax,%ebx
cmp    %eax,%ebp
jg     1230 <bind_or_unbind_set+0xe0>
add    $0x1,%ebx
lea    0xe6f(%rip),%r12
jmp    11fe <bind_or_unbind_set+0xae>
nopl   0x0(%rax,%rax,1)
mov    %ebp,%esi
call   1040 <unbind_key@plt>
add    $0x1,%ebp
cmp    %ebp,%ebx
je     1230 <bind_or_unbind_set+0xe0>
mov    %r14,%rdi
cmp    %r12,%r15
je     11f0 <bind_or_unbind_set+0xa0>
mov    %r15,%rsi
mov    %ebp,%edx
call   1050 <bind_key@plt>
jmp    11f7 <bind_or_unbind_set+0xa7>
lea    0xde7(%rip),%rdi
xor    %eax,%eax
call   1070 <io_error_msg@plt>
jmp    1230 <bind_or_unbind_set+0xe0>
lea    0xe0a(%rip),%rdi
xor    %eax,%eax
call   1070 <io_error_msg@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdd3(%rip),%rdi
jmp    1219 <bind_or_unbind_set+0xc9>

LLVM IR (-O0):
@.str = [23 x i8] c"Invalid character set.\00"
@.str.1 = [28 x i8] c"Unterminated character set.\00"
@.str.2 = [34 x i8] c"Extra characters in keyset: `%s'.\00"
@.str.3 = [2 x i8] c"0\00"
define void @bind_or_unbind_set(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = call i32 @string_to_char(i8** %6)
store i32 %9, i32* %7
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = call i32 (i8*, ...) @io_error_msg(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %67
14: ; preds = %3
br label %15
15: ; preds = %20, %14
%16 = load i8*, i8** %6
%17 = load i8, i8* %16
%18 = call i64 @isspace(i8 signext %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = load i8*, i8** %6
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %6
br label %15
23: ; preds = %15
%24 = load i8*, i8** %6
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 45
br i1 %27, label %28, label %37
28: ; preds = %23
%29 = load i8*, i8** %6
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %6
%31 = call i32 @string_to_char(i8** %6)
store i32 %31, i32* %8
%32 = load i32, i32* %8
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %28
%35 = call i32 (i8*, ...) @io_error_msg(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %67
36: ; preds = %28
br label %47
37: ; preds = %23
%38 = load i8*, i8** %6
%39 = load i8, i8* %38
%40 = icmp ne i8 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %37
%42 = load i8*, i8** %6
%43 = call i32 (i8*, ...) @io_error_msg(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %42)
br label %67
44: ; preds = %37
%45 = load i32, i32* %7
store i32 %45, i32* %8
br label %46
46: ; preds = %44
br label %47
47: ; preds = %46, %36
br label %48
48: ; preds = %64, %47
%49 = load i32, i32* %7
%50 = load i32, i32* %8
%51 = icmp sle i32 %49, %50
br i1 %51, label %52, label %67
52: ; preds = %48
%53 = load i8*, i8** %5
%54 = icmp ne i8* %53, getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
br i1 %54, label %55, label %60
55: ; preds = %52
%56 = load i8*, i8** %4
%57 = load i8*, i8** %5
%58 = load i32, i32* %7
%59 = call i32 @bind_key(i8* %56, i8* %57, i32 %58)
br label %64
60: ; preds = %52
%61 = load i8*, i8** %4
%62 = load i32, i32* %7
%63 = call i32 @unbind_key(i8* %61, i32 %62)
br label %64
64: ; preds = %60, %55
%65 = load i32, i32* %7
%66 = add nsw i32 %65, 1
store i32 %66, i32* %7
br label %48
67: ; preds = %12, %34, %41, %48
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"Invalid character set.\00"
@.str.1 = [28 x i8] c"Unterminated character set.\00"
@.str.2 = [34 x i8] c"Extra characters in keyset: `%s'.\00"
@.str.3 = [2 x i8] c"0\00"
define void @bind_or_unbind_set(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
store i8* %2, i8** %4
%5 = call i32 @string_to_char(i8** %4)
%6 = icmp slt i32 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %3
%8 = load i8*, i8** %4
%9 = load i8, i8* %8
%10 = call i64 @isspace(i8 signext %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %20, label %14
12: ; preds = %3
%13 = call i32 (i8*, ...) @io_error_msg(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %45
14: ; preds = %7, %14
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 1
store i8* %16, i8** %4
%17 = load i8, i8* %16
%18 = call i64 @isspace(i8 signext %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %14
20: ; preds = %14, %7
%21 = load i8*, i8** %4
%22 = load i8, i8* %21
switch i8 %22, label %29 [
i8 45, label %23
i8 0, label %33
]
23: ; preds = %20
%24 = getelementptr inbounds i8, i8* %21, i64 1
store i8* %24, i8** %4
%25 = call i32 @string_to_char(i8** %4)
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %23
%28 = call i32 (i8*, ...) @io_error_msg(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %45
29: ; preds = %20
%30 = call i32 (i8*, ...) @io_error_msg(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %21)
br label %45
31: ; preds = %23
%32 = icmp sgt i32 %5, %25
br i1 %32, label %45, label %33
33: ; preds = %20, %31
%34 = phi i32 [ %25, %31 ], [ %5, %20 ]
%35 = icmp eq i8* %1, getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
br label %36
36: ; preds = %33, %42
%37 = phi i32 [ %5, %33 ], [ %43, %42 ]
br i1 %35, label %40, label %38
38: ; preds = %36
%39 = call i32 @bind_key(i8* %0, i8* %1, i32 %37)
br label %42
40: ; preds = %36
%41 = call i32 @unbind_key(i8* %0, i32 %37)
br label %42
42: ; preds = %40, %38
%43 = add i32 %37, 1
%44 = icmp eq i32 %37, %34
br i1 %44, label %45, label %36
45: ; preds = %42, %31, %29, %27, %12
ret void
}