char *get_monitor_name(unsigned char *block) {
  unsigned char *ptr = block + 5;
  static char name[13];
  unsigned i;
  for (i = 0; i < 13; i++, ptr++) {
    if (*ptr == 0xa) {
      name[i] = 0;
      return name;
    }
    name[i] = *ptr;
  }
  return name;
}


x86 assembly (clang, -O0):
<get_monitor_name>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0xd,-0x1c(%rbp)
jae    1184 <get_monitor_name+0x84>
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
cmp    $0xa,%eax
jne    1155 <get_monitor_name+0x55>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
lea    0x2ee0(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2ed5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    118f <get_monitor_name+0x8f>
mov    -0x18(%rbp),%rax
mov    (%rax),%dl
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
lea    0x2eba(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    111b <get_monitor_name+0x1b>
lea    0x2e96(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_monitor_name>:
mov    0x5(%rdi),%al
cmp    $0xa,%al
jne    110e <get_monitor_name+0xe>
xor    %eax,%eax
jmp    1206 <get_monitor_name+0x106>
mov    %al,0x2f0d(%rip)
mov    0x6(%rdi),%cl
mov    $0x1,%eax
cmp    $0xa,%cl
je     1206 <get_monitor_name+0x106>
mov    %cl,0x2ef7(%rip)
mov    0x7(%rdi),%cl
mov    $0x2,%eax
cmp    $0xa,%cl
je     1206 <get_monitor_name+0x106>
mov    %cl,0x2ee1(%rip)
mov    0x8(%rdi),%cl
mov    $0x3,%eax
cmp    $0xa,%cl
je     1206 <get_monitor_name+0x106>
mov    %cl,0x2ecb(%rip)
mov    0x9(%rdi),%cl
mov    $0x4,%eax
cmp    $0xa,%cl
je     1206 <get_monitor_name+0x106>
mov    %cl,0x2eb5(%rip)
mov    0xa(%rdi),%cl
mov    $0x5,%eax
cmp    $0xa,%cl
je     1206 <get_monitor_name+0x106>
mov    %cl,0x2e9f(%rip)
mov    0xb(%rdi),%cl
mov    $0x6,%eax
cmp    $0xa,%cl
je     1206 <get_monitor_name+0x106>
mov    %cl,0x2e8d(%rip)
mov    0xc(%rdi),%cl
mov    $0x7,%eax
cmp    $0xa,%cl
je     1206 <get_monitor_name+0x106>
mov    %cl,0x2e7b(%rip)
mov    0xd(%rdi),%cl
mov    $0x8,%eax
cmp    $0xa,%cl
je     1206 <get_monitor_name+0x106>
mov    %cl,0x2e69(%rip)
mov    0xe(%rdi),%cl
mov    $0x9,%eax
cmp    $0xa,%cl
je     1206 <get_monitor_name+0x106>
mov    %cl,0x2e57(%rip)
mov    0xf(%rdi),%cl
mov    $0xa,%eax
cmp    $0xa,%cl
je     1206 <get_monitor_name+0x106>
mov    %cl,0x2e45(%rip)
mov    0x10(%rdi),%cl
mov    $0xb,%eax
cmp    $0xa,%cl
je     1206 <get_monitor_name+0x106>
mov    %cl,0x2e33(%rip)
mov    0x11(%rdi),%cl
mov    $0xc,%eax
cmp    $0xa,%cl
jne    1219 <get_monitor_name+0x119>
lea    0x2e14(%rip),%rcx
movb   $0x0,(%rax,%rcx,1)
lea    0x2e09(%rip),%rax
ret
mov    %cl,0x2e0e(%rip)
lea    0x2dfb(%rip),%rax
ret

LLVM IR (-O0):
@get_monitor_name.name = internal global [13 x i8] zeroinitializer
define i8* @get_monitor_name(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i64 5
store i8* %7, i8** %4
store i32 0, i32* %5
br label %8
8: ; preds = %26, %1
%9 = load i32, i32* %5
%10 = icmp ult i32 %9, 13
br i1 %10, label %11, label %31
11: ; preds = %8
%12 = load i8*, i8** %4
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = icmp eq i32 %14, 10
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = load i32, i32* %5
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds [13 x i8], [13 x i8]* @get_monitor_name.name, i64 0, i64 %18
store i8 0, i8* %19
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @get_monitor_name.name, i64 0, i64 0), i8** %2
br label %32
20: ; preds = %11
%21 = load i8*, i8** %4
%22 = load i8, i8* %21
%23 = load i32, i32* %5
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds [13 x i8], [13 x i8]* @get_monitor_name.name, i64 0, i64 %24
store i8 %22, i8* %25
br label %26
26: ; preds = %20
%27 = load i32, i32* %5
%28 = add i32 %27, 1
store i32 %28, i32* %5
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %4
br label %8
31: ; preds = %8
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @get_monitor_name.name, i64 0, i64 0), i8** %2
br label %32
32: ; preds = %31, %16
%33 = load i8*, i8** %2
ret i8* %33
}

LLVM IR (-O2):
@get_monitor_name.name = internal global [13 x i8] zeroinitializer
define i8* @get_monitor_name(i8* nocapture %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 5
%3 = load i8, i8* %2
%4 = icmp eq i8 %3, 10
br i1 %4, label %5, label %8
5: ; preds = %52, %48, %44, %40, %36, %32, %28, %24, %20, %16, %12, %8, %1
%6 = phi i64 [ 0, %1 ], [ 1, %8 ], [ 2, %12 ], [ 3, %16 ], [ 4, %20 ], [ 5, %24 ], [ 6, %28 ], [ 7, %32 ], [ 8, %36 ], [ 9, %40 ], [ 10, %44 ], [ 11, %48 ], [ 12, %52 ]
%7 = getelementptr inbounds [13 x i8], [13 x i8]* @get_monitor_name.name, i64 0, i64 %6
store i8 0, i8* %7
br label %57
8: ; preds = %1
store i8 %3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @get_monitor_name.name, i64 0, i64 0)
%9 = getelementptr inbounds i8, i8* %0, i64 6
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 10
br i1 %11, label %5, label %12
12: ; preds = %8
store i8 %10, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @get_monitor_name.name, i64 0, i64 1)
%13 = getelementptr inbounds i8, i8* %0, i64 7
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 10
br i1 %15, label %5, label %16
16: ; preds = %12
store i8 %14, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @get_monitor_name.name, i64 0, i64 2)
%17 = getelementptr inbounds i8, i8* %0, i64 8
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 10
br i1 %19, label %5, label %20
20: ; preds = %16
store i8 %18, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @get_monitor_name.name, i64 0, i64 3)
%21 = getelementptr inbounds i8, i8* %0, i64 9
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 10
br i1 %23, label %5, label %24
24: ; preds = %20
store i8 %22, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @get_monitor_name.name, i64 0, i64 4)
%25 = getelementptr inbounds i8, i8* %0, i64 10
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 10
br i1 %27, label %5, label %28
28: ; preds = %24
store i8 %26, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @get_monitor_name.name, i64 0, i64 5)
%29 = getelementptr inbounds i8, i8* %0, i64 11
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 10
br i1 %31, label %5, label %32
32: ; preds = %28
store i8 %30, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @get_monitor_name.name, i64 0, i64 6)
%33 = getelementptr inbounds i8, i8* %0, i64 12
%34 = load i8, i8* %33
%35 = icmp eq i8 %34, 10
br i1 %35, label %5, label %36
36: ; preds = %32
store i8 %34, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @get_monitor_name.name, i64 0, i64 7)
%37 = getelementptr inbounds i8, i8* %0, i64 13
%38 = load i8, i8* %37
%39 = icmp eq i8 %38, 10
br i1 %39, label %5, label %40
40: ; preds = %36
store i8 %38, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @get_monitor_name.name, i64 0, i64 8)
%41 = getelementptr inbounds i8, i8* %0, i64 14
%42 = load i8, i8* %41
%43 = icmp eq i8 %42, 10
br i1 %43, label %5, label %44
44: ; preds = %40
store i8 %42, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @get_monitor_name.name, i64 0, i64 9)
%45 = getelementptr inbounds i8, i8* %0, i64 15
%46 = load i8, i8* %45
%47 = icmp eq i8 %46, 10
br i1 %47, label %5, label %48
48: ; preds = %44
store i8 %46, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @get_monitor_name.name, i64 0, i64 10)
%49 = getelementptr inbounds i8, i8* %0, i64 16
%50 = load i8, i8* %49
%51 = icmp eq i8 %50, 10
br i1 %51, label %5, label %52
52: ; preds = %48
store i8 %50, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @get_monitor_name.name, i64 0, i64 11)
%53 = getelementptr inbounds i8, i8* %0, i64 17
%54 = load i8, i8* %53
%55 = icmp eq i8 %54, 10
br i1 %55, label %5, label %56
56: ; preds = %52
store i8 %54, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @get_monitor_name.name, i64 0, i64 12)
br label %57
57: ; preds = %56, %5
ret i8* getelementptr inbounds ([13 x i8], [13 x i8]* @get_monitor_name.name, i64 0, i64 0)
}