#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*/ tolower(int /*<<< orphan*/);
int /*<<< orphan*/ toupper(int /*<<< orphan*/);
char *mnemonic2words(char *mnemonic) {
  static char a[1024 + 1];
  char *ptr = a;
  int first_letter_of_word = 1;
  while (*mnemonic) {
    if (*mnemonic == '_') {
      *ptr++ = ' ';
      mnemonic++;
      first_letter_of_word = 1;
    } else if (first_letter_of_word) {
      *ptr++ = toupper(*mnemonic++);
      first_letter_of_word = 0;
    } else {
      *ptr++ = tolower(*mnemonic++);
    }
  }
  *ptr = '\0';
  return a;
}


x86 assembly (clang, -O0):
<mnemonic2words>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0x2f0d(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11f9 <mnemonic2words+0xd9>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
jne    1185 <mnemonic2words+0x65>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x20,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x14(%rbp)
jmp    11f4 <mnemonic2words+0xd4>
cmpl   $0x0,-0x14(%rbp)
je     11c5 <mnemonic2words+0xa5>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
movl   $0x0,-0x14(%rbp)
jmp    11ef <mnemonic2words+0xcf>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%edi
call   1040 <tolower@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    11f4 <mnemonic2words+0xd4>
jmp    113e <mnemonic2words+0x1e>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2e39(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mnemonic2words>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%cl
test   %cl,%cl
je     1174 <mnemonic2words+0x54>
mov    %rdi,%r14
add    $0x1,%r14
lea    0x2f08(%rip),%rbx
mov    $0x1,%edx
jmp    115a <mnemonic2words+0x3a>
call   1030 <toupper@plt>
xor    %esi,%esi
mov    %al,(%rbx)
add    $0x1,%rbx
movzbl (%r14),%ecx
add    $0x1,%r14
mov    %esi,%edx
test   %cl,%cl
je     117b <mnemonic2words+0x5b>
mov    $0x20,%al
mov    $0x1,%esi
cmp    $0x5f,%cl
je     1146 <mnemonic2words+0x26>
movsbl %cl,%edi
test   %edx,%edx
jne    113f <mnemonic2words+0x1f>
call   1040 <tolower@plt>
jmp    1144 <mnemonic2words+0x24>
lea    0x2ec5(%rip),%rbx
movb   $0x0,(%rbx)
lea    0x2ebb(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@mnemonic2words.a = internal global [1025 x i8] zeroinitializer
define i8* @mnemonic2words(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
store i8* getelementptr inbounds ([1025 x i8], [1025 x i8]* @mnemonic2words.a, i64 0, i64 0), i8** %3
store i32 1, i32* %4
br label %5
5: ; preds = %41, %1
%6 = load i8*, i8** %2
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 0
br i1 %8, label %9, label %42
9: ; preds = %5
%10 = load i8*, i8** %2
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 95
br i1 %13, label %14, label %19
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %3
store i8 32, i8* %15
%17 = load i8*, i8** %2
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %2
store i32 1, i32* %4
br label %41
19: ; preds = %9
%20 = load i32, i32* %4
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %31
22: ; preds = %19
%23 = load i8*, i8** %2
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %2
%25 = load i8, i8* %23
%26 = sext i8 %25 to i32
%27 = call i32 @toupper(i32 %26)
%28 = trunc i32 %27 to i8
%29 = load i8*, i8** %3
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %3
store i8 %28, i8* %29
store i32 0, i32* %4
br label %40
31: ; preds = %19
%32 = load i8*, i8** %2
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %2
%34 = load i8, i8* %32
%35 = sext i8 %34 to i32
%36 = call i32 @tolower(i32 %35)
%37 = trunc i32 %36 to i8
%38 = load i8*, i8** %3
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %3
store i8 %37, i8* %38
br label %40
40: ; preds = %31, %22
br label %41
41: ; preds = %40, %14
br label %5
42: ; preds = %5
%43 = load i8*, i8** %3
store i8 0, i8* %43
ret i8* getelementptr inbounds ([1025 x i8], [1025 x i8]* @mnemonic2words.a, i64 0, i64 0)
}

LLVM IR (-O2):
@mnemonic2words.a = internal global [1025 x i8] zeroinitializer
define i8* @mnemonic2words(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %26, label %4
4: ; preds = %1, %19
%5 = phi i8 [ %24, %19 ], [ %2, %1 ]
%6 = phi i32 [ %21, %19 ], [ 1, %1 ]
%7 = phi i8* [ %23, %19 ], [ getelementptr inbounds ([1025 x i8], [1025 x i8]* @mnemonic2words.a, i64 0, i64 0), %1 ]
%8 = phi i8* [ %22, %19 ], [ %0, %1 ]
%9 = sext i8 %5 to i32
%10 = icmp eq i8 %5, 95
br i1 %10, label %19, label %11
11: ; preds = %4
%12 = icmp eq i32 %6, 0
br i1 %12, label %16, label %13
13: ; preds = %11
%14 = tail call i32 @toupper(i32 %9)
%15 = trunc i32 %14 to i8
br label %19
16: ; preds = %11
%17 = tail call i32 @tolower(i32 %9)
%18 = trunc i32 %17 to i8
br label %19
19: ; preds = %4, %13, %16
%20 = phi i8 [ %15, %13 ], [ %18, %16 ], [ 32, %4 ]
%21 = phi i32 [ 0, %13 ], [ 0, %16 ], [ 1, %4 ]
store i8 %20, i8* %7
%22 = getelementptr inbounds i8, i8* %8, i64 1
%23 = getelementptr inbounds i8, i8* %7, i64 1
%24 = load i8, i8* %22
%25 = icmp eq i8 %24, 0
br i1 %25, label %26, label %4
26: ; preds = %19, %1
%27 = phi i8* [ getelementptr inbounds ([1025 x i8], [1025 x i8]* @mnemonic2words.a, i64 0, i64 0), %1 ], [ %23, %19 ]
store i8 0, i8* %27
ret i8* getelementptr inbounds ([1025 x i8], [1025 x i8]* @mnemonic2words.a, i64 0, i64 0)
}