#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 */
char *strstr(char *, char *);
int process_floppy_command(char *cmd) {
  if (strstr(cmd, "structure") == cmd) {
    return 3;
  }
  if (strstr(cmd, "showsector") == cmd) {
    return 4;
  }
  if (strstr(cmd, "traverse") == cmd) {
    return 5;
  }
  if (strstr(cmd, "showfat") == cmd) {
    return 6;
  }
  if (strstr(cmd, "showfile") == cmd) {
    return 7;
  }
  return 0;
}


x86 assembly (clang, -O0):
<process_floppy_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed9(%rip),%rsi
call   1030 <strstr@plt>
cmp    -0x10(%rbp),%rax
jne    1142 <process_floppy_command+0x32>
movl   $0x3,-0x4(%rbp)
jmp    11e1 <process_floppy_command+0xd1>
mov    -0x10(%rbp),%rdi
lea    0xebd(%rip),%rsi
call   1030 <strstr@plt>
cmp    -0x10(%rbp),%rax
jne    1168 <process_floppy_command+0x58>
movl   $0x4,-0x4(%rbp)
jmp    11e1 <process_floppy_command+0xd1>
mov    -0x10(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1030 <strstr@plt>
cmp    -0x10(%rbp),%rax
jne    118e <process_floppy_command+0x7e>
movl   $0x5,-0x4(%rbp)
jmp    11e1 <process_floppy_command+0xd1>
mov    -0x10(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1030 <strstr@plt>
cmp    -0x10(%rbp),%rax
jne    11b4 <process_floppy_command+0xa4>
movl   $0x6,-0x4(%rbp)
jmp    11e1 <process_floppy_command+0xd1>
mov    -0x10(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1030 <strstr@plt>
cmp    -0x10(%rbp),%rax
jne    11da <process_floppy_command+0xca>
movl   $0x7,-0x4(%rbp)
jmp    11e1 <process_floppy_command+0xd1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_floppy_command>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rsi
mov    $0x9,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1193 <process_floppy_command+0x83>
lea    0xeda(%rip),%rsi
mov    $0xa,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     119a <process_floppy_command+0x8a>
lea    0xecd(%rip),%rsi
mov    $0x8,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     11a1 <process_floppy_command+0x91>
lea    0xebe(%rip),%rsi
mov    $0x7,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     11a8 <process_floppy_command+0x98>
lea    0xeae(%rip),%rsi
mov    $0x8,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
xor    %ecx,%ecx
test   %eax,%eax
mov    $0x7,%eax
cmovne %ecx,%eax
pop    %rbx
ret
mov    $0x3,%eax
pop    %rbx
ret
mov    $0x4,%eax
pop    %rbx
ret
mov    $0x5,%eax
pop    %rbx
ret
mov    $0x6,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"structure\00"
@.str.1 = [11 x i8] c"showsector\00"
@.str.2 = [9 x i8] c"traverse\00"
@.str.3 = [8 x i8] c"showfat\00"
@.str.4 = [9 x i8] c"showfile\00"
define i32 @process_floppy_command(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i8* @strstr(i8* %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%6 = load i8*, i8** %3
%7 = icmp eq i8* %5, %6
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 3, i32* %2
br label %34
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i8* @strstr(i8* %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%12 = load i8*, i8** %3
%13 = icmp eq i8* %11, %12
br i1 %13, label %14, label %15
14: ; preds = %9
store i32 4, i32* %2
br label %34
15: ; preds = %9
%16 = load i8*, i8** %3
%17 = call i8* @strstr(i8* %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%18 = load i8*, i8** %3
%19 = icmp eq i8* %17, %18
br i1 %19, label %20, label %21
20: ; preds = %15
store i32 5, i32* %2
br label %34
21: ; preds = %15
%22 = load i8*, i8** %3
%23 = call i8* @strstr(i8* %22, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%24 = load i8*, i8** %3
%25 = icmp eq i8* %23, %24
br i1 %25, label %26, label %27
26: ; preds = %21
store i32 6, i32* %2
br label %34
27: ; preds = %21
%28 = load i8*, i8** %3
%29 = call i8* @strstr(i8* %28, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%30 = load i8*, i8** %3
%31 = icmp eq i8* %29, %30
br i1 %31, label %32, label %33
32: ; preds = %27
store i32 7, i32* %2
br label %34
33: ; preds = %27
store i32 0, i32* %2
br label %34
34: ; preds = %33, %32, %26, %20, %14, %8
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@.str = [10 x i8] c"structure\00"
@.str.1 = [11 x i8] c"showsector\00"
@.str.2 = [9 x i8] c"traverse\00"
@.str.3 = [8 x i8] c"showfat\00"
@.str.4 = [9 x i8] c"showfile\00"
define i32 @process_floppy_command(i8* nocapture %0) {
%2 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 9)
%3 = icmp eq i32 %2, 0
br i1 %3, label %17, label %4
4: ; preds = %1
%5 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i64 10)
%6 = icmp eq i32 %5, 0
br i1 %6, label %17, label %7
7: ; preds = %4
%8 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i64 8)
%9 = icmp eq i32 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %7
%11 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i64 7)
%12 = icmp eq i32 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i64 8)
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i32 7, i32 0
br label %17
17: ; preds = %13, %10, %7, %4, %1
%18 = phi i32 [ 3, %1 ], [ 4, %4 ], [ 5, %7 ], [ 6, %10 ], [ %16, %13 ]
ret i32 %18
}