#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 */
struct command_arg {
  int dummy;
};

/* Variables and functions */
int map_idn(char *, int);
char *symbol_verify(char **, struct command_arg *);
char *keymap_verify(char **end, struct command_arg *arg) {
  char *start = *end;
  char *error = symbol_verify(end, arg);
  int id;
  if (error)
    return error;
  id = map_idn(start, *end - start);
  return (id >= 0 ? (char *)0 : "No such keymap.");
}


x86 assembly (clang, -O0):
<keymap_verify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <symbol_verify@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1164 <keymap_verify+0x44>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1197 <keymap_verify+0x77>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
call   1040 <map_idn@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edx
lea    0xe76(%rip),%rax
xor    %ecx,%ecx
cmp    $0x0,%edx
cmovge %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<keymap_verify>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%r14
call   1030 <symbol_verify@plt>
test   %rax,%rax
jne    1152 <keymap_verify+0x32>
mov    (%rbx),%esi
sub    %r14d,%esi
mov    %r14,%rdi
call   1040 <map_idn@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
lea    0xeb2(%rip),%rcx
cmovs  %rcx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.command_arg = type { i32 }
@.str = [16 x i8] c"No such keymap.\00"
define i8* @keymap_verify(i8** %0, %struct.command_arg* %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca %struct.command_arg*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i8** %0, i8*** %4
store %struct.command_arg* %1, %struct.command_arg** %5
%9 = load i8**, i8*** %4
%10 = load i8*, i8** %9
store i8* %10, i8** %6
%11 = load i8**, i8*** %4
%12 = load %struct.command_arg*, %struct.command_arg** %5
%13 = call i8* @symbol_verify(i8** %11, %struct.command_arg* %12)
store i8* %13, i8** %7
%14 = load i8*, i8** %7
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = load i8*, i8** %7
store i8* %17, i8** %3
br label %32
18: ; preds = %2
%19 = load i8*, i8** %6
%20 = load i8**, i8*** %4
%21 = load i8*, i8** %20
%22 = load i8*, i8** %6
%23 = ptrtoint i8* %21 to i64
%24 = ptrtoint i8* %22 to i64
%25 = sub i64 %23, %24
%26 = trunc i64 %25 to i32
%27 = call i32 @map_idn(i8* %19, i32 %26)
store i32 %27, i32* %8
%28 = load i32, i32* %8
%29 = icmp sge i32 %28, 0
%30 = zext i1 %29 to i64
%31 = select i1 %29, i8* null, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0)
store i8* %31, i8** %3
br label %32
32: ; preds = %18, %16
%33 = load i8*, i8** %3
ret i8* %33
}

LLVM IR (-O2):
%struct.command_arg = type { i32 }
@.str = [16 x i8] c"No such keymap.\00"
define i8* @keymap_verify(i8** %0, %struct.command_arg* %1) {
%3 = load i8*, i8** %0
%4 = tail call i8* @symbol_verify(i8** %0, %struct.command_arg* %1)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %15
6: ; preds = %2
%7 = load i8*, i8** %0
%8 = ptrtoint i8* %7 to i64
%9 = ptrtoint i8* %3 to i64
%10 = sub i64 %8, %9
%11 = trunc i64 %10 to i32
%12 = tail call i32 @map_idn(i8* %3, i32 %11)
%13 = icmp sgt i32 %12, -1
%14 = select i1 %13, i8* null, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0)
br label %15
15: ; preds = %2, %6
%16 = phi i8* [ %14, %6 ], [ %4, %2 ]
ret i8* %16
}