#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*/ fire();
int /*<<< orphan*/ load();
int /*<<< orphan*/ spin();
int /*<<< orphan*/ unload();
int method(const char *s) {
  unload();
  for (; *s != '\0'; s++) {
    switch (*s) {
    case 'L':
      load();
      break;
    case 'S':
      spin();
      break;
    case 'F':
      if (fire()) {
        return 1;
      }
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<method>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <unload@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ec <method+0xac>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
sub    $0x46,%eax
je     11b5 <method+0x75>
jmp    117b <method+0x3b>
mov    -0x14(%rbp),%eax
sub    $0x4c,%eax
je     119d <method+0x5d>
jmp    118c <method+0x4c>
mov    -0x14(%rbp),%eax
sub    $0x53,%eax
je     11a9 <method+0x69>
jmp    11d6 <method+0x96>
mov    $0x0,%al
call   1050 <load@plt>
jmp    11d6 <method+0x96>
mov    $0x0,%al
call   1060 <spin@plt>
jmp    11d6 <method+0x96>
mov    $0x0,%al
call   1030 <fire@plt>
cmp    $0x0,%eax
je     11d1 <method+0x91>
movl   $0x1,-0x4(%rbp)
jmp    11f3 <method+0xb3>
jmp    11d6 <method+0x96>
jmp    11db <method+0x9b>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1153 <method+0x13>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<method>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <unload@plt>
mov    (%rbx),%al
test   %al,%al
je     11a4 <method+0x64>
add    $0x1,%rbx
jmp    1172 <method+0x32>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <spin@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11a2 <method+0x62>
movsbl %al,%eax
cmp    $0x46,%eax
je     1190 <method+0x50>
cmp    $0x53,%eax
je     1160 <method+0x20>
cmp    $0x4c,%eax
jne    1167 <method+0x27>
xor    %eax,%eax
call   1050 <load@plt>
jmp    1167 <method+0x27>
nopl   (%rax)
xor    %eax,%eax
call   1030 <fire@plt>
test   %eax,%eax
je     1167 <method+0x27>
mov    $0x1,%ebp
jmp    11a4 <method+0x64>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @method(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = call i32 (...) @unload()
br label %5
5: ; preds = %24, %1
%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 %16
i32 70, label %18
]
14: ; preds = %10
%15 = call i32 (...) @load()
br label %23
16: ; preds = %10
%17 = call i32 (...) @spin()
br label %23
18: ; preds = %10
%19 = call i32 (...) @fire()
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %18
store i32 1, i32* %2
br label %28
22: ; preds = %18
br label %23
23: ; preds = %10, %22, %16, %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
store i32 0, i32* %2
br label %28
28: ; preds = %27, %21
%29 = load i32, i32* %2
ret i32 %29
}

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