#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 atoi(char const *);
char const *parse_skip_whitespace(char const *);
int /*<<< orphan*/ strncmp(char const *, char *, int);
const char *parse_read_display_name(const char *str, unsigned int *mask) {
  if (!str || !mask) {
    return NULL;
  }
  str = parse_skip_whitespace(str);
  if (!strncmp(str, "CRT-", 4)) {
    *mask = 1 << (atoi(str + 4));
  } else if (!strncmp(str, "TV-", 3)) {
    *mask = (1 << (atoi(str + 3))) << 8;
  } else if (!strncmp(str, "DFP-", 4)) {
    *mask = (1 << (atoi(str + 4))) << 16;
  } else {
    return NULL;
  }
  while (*str && *str != ':') {
    str++;
  }
  if (*str == ':') {
    str++;
  }
  return parse_skip_whitespace(str);
}


x86 assembly (clang, -O0):
<parse_read_display_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1156 <parse_read_display_name+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    1163 <parse_read_display_name+0x33>
movq   $0x0,-0x8(%rbp)
jmp    12c4 <parse_read_display_name+0x194>
mov    -0x10(%rbp),%rdi
call   1040 <parse_skip_whitespace@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe85(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11b1 <parse_read_display_name+0x81>
mov    -0x10(%rbp),%rdi
add    $0x4,%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    1250 <parse_read_display_name+0x120>
mov    -0x10(%rbp),%rdi
lea    0xe49(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11f5 <parse_read_display_name+0xc5>
mov    -0x10(%rbp),%rdi
add    $0x3,%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,%ecx
shl    $0x8,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    124b <parse_read_display_name+0x11b>
mov    -0x10(%rbp),%rdi
lea    0xe09(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1239 <parse_read_display_name+0x109>
mov    -0x10(%rbp),%rdi
add    $0x4,%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,%ecx
shl    $0x10,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    1246 <parse_read_display_name+0x116>
movq   $0x0,-0x8(%rbp)
jmp    12c4 <parse_read_display_name+0x194>
jmp    124b <parse_read_display_name+0x11b>
jmp    1250 <parse_read_display_name+0x120>
jmp    1255 <parse_read_display_name+0x125>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     127a <parse_read_display_name+0x14a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    128a <parse_read_display_name+0x15a>
jmp    129b <parse_read_display_name+0x16b>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1255 <parse_read_display_name+0x125>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    12b7 <parse_read_display_name+0x187>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <parse_skip_whitespace@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_read_display_name>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     119a <parse_read_display_name+0x6a>
mov    %rsi,%r14
test   %rsi,%rsi
je     119a <parse_read_display_name+0x6a>
call   1040 <parse_skip_whitespace@plt>
mov    %rax,%rbx
lea    0xead(%rip),%rsi
mov    %rax,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
mov    $0x4,%r15d
test   %eax,%eax
je     11a7 <parse_read_display_name+0x77>
lea    0xe94(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11ae <parse_read_display_name+0x7e>
lea    0xe80(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11bb <parse_read_display_name+0x8b>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%ebp
jmp    11c0 <parse_read_display_name+0x90>
mov    $0x100,%ebp
mov    $0x3,%r15d
jmp    11c0 <parse_read_display_name+0x90>
mov    $0x10000,%ebp
mov    %rbx,%rdi
add    %r15,%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
shl    %cl,%ebp
mov    %ebp,(%r14)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rbx),%eax
test   %al,%al
je     11f1 <parse_read_display_name+0xc1>
cmp    $0x3a,%al
je     11f1 <parse_read_display_name+0xc1>
add    $0x1,%rbx
jmp    11e0 <parse_read_display_name+0xb0>
xor    %ecx,%ecx
cmp    $0x3a,%al
sete   %cl
add    %rcx,%rbx
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <parse_skip_whitespace@plt>

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

LLVM IR (-O2):
@.str = [5 x i8] c"CRT-\00"
@.str.1 = [4 x i8] c"TV-\00"
@.str.2 = [5 x i8] c"DFP-\00"
define i8* @parse_read_display_name(i8* %0, i32* writeonly %1) {
%3 = icmp ne i8* %0, null
%4 = icmp ne i32* %1, null
%5 = and i1 %3, %4
br i1 %5, label %6, label %32
6: ; preds = %2
%7 = tail call i8* @parse_skip_whitespace(i8* %0)
%8 = tail call i32 @strncmp(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%9 = icmp eq i32 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %6
%11 = tail call i32 @strncmp(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%12 = icmp eq i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = tail call i32 @strncmp(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %32
16: ; preds = %13, %10, %6
%17 = phi i64 [ 4, %6 ], [ 3, %10 ], [ 4, %13 ]
%18 = phi i32 [ 1, %6 ], [ 256, %10 ], [ 65536, %13 ]
%19 = getelementptr inbounds i8, i8* %7, i64 %17
%20 = tail call i32 @atoi(i8* %19)
%21 = shl i32 %18, %20
store i32 %21, i32* %1
br label %22
22: ; preds = %25, %16
%23 = phi i8* [ %7, %16 ], [ %26, %25 ]
%24 = load i8, i8* %23
switch i8 %24, label %25 [
i8 0, label %27
i8 58, label %27
]
25: ; preds = %22
%26 = getelementptr inbounds i8, i8* %23, i64 1
br label %22
27: ; preds = %22, %22
%28 = icmp eq i8 %24, 58
%29 = zext i1 %28 to i64
%30 = getelementptr i8, i8* %23, i64 %29
%31 = tail call i8* @parse_skip_whitespace(i8* %30)
br label %32
32: ; preds = %13, %2, %27
%33 = phi i8* [ %31, %27 ], [ null, %2 ], [ null, %13 ]
ret i8* %33
}