#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*/ pair_list_push(int, unsigned char, unsigned char);
int parse_hid(char const *);
char *skip_token(char const *);
char *skip_whitespace(char const *);
int cmd_remap(const char *p) {
  int ret = 3;
  int v1, v2;
  if (!p)
    goto ret;
  p = skip_whitespace(p);
  v1 = parse_hid(p);
  if (v1 == -9999)
    goto ret;
  p = skip_token(p);
  v2 = parse_hid(p);
  if (v2 == -9999)
    goto ret;
  pair_list_push(1, (unsigned char)v1, (unsigned char)v2);
  ret = 0;
ret:
  return ret;
}


x86 assembly (clang, -O0):
<cmd_remap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x3,-0xc(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1163 <cmd_remap+0x23>
jmp    11d8 <cmd_remap+0x98>
mov    -0x8(%rbp),%rdi
call   1050 <skip_whitespace@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <parse_hid@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xffffd8f1,-0x10(%rbp)
jne    118e <cmd_remap+0x4e>
jmp    11d8 <cmd_remap+0x98>
mov    -0x8(%rbp),%rdi
call   1060 <skip_token@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <parse_hid@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffd8f1,-0x14(%rbp)
jne    11b9 <cmd_remap+0x79>
jmp    11d8 <cmd_remap+0x98>
mov    -0x10(%rbp),%eax
mov    %al,%cl
mov    -0x14(%rbp),%eax
mov    $0x1,%edi
movzbl %cl,%esi
movzbl %al,%edx
call   1040 <pair_list_push@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_remap>:
push   %rbp
push   %r14
push   %rbx
mov    $0x3,%ebx
test   %rdi,%rdi
je     1192 <cmd_remap+0x52>
call   1050 <skip_whitespace@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1030 <parse_hid@plt>
cmp    $0xffffd8f1,%eax
je     1192 <cmd_remap+0x52>
mov    %eax,%r14d
mov    %rbp,%rdi
call   1060 <skip_token@plt>
mov    %rax,%rdi
call   1030 <parse_hid@plt>
cmp    $0xffffd8f1,%eax
je     1192 <cmd_remap+0x52>
movzbl %r14b,%esi
movzbl %al,%edx
mov    $0x1,%edi
call   1040 <pair_list_push@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @cmd_remap(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
store i32 3, i32* %3
%6 = load i8*, i8** %2
%7 = icmp ne i8* %6, null
br i1 %7, label %9, label %8
8: ; preds = %1
br label %31
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = call i8* @skip_whitespace(i8* %10)
store i8* %11, i8** %2
%12 = load i8*, i8** %2
%13 = call i32 @parse_hid(i8* %12)
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, -9999
br i1 %15, label %16, label %17
16: ; preds = %9
br label %31
17: ; preds = %9
%18 = load i8*, i8** %2
%19 = call i8* @skip_token(i8* %18)
store i8* %19, i8** %2
%20 = load i8*, i8** %2
%21 = call i32 @parse_hid(i8* %20)
store i32 %21, i32* %5
%22 = load i32, i32* %5
%23 = icmp eq i32 %22, -9999
br i1 %23, label %24, label %25
24: ; preds = %17
br label %31
25: ; preds = %17
%26 = load i32, i32* %4
%27 = trunc i32 %26 to i8
%28 = load i32, i32* %5
%29 = trunc i32 %28 to i8
%30 = call i32 @pair_list_push(i32 1, i8 zeroext %27, i8 zeroext %29)
store i32 0, i32* %3
br label %31
31: ; preds = %25, %24, %16, %8
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
define i32 @cmd_remap(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %15, label %3
3: ; preds = %1
%4 = tail call i8* @skip_whitespace(i8* %0)
%5 = tail call i32 @parse_hid(i8* %4)
%6 = icmp eq i32 %5, -9999
br i1 %6, label %15, label %7
7: ; preds = %3
%8 = tail call i8* @skip_token(i8* %4)
%9 = tail call i32 @parse_hid(i8* %8)
%10 = icmp eq i32 %9, -9999
br i1 %10, label %15, label %11
11: ; preds = %7
%12 = trunc i32 %5 to i8
%13 = trunc i32 %9 to i8
%14 = tail call i32 @pair_list_push(i32 1, i8 zeroext %12, i8 zeroext %13)
br label %15
15: ; preds = %7, %3, %1, %11
%16 = phi i32 [ 3, %3 ], [ 3, %7 ], [ 0, %11 ], [ 3, %1 ]
ret i32 %16
}