#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 EXIT_SUCCESS;
scalar_t__ islower(int);
int /*<<< orphan*/ printf(char *, int);
char toupper(int);
int main(int argc, char *argv[]) {
  const int ch_space = (int)' ';
  const int ch_score = (int)'_';
  int ch_prev = 0;
  int ch_current = 0;
  char *text;
  if (argc >= 2) {
    text = argv[1];
    *text = toupper((int)*text);
    for (;;) {
      if (*text == (char)0)
        break;
      ch_current = (int)*text;
      if (ch_prev == ch_space || ch_prev == ch_score)
        if (islower(ch_current))
          ch_current = (int)toupper(ch_current);
      (void)printf("%c", ch_current);
      ch_prev = ch_current;
      ++text;
    }
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x20,-0x14(%rbp)
movl   $0x5f,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     120f <main+0xdf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%edi
call   1040 <toupper@plt>
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %cl,(%rax)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11a1 <main+0x71>
jmp    120a <main+0xda>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x20,-0x1c(%rbp)
je     11bf <main+0x8f>
cmpl   $0x5f,-0x1c(%rbp)
jne    11e4 <main+0xb4>
mov    -0x20(%rbp),%edi
call   1030 <islower@plt>
cmp    $0x0,%rax
je     11df <main+0xaf>
mov    -0x20(%rbp),%edi
call   1040 <toupper@plt>
movsbl %al,%eax
mov    %eax,-0x20(%rbp)
jmp    11e4 <main+0xb4>
mov    -0x20(%rbp),%esi
lea    0xe12(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    118c <main+0x5c>
jmp    120f <main+0xdf>
mov    0x2dca(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x2,%edi
jl     119c <main+0x6c>
mov    0x8(%rsi),%rbx
movsbl (%rbx),%edi
call   1040 <toupper@plt>
mov    %al,(%rbx)
test   %al,%al
je     119c <main+0x6c>
add    $0x1,%rbx
xor    %ecx,%ecx
lea    0xea8(%rip),%r14
jmp    1177 <main+0x47>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebp,%esi
call   1050 <printf@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
mov    %ebp,%ecx
test   %al,%al
je     119c <main+0x6c>
movsbl %al,%ebp
cmp    $0x5f,%ecx
je     1184 <main+0x54>
cmp    $0x20,%ecx
jne    1160 <main+0x30>
mov    %ebp,%edi
call   1030 <islower@plt>
test   %rax,%rax
je     1160 <main+0x30>
mov    %ebp,%edi
call   1040 <toupper@plt>
movsbl %al,%ebp
jmp    1160 <main+0x30>
mov    0x2e3d(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %28
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = tail call signext i8 @toupper(i32 %8)
store i8 %9, i8* %6
%10 = icmp eq i8 %9, 0
br i1 %10, label %28, label %11
11: ; preds = %4, %22
%12 = phi i8 [ %26, %22 ], [ %9, %4 ]
%13 = phi i8* [ %25, %22 ], [ %6, %4 ]
%14 = phi i32 [ %23, %22 ], [ 0, %4 ]
%15 = sext i8 %12 to i32
switch i32 %14, label %22 [
i32 95, label %16
i32 32, label %16
]
16: ; preds = %11, %11
%17 = tail call i64 @islower(i32 %15)
%18 = icmp eq i64 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = tail call signext i8 @toupper(i32 %15)
%21 = sext i8 %20 to i32
br label %22
22: ; preds = %11, %16, %19
%23 = phi i32 [ %21, %19 ], [ %15, %16 ], [ %15, %11 ]
%24 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds i8, i8* %13, i64 1
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 0
br i1 %27, label %28, label %11
28: ; preds = %22, %4, %2
%29 = load i32, i32* @EXIT_SUCCESS
ret i32 %29
}