#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*/ get_arg(char *, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
char *strapp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *alternate(char *pin, char *pout, char *w) {
  int which = 1;
  char font[250], font1[250], font2[250], ww[250], tmp[250];
  tmp[0] = '\0';
  switch (w[1]) {
  case 'R':
    strcpy(font1, "\\rm");
    break;
  case 'I':
    strcpy(font1, "\\it");
    break;
  case 'B':
    strcpy(font1, "\\bf");
    break;
  }
  switch (w[2]) {
  case 'R':
    strcpy(font2, "\\rm");
    break;
  case 'I':
    strcpy(font2, "\\it");
    break;
  case 'B':
    strcpy(font2, "\\bf");
    break;
  }
  strcpy(font, font1);
  while (*pin != '\n' && *pin != '\0') {
    pin += get_arg(pin, ww, 1);
    if (which == 1) {
      sprintf(tmp, "{%s %s}", font1, ww);
      which = 2;
    } else {
      sprintf(tmp, "{%s %s}", font2, ww);
      which = 1;
    }
    pout = strapp(pout, tmp);
    while (*pin == ' ' || *pin == '\t')
      pin++;
  }
  return (pout);
}


x86 assembly (clang, -O0):
<alternate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x530,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
movb   $0x0,-0x520(%rbp)
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x524(%rbp)
sub    $0x42,%eax
je     11d9 <alternate+0x99>
jmp    1181 <alternate+0x41>
mov    -0x524(%rbp),%eax
sub    $0x49,%eax
je     11c1 <alternate+0x81>
jmp    1195 <alternate+0x55>
mov    -0x524(%rbp),%eax
sub    $0x52,%eax
jne    11ec <alternate+0xac>
jmp    11a9 <alternate+0x69>
lea    -0x220(%rbp),%rdi
lea    0xe49(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11ec <alternate+0xac>
lea    -0x220(%rbp),%rdi
lea    0xe35(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11ec <alternate+0xac>
lea    -0x220(%rbp),%rdi
lea    0xe21(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
movsbl 0x2(%rax),%eax
mov    %eax,-0x528(%rbp)
sub    $0x42,%eax
je     1260 <alternate+0x120>
jmp    1208 <alternate+0xc8>
mov    -0x528(%rbp),%eax
sub    $0x49,%eax
je     1248 <alternate+0x108>
jmp    121c <alternate+0xdc>
mov    -0x528(%rbp),%eax
sub    $0x52,%eax
jne    1273 <alternate+0x133>
jmp    1230 <alternate+0xf0>
lea    -0x320(%rbp),%rdi
lea    0xdc2(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1273 <alternate+0x133>
lea    -0x320(%rbp),%rdi
lea    0xdae(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1273 <alternate+0x133>
lea    -0x320(%rbp),%rdi
lea    0xd9a(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x120(%rbp),%rdi
lea    -0x220(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x529(%rbp)
je     12b1 <alternate+0x171>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x529(%rbp)
mov    -0x529(%rbp),%al
test   $0x1,%al
jne    12c4 <alternate+0x184>
jmp    13b0 <alternate+0x270>
mov    -0x8(%rbp),%rdi
lea    -0x420(%rbp),%rsi
mov    $0x1,%edx
call   1040 <get_arg@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    1320 <alternate+0x1e0>
lea    -0x520(%rbp),%rdi
lea    -0x220(%rbp),%rdx
lea    -0x420(%rbp),%rcx
lea    0xcfd(%rip),%rsi
call   1060 <sprintf@plt>
movl   $0x2,-0x1c(%rbp)
jmp    1348 <alternate+0x208>
lea    -0x520(%rbp),%rdi
lea    -0x320(%rbp),%rdx
lea    -0x420(%rbp),%rcx
lea    0xcd0(%rip),%rsi
call   1060 <sprintf@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x520(%rbp),%rsi
call   1050 <strapp@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x52a(%rbp)
je     1387 <alternate+0x247>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x52a(%rbp)
mov    -0x52a(%rbp),%al
test   $0x1,%al
jne    139a <alternate+0x25a>
jmp    13ab <alternate+0x26b>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    135c <alternate+0x21c>
jmp    1286 <alternate+0x146>
mov    -0x10(%rbp),%rax
add    $0x530,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alternate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x508,%rsp
mov    %rdx,%rbp
mov    %rsi,%r14
mov    %rdi,%rbx
movb   $0x0,0x100(%rsp)
movsbl 0x1(%rdx),%eax
cmp    $0x42,%eax
je     117e <alternate+0x3e>
cmp    $0x52,%eax
je     1187 <alternate+0x47>
cmp    $0x49,%eax
jne    1196 <alternate+0x56>
lea    0xe88(%rip),%rsi
jmp    118e <alternate+0x4e>
lea    0xe83(%rip),%rsi
jmp    118e <alternate+0x4e>
lea    0xe72(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
movsbl 0x2(%rbp),%eax
cmp    $0x42,%eax
je     11b2 <alternate+0x72>
cmp    $0x52,%eax
je     11bb <alternate+0x7b>
cmp    $0x49,%eax
jne    11cf <alternate+0x8f>
lea    0xe54(%rip),%rsi
jmp    11c2 <alternate+0x82>
lea    0xe4f(%rip),%rsi
jmp    11c2 <alternate+0x82>
lea    0xe3e(%rip),%rsi
lea    0x200(%rsp),%rdi
call   1030 <strcpy@plt>
lea    0x400(%rsp),%rdi
mov    %rsp,%rsi
call   1030 <strcpy@plt>
mov    (%rbx),%al
mov    $0x1,%r15d
lea    0x300(%rsp),%r12
lea    0xe16(%rip),%r13
lea    0x100(%rsp),%rbp
xchg   %ax,%ax
test   %al,%al
je     1271 <alternate+0x131>
cmp    $0xa,%al
je     1271 <alternate+0x131>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x1,%edx
call   1040 <get_arg@plt>
cltq
add    %rax,%rbx
xor    %eax,%eax
cmp    $0x1,%r15d
sete   %al
lea    0x200(%rsp),%rdx
mov    %rsp,%rcx
cmove  %rcx,%rdx
mov    %eax,%r15d
add    $0x1,%r15d
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %r12,%rcx
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1050 <strapp@plt>
mov    %rax,%r14
jmp    1264 <alternate+0x124>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x20,%al
je     1260 <alternate+0x120>
cmp    $0x9,%al
je     1260 <alternate+0x120>
jmp    1200 <alternate+0xc0>
mov    %r14,%rax
add    $0x508,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"\\rm\00"
@.str.1 = [4 x i8] c"\\it\00"
@.str.2 = [4 x i8] c"\\bf\00"
@.str.3 = [8 x i8] c"{%s %s}\00"
define i8* @alternate(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca [250 x i8]
%9 = alloca [250 x i8]
%10 = alloca [250 x i8]
%11 = alloca [250 x i8]
%12 = alloca [250 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 1, i32* %7
%13 = getelementptr inbounds [250 x i8], [250 x i8]* %12, i64 0, i64 0
store i8 0, i8* %13
%14 = load i8*, i8** %6
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
switch i32 %17, label %27 [
i32 82, label %18
i32 73, label %21
i32 66, label %24
]
18: ; preds = %3
%19 = getelementptr inbounds [250 x i8], [250 x i8]* %9, i64 0, i64 0
%20 = call i32 @strcpy(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %27
21: ; preds = %3
%22 = getelementptr inbounds [250 x i8], [250 x i8]* %9, i64 0, i64 0
%23 = call i32 @strcpy(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %27
24: ; preds = %3
%25 = getelementptr inbounds [250 x i8], [250 x i8]* %9, i64 0, i64 0
%26 = call i32 @strcpy(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %27
27: ; preds = %3, %24, %21, %18
%28 = load i8*, i8** %6
%29 = getelementptr inbounds i8, i8* %28, i64 2
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
switch i32 %31, label %41 [
i32 82, label %32
i32 73, label %35
i32 66, label %38
]
32: ; preds = %27
%33 = getelementptr inbounds [250 x i8], [250 x i8]* %10, i64 0, i64 0
%34 = call i32 @strcpy(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %41
35: ; preds = %27
%36 = getelementptr inbounds [250 x i8], [250 x i8]* %10, i64 0, i64 0
%37 = call i32 @strcpy(i8* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %41
38: ; preds = %27
%39 = getelementptr inbounds [250 x i8], [250 x i8]* %10, i64 0, i64 0
%40 = call i32 @strcpy(i8* %39, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %41
41: ; preds = %27, %38, %35, %32
%42 = getelementptr inbounds [250 x i8], [250 x i8]* %8, i64 0, i64 0
%43 = getelementptr inbounds [250 x i8], [250 x i8]* %9, i64 0, i64 0
%44 = call i32 @strcpy(i8* %42, i8* %43)
br label %45
45: ; preds = %95, %41
%46 = load i8*, i8** %4
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp ne i32 %48, 10
br i1 %49, label %50, label %55
50: ; preds = %45
%51 = load i8*, i8** %4
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp ne i32 %53, 0
br label %55
55: ; preds = %50, %45
%56 = phi i1 [ false, %45 ], [ %54, %50 ]
br i1 %56, label %57, label %96
57: ; preds = %55
%58 = load i8*, i8** %4
%59 = getelementptr inbounds [250 x i8], [250 x i8]* %11, i64 0, i64 0
%60 = call i32 @get_arg(i8* %58, i8* %59, i32 1)
%61 = load i8*, i8** %4
%62 = sext i32 %60 to i64
%63 = getelementptr inbounds i8, i8* %61, i64 %62
store i8* %63, i8** %4
%64 = load i32, i32* %7
%65 = icmp eq i32 %64, 1
br i1 %65, label %66, label %71
66: ; preds = %57
%67 = getelementptr inbounds [250 x i8], [250 x i8]* %12, i64 0, i64 0
%68 = getelementptr inbounds [250 x i8], [250 x i8]* %9, i64 0, i64 0
%69 = getelementptr inbounds [250 x i8], [250 x i8]* %11, i64 0, i64 0
%70 = call i32 @sprintf(i8* %67, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %68, i8* %69)
store i32 2, i32* %7
br label %76
71: ; preds = %57
%72 = getelementptr inbounds [250 x i8], [250 x i8]* %12, i64 0, i64 0
%73 = getelementptr inbounds [250 x i8], [250 x i8]* %10, i64 0, i64 0
%74 = getelementptr inbounds [250 x i8], [250 x i8]* %11, i64 0, i64 0
%75 = call i32 @sprintf(i8* %72, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %73, i8* %74)
store i32 1, i32* %7
br label %76
76: ; preds = %71, %66
%77 = load i8*, i8** %5
%78 = getelementptr inbounds [250 x i8], [250 x i8]* %12, i64 0, i64 0
%79 = call i8* @strapp(i8* %77, i8* %78)
store i8* %79, i8** %5
br label %80
80: ; preds = %92, %76
%81 = load i8*, i8** %4
%82 = load i8, i8* %81
%83 = sext i8 %82 to i32
%84 = icmp eq i32 %83, 32
br i1 %84, label %90, label %85
85: ; preds = %80
%86 = load i8*, i8** %4
%87 = load i8, i8* %86
%88 = sext i8 %87 to i32
%89 = icmp eq i32 %88, 9
br label %90
90: ; preds = %85, %80
%91 = phi i1 [ true, %80 ], [ %89, %85 ]
br i1 %91, label %92, label %95
92: ; preds = %90
%93 = load i8*, i8** %4
%94 = getelementptr inbounds i8, i8* %93, i32 1
store i8* %94, i8** %4
br label %80
95: ; preds = %90
br label %45
96: ; preds = %55
%97 = load i8*, i8** %5
ret i8* %97
}

LLVM IR (-O2):
@.str = [4 x i8] c"\\rm\00"
@.str.1 = [4 x i8] c"\\it\00"
@.str.2 = [4 x i8] c"\\bf\00"
@.str.3 = [8 x i8] c"{%s %s}\00"
define i8* @alternate(i8* %0, i8* %1, i8* nocapture %2) {
%4 = alloca [250 x i8]
%5 = alloca [250 x i8]
%6 = alloca [250 x i8]
%7 = alloca [250 x i8]
%8 = alloca [250 x i8]
%9 = getelementptr inbounds [250 x i8], [250 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [250 x i8], [250 x i8]* %5, i64 0, i64 0
%11 = getelementptr inbounds [250 x i8], [250 x i8]* %6, i64 0, i64 0
%12 = getelementptr inbounds [250 x i8], [250 x i8]* %7, i64 0, i64 0
%13 = getelementptr inbounds [250 x i8], [250 x i8]* %8, i64 0, i64 0
store i8 0, i8* %13
%14 = getelementptr inbounds i8, i8* %2, i64 1
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
switch i32 %16, label %22 [
i32 82, label %19
i32 73, label %17
i32 66, label %18
]
17: ; preds = %3
br label %19
18: ; preds = %3
br label %19
19: ; preds = %3, %17, %18
%20 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), %18 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %17 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %3 ]
%21 = call i32 @strcpy(i8* %10, i8* %20)
br label %22
22: ; preds = %19, %3
%23 = getelementptr inbounds i8, i8* %2, i64 2
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
switch i32 %25, label %31 [
i32 82, label %28
i32 73, label %26
i32 66, label %27
]
26: ; preds = %22
br label %28
27: ; preds = %22
br label %28
28: ; preds = %22, %26, %27
%29 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), %27 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %26 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %22 ]
%30 = call i32 @strcpy(i8* %11, i8* %29)
br label %31
31: ; preds = %28, %22
%32 = call i32 @strcpy(i8* %9, i8* %10)
%33 = load i8, i8* %0
br label %34
34: ; preds = %48, %31
%35 = phi i8 [ %33, %31 ], [ %50, %48 ]
%36 = phi i8* [ %1, %31 ], [ %47, %48 ]
%37 = phi i8* [ %0, %31 ], [ %49, %48 ]
%38 = phi i32 [ 1, %31 ], [ %45, %48 ]
switch i8 %35, label %39 [
i8 10, label %53
i8 0, label %53
]
39: ; preds = %34
%40 = call i32 @get_arg(i8* %37, i8* %12, i32 1)
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %37, i64 %41
%43 = icmp eq i32 %38, 1
%44 = select i1 %43, i8* %10, i8* %11
%45 = select i1 %43, i32 2, i32 1
%46 = call i32 @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %44, i8* %12)
%47 = call i8* @strapp(i8* %36, i8* %13)
br label %48
48: ; preds = %51, %39
%49 = phi i8* [ %42, %39 ], [ %52, %51 ]
%50 = load i8, i8* %49
switch i8 %50, label %34 [
i8 32, label %51
i8 9, label %51
]
51: ; preds = %48, %48
%52 = getelementptr inbounds i8, i8* %49, i64 1
br label %48
53: ; preds = %34, %34
ret i8* %36
}