#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 *, char const);
void reverse_name(const char *name) {
  int i = 0;
  char fi;
  while (name[i] == ' ') {
    i += 1;
  }
  fi = name[i];
  while (name[i] != ' ') {
    i += 1;
  }
  while (name[i] == ' ') {
    i += 1;
  }
  while (name[i] != '\n' && name[i] != ' ') {
    printf("%c", name[i]);
    i += 1;
  }
  printf(", %c.\n", fi);
}


x86 assembly (clang, -O0):
<reverse_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    1146 <reverse_name+0x36>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <reverse_name+0x13>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0xd(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     1177 <reverse_name+0x67>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1154 <reverse_name+0x44>
jmp    117c <reverse_name+0x6c>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    119f <reverse_name+0x8f>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117c <reverse_name+0x6c>
jmp    11a4 <reverse_name+0x94>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0xe(%rbp)
je     11d3 <reverse_name+0xc3>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
setne  %al
mov    %al,-0xe(%rbp)
mov    -0xe(%rbp),%al
test   $0x1,%al
jne    11e3 <reverse_name+0xd3>
jmp    1209 <reverse_name+0xf9>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
lea    0xe0e(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a4 <reverse_name+0x94>
lea    0xdf3(%rip),%rdi
movsbl -0xd(%rbp),%esi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse_name>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
mov    $0xfffffffd,%eax
mov    %rdi,%rcx
movzbl (%rcx),%ebx
add    $0x1,%eax
add    $0x1,%rcx
cmp    $0x20,%bl
je     1120 <reverse_name+0x10>
lea    0x2(%rax),%ecx
add    %r15,%rcx
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%eax
cmpb   $0x20,(%rcx)
lea    0x1(%rcx),%rcx
jne    1140 <reverse_name+0x30>
lea    0x1(%rax),%ecx
add    %r15,%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%eax
cmpb   $0x20,(%rcx)
lea    0x1(%rcx),%rcx
je     1160 <reverse_name+0x50>
mov    %eax,%eax
add    %rax,%r15
lea    0xe88(%rip),%r14
nopl   0x0(%rax,%rax,1)
movzbl (%r15),%eax
cmp    $0xa,%al
je     119d <reverse_name+0x8d>
cmp    $0x20,%al
je     119d <reverse_name+0x8d>
movsbl %al,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%r15
jmp    1180 <reverse_name+0x70>
movsbl %bl,%esi
lea    0xe5c(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [7 x i8] c", %c.\0A\00"
define void @reverse_name(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8
store i8* %0, i8** %2
store i32 0, i32* %3
br label %5
5: ; preds = %13, %1
%6 = load i8*, i8** %2
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 32
br i1 %12, label %13, label %16
13: ; preds = %5
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %5
16: ; preds = %5
%17 = load i8*, i8** %2
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
store i8 %21, i8* %4
br label %22
22: ; preds = %30, %16
%23 = load i8*, i8** %2
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 32
br i1 %29, label %30, label %33
30: ; preds = %22
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %22
33: ; preds = %22
br label %34
34: ; preds = %42, %33
%35 = load i8*, i8** %2
%36 = load i32, i32* %3
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 32
br i1 %41, label %42, label %45
42: ; preds = %34
%43 = load i32, i32* %3
%44 = add nsw i32 %43, 1
store i32 %44, i32* %3
br label %34
45: ; preds = %34
br label %46
46: ; preds = %64, %45
%47 = load i8*, i8** %2
%48 = load i32, i32* %3
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp ne i32 %52, 10
br i1 %53, label %54, label %62
54: ; preds = %46
%55 = load i8*, i8** %2
%56 = load i32, i32* %3
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %55, i64 %57
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp ne i32 %60, 32
br label %62
62: ; preds = %54, %46
%63 = phi i1 [ false, %46 ], [ %61, %54 ]
br i1 %63, label %64, label %73
64: ; preds = %62
%65 = load i8*, i8** %2
%66 = load i32, i32* %3
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8, i8* %65, i64 %67
%69 = load i8, i8* %68
%70 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %69)
%71 = load i32, i32* %3
%72 = add nsw i32 %71, 1
store i32 %72, i32* %3
br label %46
73: ; preds = %62
%74 = load i8, i8* %4
%75 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 signext %74)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@.str.1 = [7 x i8] c", %c.\0A\00"
define void @reverse_name(i8* nocapture %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i64 [ %7, %2 ], [ 0, %1 ]
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 32
%7 = add nuw i64 %3, 1
br i1 %6, label %2, label %8
8: ; preds = %2
%9 = and i64 %3, 4294967295
br label %10
10: ; preds = %10, %8
%11 = phi i64 [ %15, %10 ], [ %9, %8 ]
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 32
%15 = add nuw i64 %11, 1
br i1 %14, label %16, label %10
16: ; preds = %10
%17 = and i64 %11, 4294967295
br label %18
18: ; preds = %16, %18
%19 = phi i64 [ %17, %16 ], [ %23, %18 ]
%20 = getelementptr inbounds i8, i8* %0, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 32
%23 = add nuw i64 %19, 1
br i1 %22, label %18, label %24
24: ; preds = %18
%25 = and i64 %19, 4294967295
br label %26
26: ; preds = %24, %30
%27 = phi i64 [ %25, %24 ], [ %32, %30 ]
%28 = getelementptr inbounds i8, i8* %0, i64 %27
%29 = load i8, i8* %28
switch i8 %29, label %30 [
i8 10, label %33
i8 32, label %33
]
30: ; preds = %26
%31 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %29)
%32 = add nuw i64 %27, 1
br label %26
33: ; preds = %26, %26
%34 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 signext %5)
ret void
}