#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);
int main(void) {
  char name, ch;
  printf("enter a name:\n");
  while ((name = getchar()) == ' ') {
    ;
  }
  while (getchar() != ' ') {
    ;
  }
  while ((ch = getchar()) == ' ') {
    ;
  }
  putchar(ch);
  while ((ch = getchar()) != '\n') {
    putchar(ch);
  }
  putchar(',');
  putchar(name);
  putchar('.');
  putchar('\n');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0x20,%eax
jne    1166 <main+0x36>
jmp    114b <main+0x1b>
jmp    116b <main+0x3b>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
cmp    $0x20,%eax
je     1183 <main+0x53>
jmp    116b <main+0x3b>
jmp    1188 <main+0x58>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x6(%rbp)
movsbl %al,%eax
cmp    $0x20,%eax
jne    11a3 <main+0x73>
jmp    1188 <main+0x58>
movsbl -0x6(%rbp),%edi
call   1030 <putchar@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x6(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     11d0 <main+0xa0>
movsbl -0x6(%rbp),%edi
call   1030 <putchar@plt>
jmp    11ac <main+0x7c>
mov    $0x2c,%edi
call   1030 <putchar@plt>
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xec8(%rip),%rdi
call   1040 <puts@plt>
nopl   (%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0x20,%al
je     1140 <main+0x10>
mov    %eax,%ebx
nopl   (%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0x20,%al
jne    1150 <main+0x20>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0x20,%al
je     1160 <main+0x30>
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    1170 <main+0x40>
mov    $0x2c,%edi
call   1030 <putchar@plt>
movsbl %bl,%edi
call   1030 <putchar@plt>
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
ret

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

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