#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 *, ...);
void parse_name(char *subs) {
  int status = 0;
  int i = 0;
  printf("\nThis block\n\n  <subsystem name=\"");
  for (i = 0; i < 256; i++) {
    if (subs[i] == '_') {
      status = 1;
      break;
    }
    if (subs[i] == '.') {
      status = 2;
      break;
    }
    printf("%c", subs[i]);
  }
  if (status == 1) {
    printf("\" type=\"");
    for (i++; i < 256; i++) {
      if (subs[i] == '.') {
        break;
      }
      printf("%c", subs[i]);
    }
  }
  printf("\" >\n\nreplaces\n\n");
}


x86 assembly (clang, -O0):
<parse_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x100,-0x10(%rbp)
jge    11b6 <parse_name+0xa6>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5f,%eax
jne    116d <parse_name+0x5d>
movl   $0x1,-0xc(%rbp)
jmp    11b6 <parse_name+0xa6>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    118e <parse_name+0x7e>
movl   $0x2,-0xc(%rbp)
jmp    11b6 <parse_name+0xa6>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113f <parse_name+0x2f>
cmpl   $0x1,-0xc(%rbp)
jne    122b <parse_name+0x11b>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x100,-0x10(%rbp)
jge    1226 <parse_name+0x116>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    11fe <parse_name+0xee>
jmp    1226 <parse_name+0x116>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11d7 <parse_name+0xc7>
jmp    122b <parse_name+0x11b>
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_name>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xec2(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
nopw   0x0(%rax,%rax,1)
movsbl (%r14,%rbx,1),%edi
cmp    $0x2e,%edi
je     11ac <parse_name+0x7c>
cmp    $0x5f,%dil
je     1174 <parse_name+0x44>
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    1150 <parse_name+0x20>
jmp    11ac <parse_name+0x7c>
lea    0xea6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0xfe,%ebx
ja     11ac <parse_name+0x7c>
add    $0x1,%rbx
xchg   %ax,%ax
movsbl (%r14,%rbx,1),%edi
cmp    $0x2e,%edi
je     11ac <parse_name+0x7c>
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    1190 <parse_name+0x60>
lea    0xe77(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <puts@plt>

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

LLVM IR (-O2):
@.str = [33 x i8] c"\0AThis block\0A\0A <subsystem name=\22\00"
@.str.2 = [9 x i8] c"\22 type=\22\00"
@str = [15 x i8] c"\22 >\0A\0Areplaces\0A\00"
define void @parse_name(i8* nocapture %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %3
3: ; preds = %1, %7
%4 = phi i64 [ 0, %1 ], [ %10, %7 ]
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
switch i8 %6, label %7 [
i8 95, label %12
i8 46, label %26
]
7: ; preds = %3
%8 = sext i8 %6 to i32
%9 = tail call i32 @putchar(i32 %8)
%10 = add nuw nsw i64 %4, 1
%11 = icmp eq i64 %10, 256
br i1 %11, label %26, label %3
12: ; preds = %3
%13 = trunc i64 %4 to i32
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp ult i32 %13, 255
br i1 %15, label %16, label %26
16: ; preds = %12, %22
%17 = phi i64 [ %18, %22 ], [ %4, %12 ]
%18 = add nuw nsw i64 %17, 1
%19 = getelementptr inbounds i8, i8* %0, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 46
br i1 %21, label %26, label %22
22: ; preds = %16
%23 = sext i8 %20 to i32
%24 = tail call i32 @putchar(i32 %23)
%25 = icmp eq i64 %18, 255
br i1 %25, label %26, label %16
26: ; preds = %3, %7, %16, %22, %12
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
ret void
}