#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();
scalar_t__ isspace(char);
int /*<<< orphan*/ printf(char *);
int get_name(char name[]) {
  int err = 0;
  int i = 0;
  printf("Name: ");
  while (isspace(name[i] = getchar()) || i++)
    ;
  for (i = i; ((name[i++] = getchar()) != '\n') && i < 25;)
    ;
  name[--i] = '\0';
  return err;
}


x86 assembly (clang, -O0):
<get_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    -0x8(%rbp),%rcx
movslq -0x10(%rbp),%rdx
mov    %al,(%rcx,%rdx,1)
movsbl %al,%edi
call   1040 <isspace@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x11(%rbp)
jne    1196 <get_name+0x66>
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x10(%rbp)
cmp    $0x0,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    11a6 <get_name+0x76>
jmp    11ab <get_name+0x7b>
jmp    1156 <get_name+0x26>
mov    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%edx
mov    %edx,%esi
add    $0x1,%esi
mov    %esi,-0x10(%rbp)
movslq %edx,%rdx
mov    %al,(%rcx,%rdx,1)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x12(%rbp)
je     11e8 <get_name+0xb8>
cmpl   $0x19,-0x10(%rbp)
setl   %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    11f8 <get_name+0xc8>
jmp    11fd <get_name+0xcd>
jmp    11b1 <get_name+0x81>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x10(%rbp)
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_name>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xec2(%rip),%rdi
call   1030 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %al,(%r14)
movsbl %al,%edi
call   1040 <isspace@plt>
test   %rax,%rax
jne    1150 <get_name+0x20>
mov    $0x1,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
lea    0x1(%rbx),%rcx
mov    %al,(%r14,%rbx,1)
cmp    $0xa,%al
je     118c <get_name+0x5c>
cmp    $0x18,%rbx
mov    %rcx,%rbx
jb     1170 <get_name+0x40>
movb   $0x0,-0x1(%r14,%rcx,1)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"Name: \00"
define i32 @get_name(i8* nocapture writeonly %0) {
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %3
3: ; preds = %3, %1
%4 = tail call signext i8 (...) @getchar()
store i8 %4, i8* %0
%5 = tail call i64 @isspace(i8 signext %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %3
7: ; preds = %3, %7
%8 = phi i64 [ %10, %7 ], [ 1, %3 ]
%9 = tail call signext i8 (...) @getchar()
%10 = add nuw nsw i64 %8, 1
%11 = getelementptr inbounds i8, i8* %0, i64 %8
store i8 %9, i8* %11
%12 = icmp ne i8 %9, 10
%13 = icmp ult i64 %8, 24
%14 = select i1 %12, i1 %13, i1 false
br i1 %14, label %7, label %15
15: ; preds = %7
%16 = getelementptr inbounds i8, i8* %0, i64 %8
store i8 0, i8* %16
ret i32 0
}