#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*/ append(char *, char *);
void mstring(const char *s, char *out) {
  for (; *s != '\0'; s++) {
    switch (*s) {
    case 'L':
      append(out, "load");
      break;
    case 'S':
      append(out, "spin");
      break;
    case 'F':
      append(out, "fire");
      break;
    }
  }
}


x86 assembly (clang, -O0):
<mstring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ba <mstring+0xaa>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
sub    $0x46,%eax
je     1194 <mstring+0x84>
jmp    1148 <mstring+0x38>
mov    -0x14(%rbp),%eax
sub    $0x4c,%eax
je     116a <mstring+0x5a>
jmp    1159 <mstring+0x49>
mov    -0x14(%rbp),%eax
sub    $0x53,%eax
je     117f <mstring+0x6f>
jmp    11a4 <mstring+0x94>
mov    -0x10(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1030 <append@plt>
jmp    11a4 <mstring+0x94>
mov    -0x10(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1030 <append@plt>
jmp    11a4 <mstring+0x94>
mov    -0x10(%rbp),%rdi
lea    0xe6b(%rip),%rsi
call   1030 <append@plt>
jmp    11a9 <mstring+0x99>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1120 <mstring+0x10>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mstring>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     1170 <mstring+0x60>
mov    %rsi,%r14
mov    %rdi,%rbx
add    $0x1,%rbx
lea    0xed0(%rip),%r15
lea    0xed3(%rip),%r12
lea    0xec7(%rip),%r13
jmp    1156 <mstring+0x46>
mov    %r12,%rsi
mov    %r14,%rdi
call   1030 <append@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1170 <mstring+0x60>
movsbl %al,%eax
cmp    $0x46,%eax
je     1140 <mstring+0x30>
mov    %r15,%rsi
cmp    $0x4c,%eax
je     1143 <mstring+0x33>
cmp    $0x53,%eax
jne    114b <mstring+0x3b>
mov    %r13,%rsi
jmp    1143 <mstring+0x33>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"load\00"
@.str.1 = [5 x i8] c"spin\00"
@.str.2 = [5 x i8] c"fire\00"
define void @mstring(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
br label %5
5: ; preds = %24, %2
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %27
10: ; preds = %5
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
switch i32 %13, label %23 [
i32 76, label %14
i32 83, label %17
i32 70, label %20
]
14: ; preds = %10
%15 = load i8*, i8** %4
%16 = call i32 @append(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %23
17: ; preds = %10
%18 = load i8*, i8** %4
%19 = call i32 @append(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %23
20: ; preds = %10
%21 = load i8*, i8** %4
%22 = call i32 @append(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %10, %20, %17, %14
br label %24
24: ; preds = %23
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %3
br label %5
27: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"load\00"
@.str.1 = [5 x i8] c"spin\00"
@.str.2 = [5 x i8] c"fire\00"
define void @mstring(i8* nocapture %0, i8* %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %18, label %5
5: ; preds = %2, %14
%6 = phi i8 [ %16, %14 ], [ %3, %2 ]
%7 = phi i8* [ %15, %14 ], [ %0, %2 ]
%8 = sext i8 %6 to i32
switch i32 %8, label %14 [
i32 76, label %11
i32 83, label %9
i32 70, label %10
]
9: ; preds = %5
br label %11
10: ; preds = %5
br label %11
11: ; preds = %5, %10, %9
%12 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %9 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %10 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %5 ]
%13 = tail call i32 @append(i8* %1, i8* %12)
br label %14
14: ; preds = %11, %5
%15 = getelementptr inbounds i8, i8* %7, i64 1
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %5
18: ; preds = %14, %2
ret void
}