#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*/ printf(char *, char const *, ...);
scalar_t__ toupper(unsigned char);
void keydef(const char *name, const char *old_name, int value, int mode) {
  if (mode == 0)
    printf("   %-30s : constant Special_Key_Code := 8#%3o#;\n", name, value);
  else {
    const char *s = old_name;
    const char *t = name;
    while (
        *s && *t &&
        (toupper(((unsigned char)(*s++))) == toupper(((unsigned char)(*t++)))))
      ;
    if (*s || *t)
      printf("   %-16s : Special_Key_Code renames %s;\n", old_name, name);
  }
}


x86 assembly (clang, -O0):
<keydef>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    115a <keydef+0x3a>
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1226 <keydef+0x106>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x29(%rbp)
je     11d6 <keydef+0xb6>
mov    -0x28(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x29(%rbp)
je     11d6 <keydef+0xb6>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movzbl (%rax),%edi
call   1030 <toupper@plt>
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movzbl (%rax),%edi
call   1030 <toupper@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cmp    %rcx,%rax
sete   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11e6 <keydef+0xc6>
jmp    11eb <keydef+0xcb>
jmp    116a <keydef+0x4a>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    120b <keydef+0xeb>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1221 <keydef+0x101>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1226 <keydef+0x106>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<keydef>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
test   %ecx,%ecx
je     119c <keydef+0x7c>
mov    %rsi,%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%r14,%rbx,1),%eax
test   %al,%al
je     1175 <keydef+0x55>
cmpb   $0x0,(%r15,%rbx,1)
je     117d <keydef+0x5d>
movzbl %al,%edi
call   1030 <toupper@plt>
mov    %rax,%r12
movzbl (%r15,%rbx,1),%edi
call   1030 <toupper@plt>
add    $0x1,%rbx
cmp    %rax,%r12
je     1140 <keydef+0x20>
cmpb   $0x0,(%r14,%rbx,1)
jne    117d <keydef+0x5d>
add    %r15,%rbx
cmpb   $0x0,(%rbx)
je     11b8 <keydef+0x98>
lea    0xead(%rip),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <printf@plt>
lea    0xe5d(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [49 x i8] c" %-30s : constant Special_Key_Code := 8#%3o#;\0A\00"
@.str.1 = [41 x i8] c" %-16s : Special_Key_Code renames %s;\0A\00"
define void @keydef(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load i32, i32* %8
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %4
%14 = load i8*, i8** %5
%15 = load i32, i32* %7
%16 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %14, i32 %15)
br label %58
17: ; preds = %4
%18 = load i8*, i8** %6
store i8* %18, i8** %9
%19 = load i8*, i8** %5
store i8* %19, i8** %10
br label %20
20: ; preds = %42, %17
%21 = load i8*, i8** %9
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %40
25: ; preds = %20
%26 = load i8*, i8** %10
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %40
30: ; preds = %25
%31 = load i8*, i8** %9
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %9
%33 = load i8, i8* %31
%34 = call i64 @toupper(i8 zeroext %33)
%35 = load i8*, i8** %10
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %10
%37 = load i8, i8* %35
%38 = call i64 @toupper(i8 zeroext %37)
%39 = icmp eq i64 %34, %38
br label %40
40: ; preds = %30, %25, %20
%41 = phi i1 [ false, %25 ], [ false, %20 ], [ %39, %30 ]
br i1 %41, label %42, label %43
42: ; preds = %40
br label %20
43: ; preds = %40
%44 = load i8*, i8** %9
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp ne i32 %46, 0
br i1 %47, label %53, label %48
48: ; preds = %43
%49 = load i8*, i8** %10
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %57
53: ; preds = %48, %43
%54 = load i8*, i8** %6
%55 = load i8*, i8** %5
%56 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %54, i8* %55)
br label %57
57: ; preds = %53, %48
br label %58
58: ; preds = %57, %13
ret void
}

LLVM IR (-O2):
@.str = [49 x i8] c" %-30s : constant Special_Key_Code := 8#%3o#;\0A\00"
@.str.1 = [41 x i8] c" %-16s : Special_Key_Code renames %s;\0A\00"
define void @keydef(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %3, 0
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %2)
br label %32
8: ; preds = %4, %16
%9 = phi i8* [ %17, %16 ], [ %1, %4 ]
%10 = phi i8* [ %19, %16 ], [ %0, %4 ]
%11 = load i8, i8* %9
%12 = icmp eq i8 %11, 0
br i1 %12, label %26, label %13
13: ; preds = %8
%14 = load i8, i8* %10
%15 = icmp eq i8 %14, 0
br i1 %15, label %30, label %16
16: ; preds = %13
%17 = getelementptr inbounds i8, i8* %9, i64 1
%18 = tail call i64 @toupper(i8 zeroext %11)
%19 = getelementptr inbounds i8, i8* %10, i64 1
%20 = load i8, i8* %10
%21 = tail call i64 @toupper(i8 zeroext %20)
%22 = icmp eq i64 %18, %21
br i1 %22, label %8, label %23
23: ; preds = %16
%24 = load i8, i8* %17
%25 = icmp eq i8 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %8, %23
%27 = phi i8* [ %19, %23 ], [ %10, %8 ]
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %13, %26, %23
%31 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %0)
br label %32
32: ; preds = %26, %30, %6
ret void
}