#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*/ exit(int);
int /*<<< orphan*/ free(char *);
char *getInput();
int isAllAlpha(char *);
int /*<<< orphan*/ printf(char *);
char *getName(void) {
  printf("Name: ");
  char *name = getInput();
  if (name == NULL) {
    printf("You have entered an invalid name.\n");
    exit(1);
  }
  if (isAllAlpha(name) != 1) {
    printf("A name must contain only letters and one space.\n");
    free(name);
    exit(2);
  }
  return name;
}


x86 assembly (clang, -O0):
<getName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <getInput@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1190 <getName+0x40>
lea    0xe86(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%rdi
call   1040 <isAllAlpha@plt>
cmp    $0x1,%eax
je     11c1 <getName+0x71>
lea    0xe81(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    $0x2,%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getName>:
push   %rbx
lea    0xe98(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <getInput@plt>
test   %rax,%rax
je     118e <getName+0x2e>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <isAllAlpha@plt>
cmp    $0x1,%eax
jne    11a4 <getName+0x44>
mov    %rbx,%rax
pop    %rbx
ret
lea    0xea2(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xe5c(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x2,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"Name: \00"
@.str.1 = [35 x i8] c"You have entered an invalid name.\0A\00"
@.str.2 = [49 x i8] c"A name must contain only letters and one space.\0A\00"
define i8* @getName() {
%1 = alloca i8*
%2 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%3 = call i8* (...) @getInput()
store i8* %3, i8** %1
%4 = load i8*, i8** %1
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = load i8*, i8** %1
%11 = call i32 @isAllAlpha(i8* %10)
%12 = icmp ne i32 %11, 1
br i1 %12, label %13, label %18
13: ; preds = %9
%14 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0))
%15 = load i8*, i8** %1
%16 = call i32 @free(i8* %15)
%17 = call i32 @exit(i32 2)
unreachable
18: ; preds = %9
%19 = load i8*, i8** %1
ret i8* %19
}

LLVM IR (-O2):
@.str = [7 x i8] c"Name: \00"
@str = [48 x i8] c"A name must contain only letters and one space.\00"
@str.3 = [34 x i8] c"You have entered an invalid name.\00"
define i8* @getName() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%2 = tail call i8* (...) @getInput()
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.3, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %0
%8 = tail call i32 @isAllAlpha(i8* %2)
%9 = icmp eq i32 %8, 1
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @free(i8* %2)
%13 = tail call i32 @exit(i32 2)
unreachable
14: ; preds = %7
ret i8* %2
}