#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*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
void parse_font_name(char *res, char *font, int *bold, int *italic) {
  char *fontSave = res;
  *bold = *italic = 0;
  while (*font)
    if (*font == ' ' && !strncmp(font, " Bold", 5) &&
        (!font[5] || font[5] == ' ')) {
      *bold = 1;
      font += 5;
    } else if (*font == ' ' && !strncmp(font, " Italic", 7) &&
               (!font[7] || font[7] == ' ')) {
      *italic = 1;
      font += 7;
    } else
      *res++ = *font++;
  *res = '\0';
  if (!strcmp(fontSave, "MS Sans Serif"))
    strcpy(fontSave, "Microsoft Sans Serif");
}


x86 assembly (clang, -O0):
<parse_font_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     126d <parse_font_name+0x13d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    11d9 <parse_font_name+0xa9>
mov    -0x10(%rbp),%rdi
lea    0xe74(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11d9 <parse_font_name+0xa9>
mov    -0x10(%rbp),%rax
cmpb   $0x0,0x5(%rax)
je     11be <parse_font_name+0x8e>
mov    -0x10(%rbp),%rax
movsbl 0x5(%rax),%eax
cmp    $0x20,%eax
jne    11d9 <parse_font_name+0xa9>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x10(%rbp)
jmp    1268 <parse_font_name+0x138>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1241 <parse_font_name+0x111>
mov    -0x10(%rbp),%rdi
lea    0xe12(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1241 <parse_font_name+0x111>
mov    -0x10(%rbp),%rax
cmpb   $0x0,0x7(%rax)
je     1226 <parse_font_name+0xf6>
mov    -0x10(%rbp),%rax
movsbl 0x7(%rax),%eax
cmp    $0x20,%eax
jne    1241 <parse_font_name+0x111>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
add    $0x7,%rax
mov    %rax,-0x10(%rbp)
jmp    1263 <parse_font_name+0x133>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    1268 <parse_font_name+0x138>
jmp    1164 <parse_font_name+0x34>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
lea    0xd8f(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    129d <parse_font_name+0x16d>
mov    -0x28(%rbp),%rdi
lea    0xd84(%rip),%rsi
call   1040 <strcpy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_font_name>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r12
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
movl   $0x0,(%rcx)
movl   $0x0,(%rdx)
lea    0xea6(%rip),%r13
lea    0xea5(%rip),%rbp
mov    %rdi,(%rsp)
jmp    1181 <parse_font_name+0x51>
nopw   0x0(%rax,%rax,1)
testb  $0xdf,0x5(%rbx)
jne    119c <parse_font_name+0x6c>
add    $0x5,%rbx
movl   $0x1,(%r15)
movzbl (%rbx),%eax
cmp    $0x20,%al
jne    11c9 <parse_font_name+0x99>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1170 <parse_font_name+0x40>
cmpb   $0x20,(%rbx)
jne    11cd <parse_font_name+0x9d>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    11cd <parse_font_name+0x9d>
testb  $0xdf,0x7(%rbx)
jne    11cd <parse_font_name+0x9d>
add    $0x7,%rbx
movl   $0x1,(%r12)
jmp    1181 <parse_font_name+0x51>
test   %al,%al
je     11dd <parse_font_name+0xad>
movzbl (%rbx),%eax
add    $0x1,%rbx
mov    %al,(%r14)
add    $0x1,%r14
jmp    1181 <parse_font_name+0x51>
movb   $0x0,(%r14)
lea    0xe26(%rip),%rsi
mov    (%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1207 <parse_font_name+0xd7>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe0e(%rip),%rsi
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <strcpy@plt>

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

LLVM IR (-O2):
@.str = [6 x i8] c" Bold\00"
@.str.1 = [8 x i8] c" Italic\00"
@.str.2 = [14 x i8] c"MS Sans Serif\00"
@.str.3 = [21 x i8] c"Microsoft Sans Serif\00"
define void @parse_font_name(i8* %0, i8* %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3) {
store i32 0, i32* %3
store i32 0, i32* %2
br label %5
5: ; preds = %30, %4
%6 = phi i8* [ %31, %30 ], [ %1, %4 ]
%7 = phi i8* [ %33, %30 ], [ %0, %4 ]
br label %8
8: ; preds = %28, %5
%9 = phi i8* [ %6, %5 ], [ %29, %28 ]
%10 = load i8, i8* %9
switch i8 %10, label %30 [
i8 0, label %34
i8 32, label %11
]
11: ; preds = %8
%12 = tail call i32 @strncmp(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = getelementptr inbounds i8, i8* %9, i64 5
%16 = load i8, i8* %15
switch i8 %16, label %18 [
i8 0, label %17
i8 32, label %17
]
17: ; preds = %14, %14
store i32 1, i32* %2
br label %28
18: ; preds = %14, %11
%19 = load i8, i8* %9
%20 = icmp eq i8 %19, 32
br i1 %20, label %21, label %30
21: ; preds = %18
%22 = tail call i32 @strncmp(i8* %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %21
%25 = getelementptr inbounds i8, i8* %9, i64 7
%26 = load i8, i8* %25
switch i8 %26, label %30 [
i8 0, label %27
i8 32, label %27
]
27: ; preds = %24, %24
store i32 1, i32* %3
br label %28
28: ; preds = %27, %17
%29 = phi i8* [ %25, %27 ], [ %15, %17 ]
br label %8
30: ; preds = %8, %24, %21, %18
%31 = getelementptr inbounds i8, i8* %9, i64 1
%32 = load i8, i8* %9
%33 = getelementptr inbounds i8, i8* %7, i64 1
store i8 %32, i8* %7
br label %5
34: ; preds = %8
store i8 0, i8* %7
%35 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(14) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %39
39: ; preds = %37, %34
ret void
}