#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 *, ...);
int toUpperCase(char);
void printInitials(char *s, int length) {
  int i;
  int nChar;
  bool initial = true;
  for (i = 0; i <= length; i++) {
    if (initial) {
      printf("%c", toUpperCase(s[i]));
      initial = false;
    }
    nChar = s[i];
    if (nChar == 32) {
      initial = true;
    }
    if (nChar == 10) {
      break;
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<printInitials>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11bd <printInitials+0x9d>
cmpl   $0x0,-0x18(%rbp)
je     117b <printInitials+0x5b>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <toUpperCase@plt>
mov    %eax,%esi
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x20,-0x14(%rbp)
jne    119b <printInitials+0x7b>
movl   $0x1,-0x18(%rbp)
cmpl   $0xa,-0x14(%rbp)
jne    11aa <printInitials+0x8a>
jmp    11bd <printInitials+0x9d>
jmp    11af <printInitials+0x8f>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113d <printInitials+0x1d>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printInitials>:
push   %r15
push   %r14
push   %rbx
test   %esi,%esi
js     1170 <printInitials+0x50>
mov    %esi,%r14d
mov    %rdi,%r15
add    $0x1,%r14d
mov    $0x1,%eax
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
test   %eax,%eax
je     1155 <printInitials+0x35>
movsbl (%r15,%rbx,1),%edi
call   1040 <toUpperCase@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
movzbl (%r15,%rbx,1),%ecx
cmp    $0xa,%cl
je     1170 <printInitials+0x50>
xor    %eax,%eax
cmp    $0x20,%cl
sete   %al
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1140 <printInitials+0x20>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @printInitials(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 1, i32* %7
store i32 0, i32* %5
br label %8
8: ; preds = %38, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = icmp sle i32 %9, %10
br i1 %11, label %12, label %41
12: ; preds = %8
%13 = load i32, i32* %7
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %12
%16 = load i8*, i8** %3
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = call i32 @toUpperCase(i8 signext %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %21)
store i32 0, i32* %7
br label %23
23: ; preds = %15, %12
%24 = load i8*, i8** %3
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
store i32 %29, i32* %6
%30 = load i32, i32* %6
%31 = icmp eq i32 %30, 32
br i1 %31, label %32, label %33
32: ; preds = %23
store i32 1, i32* %7
br label %33
33: ; preds = %32, %23
%34 = load i32, i32* %6
%35 = icmp eq i32 %34, 10
br i1 %35, label %36, label %37
36: ; preds = %33
br label %41
37: ; preds = %33
br label %38
38: ; preds = %37
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %8
41: ; preds = %36, %8
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
define void @printInitials(i8* nocapture %0, i32 %1) {
%3 = icmp slt i32 %1, 0
br i1 %3, label %25, label %4
4: ; preds = %2
%5 = add nuw i32 %1, 1
%6 = zext i32 %5 to i64
br label %7
7: ; preds = %4, %20
%8 = phi i64 [ 0, %4 ], [ %23, %20 ]
%9 = phi i32 [ 1, %4 ], [ %22, %20 ]
%10 = icmp eq i32 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %7
%12 = getelementptr inbounds i8, i8* %0, i64 %8
%13 = load i8, i8* %12
%14 = tail call i32 @toUpperCase(i8 signext %13)
%15 = tail call i32 @putchar(i32 %14)
br label %16
16: ; preds = %11, %7
%17 = getelementptr inbounds i8, i8* %0, i64 %8
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 10
br i1 %19, label %25, label %20
20: ; preds = %16
%21 = icmp eq i8 %18, 32
%22 = zext i1 %21 to i32
%23 = add nuw nsw i64 %8, 1
%24 = icmp eq i64 %23, %6
br i1 %24, label %25, label %7
25: ; preds = %20, %16, %2
%26 = tail call i32 @putchar(i32 10)
ret void
}