#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 TexFontNumber(char *);
int /*<<< orphan*/ diagnostics(int /*<<< orphan*/, char *, char *, char **);
int /*<<< orphan*/ fprintRTF(char *, ...);
int /*<<< orphan*/ free(char *);
char *my_strdup(char *);
char *strchr(char *, char);
int /*<<< orphan*/ strlen(char *);
void WriteCFGFontNumber(char **cfg_stream) {
  int n = -1;
  char *font_name, *star;
  *cfg_stream += 1;
  if (**cfg_stream == '*') {
    fprintRTF("*");
    return;
  }
  font_name = my_strdup(*cfg_stream);
  star = strchr(font_name, '*');
  if (star) {
    *star = '\0';
    n = TexFontNumber(font_name);
    if (n < 0)
      diagnostics(0, "Unknown font <%s>\nFound in cfg line <%s>", font_name,
                  cfg_stream);
    *cfg_stream += strlen(font_name);
    fprintRTF("%d", n);
  }
  free(font_name);
}


x86 assembly (clang, -O0):
<WriteCFGFontNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
jne    11b7 <WriteCFGFontNumber+0x47>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1090 <fprintRTF@plt>
jmp    124c <WriteCFGFontNumber+0xdc>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1080 <my_strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x2a,%esi
call   1060 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1243 <WriteCFGFontNumber+0xd3>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
call   1040 <TexFontNumber@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1217 <WriteCFGFontNumber+0xa7>
mov    -0x18(%rbp),%rdx
mov    -0x8(%rbp),%rcx
xor    %edi,%edi
lea    0xdf0(%rip),%rsi
call   1070 <diagnostics@plt>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
movslq %edx,%rdx
add    %rdx,%rcx
mov    %rcx,(%rax)
mov    -0xc(%rbp),%esi
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1090 <fprintRTF@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WriteCFGFontNumber>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%rax
lea    0x1(%rax),%rdi
mov    %rdi,(%rbx)
cmpb   $0x2a,0x1(%rax)
jne    1199 <WriteCFGFontNumber+0x29>
lea    0xe72(%rip),%rdi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1090 <fprintRTF@plt>
call   1080 <my_strdup@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    $0x2a,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     11f5 <WriteCFGFontNumber+0x85>
movb   $0x0,(%rax)
mov    %r14,%rdi
call   1040 <TexFontNumber@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    11d8 <WriteCFGFontNumber+0x68>
lea    0xe37(%rip),%rsi
xor    %edi,%edi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1070 <diagnostics@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
add    %rax,(%rbx)
lea    0xe3f(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1090 <fprintRTF@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"*\00"
@.str.1 = [41 x i8] c"Unknown font <%s>\0AFound in cfg line <%s>\00"
@.str.2 = [3 x i8] c"%d\00"
define void @WriteCFGFontNumber(i8** %0) {
%2 = alloca i8**
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8** %0, i8*** %2
store i32 -1, i32* %3
%6 = load i8**, i8*** %2
%7 = load i8*, i8** %6
%8 = getelementptr inbounds i8, i8* %7, i64 1
store i8* %8, i8** %6
%9 = load i8**, i8*** %2
%10 = load i8*, i8** %9
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 42
br i1 %13, label %14, label %16
14: ; preds = %1
%15 = call i32 (i8*, ...) @fprintRTF(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %46
16: ; preds = %1
%17 = load i8**, i8*** %2
%18 = load i8*, i8** %17
%19 = call i8* @my_strdup(i8* %18)
store i8* %19, i8** %4
%20 = load i8*, i8** %4
%21 = call i8* @strchr(i8* %20, i8 signext 42)
store i8* %21, i8** %5
%22 = load i8*, i8** %5
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %43
24: ; preds = %16
%25 = load i8*, i8** %5
store i8 0, i8* %25
%26 = load i8*, i8** %4
%27 = call i32 @TexFontNumber(i8* %26)
store i32 %27, i32* %3
%28 = load i32, i32* %3
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %24
%31 = load i8*, i8** %4
%32 = load i8**, i8*** %2
%33 = call i32 @diagnostics(i32 0, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %31, i8** %32)
br label %34
34: ; preds = %30, %24
%35 = load i8*, i8** %4
%36 = call i32 @strlen(i8* %35)
%37 = load i8**, i8*** %2
%38 = load i8*, i8** %37
%39 = sext i32 %36 to i64
%40 = getelementptr inbounds i8, i8* %38, i64 %39
store i8* %40, i8** %37
%41 = load i32, i32* %3
%42 = call i32 (i8*, ...) @fprintRTF(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %34, %16
%44 = load i8*, i8** %4
%45 = call i32 @free(i8* %44)
br label %46
46: ; preds = %43, %14
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"*\00"
@.str.1 = [41 x i8] c"Unknown font <%s>\0AFound in cfg line <%s>\00"
@.str.2 = [3 x i8] c"%d\00"
define void @WriteCFGFontNumber(i8** %0) {
%2 = load i8*, i8** %0
%3 = getelementptr inbounds i8, i8* %2, i64 1
store i8* %3, i8** %0
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 42
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 (i8*, ...) @fprintRTF(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %25
8: ; preds = %1
%9 = tail call i8* @my_strdup(i8* %3)
%10 = tail call i8* @strchr(i8* dereferenceable(1) %9, i8 signext 42)
%11 = icmp eq i8* %10, null
br i1 %11, label %23, label %12
12: ; preds = %8
store i8 0, i8* %10
%13 = tail call i32 @TexFontNumber(i8* %9)
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call i32 @diagnostics(i32 0, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %9, i8** %0)
br label %17
17: ; preds = %15, %12
%18 = tail call i32 @strlen(i8* %9)
%19 = load i8*, i8** %0
%20 = sext i32 %18 to i64
%21 = getelementptr inbounds i8, i8* %19, i64 %20
store i8* %21, i8** %0
%22 = tail call i32 (i8*, ...) @fprintRTF(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %13)
br label %23
23: ; preds = %17, %8
%24 = tail call i32 @free(i8* %9)
br label %25
25: ; preds = %23, %6
ret void
}