#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 */
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
scalar_t__ strcasecmp(char *, char *);
char *strchr(char *, char);
int strspn(char *, char *);
char *strtok(char *, char *);
int main(int ac, char **av) {
  char line[256];
  char buf[256];
  char *var;
  char *val;
  char *p;
  int n;
  (void)ac;
  (void)av;
  fputs("Copyright 2020 James R.\n"
        "All rights reserved.\n"
        "\n"
        "Usage: musicdef-2.2.1 < old-MUSICDEF > new-MUSICDEF\n"
        "\n",
        stderr);
  while (fgets(line, sizeof line, stdin)) {
    memcpy(buf, line, sizeof buf);
    if ((var = strtok(buf, " ="))) {
      if (!(strcasecmp(var, "TITLE") && strcasecmp(var, "ALTTITLE") &&
            strcasecmp(var, "AUTHORS"))) {
        if ((val = strtok(0, ""))) {
          for (p = val; (p = strchr(p, '_'));) {
            n = strspn(p, "_");
            memset(p, ' ', n);
            p += n;
          }
          printf("%s %s", var, val);
          continue;
        }
      }
    }
    fputs(line, stdout);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e28(%rip),%rax
mov    (%rax),%esi
lea    0xe47(%rip),%rdi
call   1060 <fputs@plt>
lea    -0x110(%rbp),%rdi
mov    0x2e1c(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     1358 <main+0x1c8>
lea    -0x210(%rbp),%rdi
lea    -0x110(%rbp),%rsi
mov    $0x100,%edx
call   10a0 <memcpy@plt>
lea    -0x210(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   10b0 <strtok@plt>
mov    %rax,-0x218(%rbp)
cmp    $0x0,%rax
je     133e <main+0x1ae>
mov    -0x218(%rbp),%rdi
lea    0xe3e(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     1275 <main+0xe5>
mov    -0x218(%rbp),%rdi
lea    0xe1e(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     1275 <main+0xe5>
mov    -0x218(%rbp),%rdi
lea    0xe0a(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1339 <main+0x1a9>
xor    %eax,%eax
mov    %eax,%edi
lea    0xde3(%rip),%rsi
call   10b0 <strtok@plt>
mov    %rax,-0x220(%rbp)
cmp    $0x0,%rax
je     1334 <main+0x1a4>
mov    -0x220(%rbp),%rax
mov    %rax,-0x228(%rbp)
mov    -0x228(%rbp),%rdi
mov    $0x5f,%esi
call   1040 <strchr@plt>
mov    %rax,-0x228(%rbp)
cmp    $0x0,%rax
je     1315 <main+0x185>
mov    -0x228(%rbp),%rdi
lea    0xda4(%rip),%rsi
call   1080 <strspn@plt>
mov    %eax,-0x22c(%rbp)
mov    -0x228(%rbp),%rdi
mov    -0x22c(%rbp),%edx
mov    $0x20,%esi
call   1070 <memset@plt>
mov    -0x22c(%rbp),%ecx
mov    -0x228(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x228(%rbp)
jmp    12a4 <main+0x114>
mov    -0x218(%rbp),%rsi
mov    -0x220(%rbp),%rdx
lea    0xd50(%rip),%rdi
call   1050 <printf@plt>
jmp    11be <main+0x2e>
jmp    1339 <main+0x1a9>
jmp    133e <main+0x1ae>
lea    -0x110(%rbp),%rdi
mov    0x2c84(%rip),%rax
mov    (%rax),%esi
call   1060 <fputs@plt>
jmp    11be <main+0x2e>
xor    %eax,%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    0x2e30(%rip),%rax
mov    (%rax),%esi
lea    0xe4f(%rip),%rdi
call   1060 <fputs@plt>
mov    0x2e2b(%rip),%r14
mov    (%r14),%edx
mov    %rsp,%rdi
mov    $0x100,%esi
call   1090 <fgets@plt>
test   %rax,%rax
je     1321 <main+0x191>
lea    0x100(%rsp),%rbp
mov    %rsp,%rbx
lea    0xe7c(%rip),%r15
jmp    121a <main+0x8a>
nopw   0x0(%rax,%rax,1)
mov    0x2dd9(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1060 <fputs@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1090 <fgets@plt>
test   %rax,%rax
je     1321 <main+0x191>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x100,%edx
call   10a0 <memcpy@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   10b0 <strtok@plt>
test   %rax,%rax
je     11f0 <main+0x60>
mov    %rax,%r13
mov    %rax,%rdi
lea    0xe23(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1280 <main+0xf0>
mov    %r13,%rdi
lea    0xe0c(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1280 <main+0xf0>
mov    %r13,%rdi
lea    0xe01(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
jne    11f0 <main+0x60>
nopl   (%rax)
xor    %edi,%edi
lea    0xdda(%rip),%rsi
call   10b0 <strtok@plt>
test   %rax,%rax
je     11f0 <main+0x60>
mov    %rax,%r12
mov    %r14,%rbx
mov    %rax,%rdi
mov    $0x5f,%esi
call   1040 <strchr@plt>
test   %rax,%rax
lea    0xdc4(%rip),%rbp
je     12f5 <main+0x165>
mov    %rax,%r15
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %rbp,%rsi
call   1080 <strspn@plt>
mov    %eax,%r14d
mov    %r15,%rdi
mov    $0x20,%esi
mov    %eax,%edx
call   1070 <memset@plt>
movslq %r14d,%rdi
add    %r15,%rdi
mov    $0x5f,%esi
call   1040 <strchr@plt>
mov    %rax,%r15
test   %rax,%rax
jne    12c0 <main+0x130>
lea    0xd7e(%rip),%rdi
mov    %r13,%rsi
mov    %r12,%rdx
call   1050 <printf@plt>
mov    %rbx,%r14
lea    0x100(%rsp),%rbp
mov    %rsp,%rbx
lea    0xd48(%rip),%r15
jmp    1201 <main+0x71>
xor    %eax,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [100 x i8] c"Copyright 2020 James R.\0AAll rights reserved.\0A\0AUsage: musicdef-2.2.1 < old-MUSICDEF > new-MUSICDEF\0A\0A\00"
@stderr = global i32 0
@stdin = global i32 0
@.str.1 = [3 x i8] c" =\00"
@.str.2 = [6 x i8] c"TITLE\00"
@.str.3 = [9 x i8] c"ALTTITLE\00"
@.str.4 = [8 x i8] c"AUTHORS\00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [2 x i8] c"_\00"
@.str.7 = [6 x i8] c"%s %s\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i8]
%7 = alloca [256 x i8]
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = load i8**, i8*** %5
%14 = load i32, i32* @stderr
%15 = call i32 @fputs(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %65, %59, %2
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%18 = load i32, i32* @stdin
%19 = call i64 @fgets(i8* %17, i32 256, i32 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %69
21: ; preds = %16
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%24 = call i32 @memcpy(i8* %22, i8* %23, i32 256)
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%26 = call i8* @strtok(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i8* %26, i8** %8
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %65
28: ; preds = %21
%29 = load i8*, i8** %8
%30 = call i64 @strcasecmp(i8* %29, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %40
32: ; preds = %28
%33 = load i8*, i8** %8
%34 = call i64 @strcasecmp(i8* %33, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %32
%37 = load i8*, i8** %8
%38 = call i64 @strcasecmp(i8* %37, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%39 = icmp ne i64 %38, 0
br i1 %39, label %64, label %40
40: ; preds = %36, %32, %28
%41 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0))
store i8* %41, i8** %9
%42 = icmp ne i8* %41, null
br i1 %42, label %43, label %63
43: ; preds = %40
%44 = load i8*, i8** %9
store i8* %44, i8** %10
br label %45
45: ; preds = %49, %43
%46 = load i8*, i8** %10
%47 = call i8* @strchr(i8* %46, i8 signext 95)
store i8* %47, i8** %10
%48 = icmp ne i8* %47, null
br i1 %48, label %49, label %59
49: ; preds = %45
%50 = load i8*, i8** %10
%51 = call i32 @strspn(i8* %50, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32 %51, i32* %11
%52 = load i8*, i8** %10
%53 = load i32, i32* %11
%54 = call i32 @memset(i8* %52, i8 signext 32, i32 %53)
%55 = load i32, i32* %11
%56 = load i8*, i8** %10
%57 = sext i32 %55 to i64
%58 = getelementptr inbounds i8, i8* %56, i64 %57
store i8* %58, i8** %10
br label %45
59: ; preds = %45
%60 = load i8*, i8** %8
%61 = load i8*, i8** %9
%62 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %60, i8* %61)
br label %16
63: ; preds = %40
br label %64
64: ; preds = %63, %36
br label %65
65: ; preds = %64, %21
%66 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%67 = load i32, i32* @stdout
%68 = call i32 @fputs(i8* %66, i32 %67)
br label %16
69: ; preds = %16
ret i32 0
}

LLVM IR (-O2):
@.str = [100 x i8] c"Copyright 2020 James R.\0AAll rights reserved.\0A\0AUsage: musicdef-2.2.1 < old-MUSICDEF > new-MUSICDEF\0A\0A\00"
@stderr = global i32 0
@stdin = global i32 0
@.str.1 = [3 x i8] c" =\00"
@.str.2 = [6 x i8] c"TITLE\00"
@.str.3 = [9 x i8] c"ALTTITLE\00"
@.str.4 = [8 x i8] c"AUTHORS\00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [2 x i8] c"_\00"
@.str.7 = [6 x i8] c"%s %s\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [256 x i8]
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = load i32, i32* @stderr
%8 = tail call i32 @fputs(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* @stdin
%10 = call i64 @fgets(i8* %5, i32 256, i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %48, label %12
12: ; preds = %2, %41
%13 = call i32 @memcpy(i8* %6, i8* %5, i32 256)
%14 = call i8* @strtok(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i8* %14, null
br i1 %15, label %45, label %16
16: ; preds = %12
%17 = call i64 @strcasecmp(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %25, label %19
19: ; preds = %16
%20 = call i64 @strcasecmp(i8* %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %19
%23 = call i64 @strcasecmp(i8* %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %45
25: ; preds = %22, %19, %16
%26 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0))
%27 = icmp eq i8* %26, null
br i1 %27, label %45, label %28
28: ; preds = %25
%29 = call i8* @strchr(i8* dereferenceable(1) %26, i8 signext 95)
%30 = icmp eq i8* %29, null
br i1 %30, label %39, label %31
31: ; preds = %28, %31
%32 = phi i8* [ %37, %31 ], [ %29, %28 ]
%33 = call i32 @strspn(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%34 = call i32 @memset(i8* %32, i8 signext 32, i32 %33)
%35 = sext i32 %33 to i64
%36 = getelementptr inbounds i8, i8* %32, i64 %35
%37 = call i8* @strchr(i8* dereferenceable(1) %36, i8 signext 95)
%38 = icmp eq i8* %37, null
br i1 %38, label %39, label %31
39: ; preds = %31, %28
%40 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %14, i8* %26)
br label %41
41: ; preds = %39, %45
%42 = load i32, i32* @stdin
%43 = call i64 @fgets(i8* %5, i32 256, i32 %42)
%44 = icmp eq i64 %43, 0
br i1 %44, label %48, label %12
45: ; preds = %22, %25, %12
%46 = load i32, i32* @stdout
%47 = call i32 @fputs(i8* %5, i32 %46)
br label %41
48: ; preds = %41, %2
ret i32 0
}