#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
char toupper(char);
int main(void) {
  char ch, initial;
  printf("Enter a first and last name: ");
  do {
    initial = (toupper(getchar()));
  } while (getchar() == ' ');
  while (getchar() != ' ')
    ;
  while ((ch = getchar()) == ' ')
    ;
  putchar(ch);
  while ((ch = getchar()) != '\n')
    putchar(ch);
  printf(", %c.\n", initial);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
movsbl %al,%edi
call   1040 <toupper@plt>
mov    %al,-0x6(%rbp)
mov    $0x0,%al
call   1060 <getchar@plt>
movsbl %al,%eax
cmp    $0x20,%eax
je     115d <main+0x1d>
jmp    1187 <main+0x47>
mov    $0x0,%al
call   1060 <getchar@plt>
movsbl %al,%eax
cmp    $0x20,%eax
je     119f <main+0x5f>
jmp    1187 <main+0x47>
jmp    11a4 <main+0x64>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0x20,%eax
jne    11bf <main+0x7f>
jmp    11a4 <main+0x64>
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     11ec <main+0xac>
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
jmp    11c8 <main+0x88>
movsbl -0x6(%rbp),%esi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
nop
xor    %eax,%eax
call   1060 <getchar@plt>
movsbl %al,%edi
call   1040 <toupper@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0x20,%al
je     1150 <main+0x10>
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0x20,%al
jne    1170 <main+0x30>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0x20,%al
je     1180 <main+0x40>
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%al
jne    1190 <main+0x50>
movsbl %bl,%esi
lea    0xe71(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [30 x i8] c"Enter a first and last name: \00"
@.str.1 = [7 x i8] c", %c.\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %2
2: ; preds = %2, %0
%3 = tail call signext i8 (...) @getchar()
%4 = tail call signext i8 @toupper(i8 signext %3)
%5 = tail call signext i8 (...) @getchar()
%6 = icmp eq i8 %5, 32
br i1 %6, label %2, label %7
7: ; preds = %2, %7
%8 = tail call signext i8 (...) @getchar()
%9 = icmp eq i8 %8, 32
br i1 %9, label %10, label %7
10: ; preds = %7, %10
%11 = tail call signext i8 (...) @getchar()
%12 = icmp eq i8 %11, 32
br i1 %12, label %10, label %13
13: ; preds = %10
%14 = tail call i32 @putchar(i8 signext %11)
%15 = tail call signext i8 (...) @getchar()
%16 = icmp eq i8 %15, 10
br i1 %16, label %22, label %17
17: ; preds = %13, %17
%18 = phi i8 [ %20, %17 ], [ %15, %13 ]
%19 = tail call i32 @putchar(i8 signext %18)
%20 = tail call signext i8 (...) @getchar()
%21 = icmp eq i8 %20, 10
br i1 %21, label %22, label %17
22: ; preds = %17, %13
%23 = sext i8 %4 to i32
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %23)
ret i32 0
}