#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 atoi(char *);
int strlen(char *);
scalar_t__ strstr(char *, char *);
int toNum(char *);
int isDirective(char **token) {
  int num;
  num = toNum(token[2]);
  if (strstr(token[0], "end")) {
    return -3;
  }
  if (strstr(token[1], "resw")) {
    int len;
    len = atoi(token[2]);
    return len * 3;
  }
  if (strstr(token[1], "word")) {
    return 3;
  }
  if (strstr(token[1], "byte")) {
    int len = strlen(token[2]);
    if (token[2][0] == 'x') {
      return (len - 4) / 2;
    }
    if (token[2][0] == 'c') {
      return len - 4;
    }
  }
  if (strstr(token[1], "resb")) {
    int len = strlen(token[2]);
    return len;
  }
  return 3;
}


x86 assembly (clang, -O0):
<isDirective>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <toNum@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe96(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     1185 <isDirective+0x45>
movl   $0xfffffffd,-0x4(%rbp)
jmp    12a8 <isDirective+0x168>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe70(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     11bf <isDirective+0x7f>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
imul   $0x3,-0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12a8 <isDirective+0x168>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe3b(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     11e9 <isDirective+0xa9>
movl   $0x3,-0x4(%rbp)
jmp    12a8 <isDirective+0x168>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe16(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     1268 <isDirective+0x128>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movsbl (%rax),%eax
cmp    $0x78,%eax
jne    1241 <isDirective+0x101>
mov    -0x1c(%rbp),%eax
sub    $0x4,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    12a8 <isDirective+0x168>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movsbl (%rax),%eax
cmp    $0x63,%eax
jne    1263 <isDirective+0x123>
mov    -0x1c(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x4(%rbp)
jmp    12a8 <isDirective+0x168>
jmp    1268 <isDirective+0x128>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd9c(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     12a1 <isDirective+0x161>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12a8 <isDirective+0x168>
movl   $0x3,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isDirective>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x10(%rdi),%rdi
call   1040 <toNum@plt>
mov    (%rbx),%rdi
lea    0xea7(%rip),%rsi
call   1060 <strstr@plt>
mov    $0xfffffffd,%ebp
test   %rax,%rax
jne    11a5 <isDirective+0x65>
mov    0x8(%rbx),%rdi
lea    0xe91(%rip),%rsi
call   1060 <strstr@plt>
test   %rax,%rax
je     118b <isDirective+0x4b>
mov    0x10(%rbx),%rdi
call   1050 <atoi@plt>
lea    (%rax,%rax,2),%ebp
jmp    11a5 <isDirective+0x65>
mov    0x8(%rbx),%rdi
lea    0xe73(%rip),%rsi
call   1060 <strstr@plt>
mov    $0x3,%ebp
test   %rax,%rax
je     11ae <isDirective+0x6e>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x8(%rbx),%rdi
lea    0xe55(%rip),%rsi
call   1060 <strstr@plt>
test   %rax,%rax
je     11ee <isDirective+0xae>
mov    0x10(%rbx),%rdi
call   1030 <strlen@plt>
mov    0x10(%rbx),%rcx
mov    (%rcx),%cl
cmp    $0x63,%cl
je     1212 <isDirective+0xd2>
cmp    $0x78,%cl
jne    11ee <isDirective+0xae>
mov    %eax,%ecx
add    $0xfffffffc,%ecx
shr    $0x1f,%ecx
lea    (%rax,%rcx,1),%ebp
add    $0xfffffffc,%ebp
sar    %ebp
jmp    11a5 <isDirective+0x65>
mov    0x8(%rbx),%rdi
lea    0xe1a(%rip),%rsi
call   1060 <strstr@plt>
test   %rax,%rax
je     11a5 <isDirective+0x65>
mov    0x10(%rbx),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <strlen@plt>
add    $0xfffffffc,%eax
mov    %eax,%ebp
jmp    11a5 <isDirective+0x65>

LLVM IR (-O0):
@.str = [4 x i8] c"end\00"
@.str.1 = [5 x i8] c"resw\00"
@.str.2 = [5 x i8] c"word\00"
@.str.3 = [5 x i8] c"byte\00"
@.str.4 = [5 x i8] c"resb\00"
define i32 @isDirective(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8** %0, i8*** %3
%8 = load i8**, i8*** %3
%9 = getelementptr inbounds i8*, i8** %8, i64 2
%10 = load i8*, i8** %9
%11 = call i32 @toNum(i8* %10)
store i32 %11, i32* %4
%12 = load i8**, i8*** %3
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i64 @strstr(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %1
store i32 -3, i32* %2
br label %85
18: ; preds = %1
%19 = load i8**, i8*** %3
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i64 @strstr(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %31
24: ; preds = %18
%25 = load i8**, i8*** %3
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @atoi(i8* %27)
store i32 %28, i32* %5
%29 = load i32, i32* %5
%30 = mul nsw i32 %29, 3
store i32 %30, i32* %2
br label %85
31: ; preds = %18
%32 = load i8**, i8*** %3
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i64 @strstr(i8* %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %31
store i32 3, i32* %2
br label %85
38: ; preds = %31
%39 = load i8**, i8*** %3
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
%42 = call i64 @strstr(i8* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %72
44: ; preds = %38
%45 = load i8**, i8*** %3
%46 = getelementptr inbounds i8*, i8** %45, i64 2
%47 = load i8*, i8** %46
%48 = call i32 @strlen(i8* %47)
store i32 %48, i32* %6
%49 = load i8**, i8*** %3
%50 = getelementptr inbounds i8*, i8** %49, i64 2
%51 = load i8*, i8** %50
%52 = getelementptr inbounds i8, i8* %51, i64 0
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 120
br i1 %55, label %56, label %60
56: ; preds = %44
%57 = load i32, i32* %6
%58 = sub nsw i32 %57, 4
%59 = sdiv i32 %58, 2
store i32 %59, i32* %2
br label %85
60: ; preds = %44
%61 = load i8**, i8*** %3
%62 = getelementptr inbounds i8*, i8** %61, i64 2
%63 = load i8*, i8** %62
%64 = getelementptr inbounds i8, i8* %63, i64 0
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = icmp eq i32 %66, 99
br i1 %67, label %68, label %71
68: ; preds = %60
%69 = load i32, i32* %6
%70 = sub nsw i32 %69, 4
store i32 %70, i32* %2
br label %85
71: ; preds = %60
br label %72
72: ; preds = %71, %38
%73 = load i8**, i8*** %3
%74 = getelementptr inbounds i8*, i8** %73, i64 1
%75 = load i8*, i8** %74
%76 = call i64 @strstr(i8* %75, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%77 = icmp ne i64 %76, 0
br i1 %77, label %78, label %84
78: ; preds = %72
%79 = load i8**, i8*** %3
%80 = getelementptr inbounds i8*, i8** %79, i64 2
%81 = load i8*, i8** %80
%82 = call i32 @strlen(i8* %81)
store i32 %82, i32* %7
%83 = load i32, i32* %7
store i32 %83, i32* %2
br label %85
84: ; preds = %72
store i32 3, i32* %2
br label %85
85: ; preds = %84, %78, %68, %56, %37, %24, %17
%86 = load i32, i32* %2
ret i32 %86
}

LLVM IR (-O2):
@.str = [4 x i8] c"end\00"
@.str.1 = [5 x i8] c"resw\00"
@.str.2 = [5 x i8] c"word\00"
@.str.3 = [5 x i8] c"byte\00"
@.str.4 = [5 x i8] c"resb\00"
define i32 @isDirective(i8** nocapture %0) {
%2 = getelementptr inbounds i8*, i8** %0, i64 2
%3 = load i8*, i8** %2
%4 = tail call i32 @toNum(i8* %3)
%5 = load i8*, i8** %0
%6 = tail call i64 @strstr(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %42
8: ; preds = %1
%9 = getelementptr inbounds i8*, i8** %0, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @strstr(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %8
%14 = load i8*, i8** %2
%15 = tail call i32 @atoi(i8* %14)
%16 = mul nsw i32 %15, 3
br label %42
17: ; preds = %8
%18 = load i8*, i8** %9
%19 = tail call i64 @strstr(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %42
21: ; preds = %17
%22 = load i8*, i8** %9
%23 = tail call i64 @strstr(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %35, label %25
25: ; preds = %21
%26 = load i8*, i8** %2
%27 = tail call i32 @strlen(i8* %26)
%28 = load i8*, i8** %2
%29 = load i8, i8* %28
switch i8 %29, label %35 [
i8 120, label %30
i8 99, label %33
]
30: ; preds = %25
%31 = add nsw i32 %27, -4
%32 = sdiv i32 %31, 2
br label %42
33: ; preds = %25
%34 = add nsw i32 %27, -4
br label %42
35: ; preds = %25, %21
%36 = load i8*, i8** %9
%37 = tail call i64 @strstr(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %42, label %39
39: ; preds = %35
%40 = load i8*, i8** %2
%41 = tail call i32 @strlen(i8* %40)
br label %42
42: ; preds = %30, %33, %35, %17, %1, %39, %13
%43 = phi i32 [ %16, %13 ], [ %41, %39 ], [ -3, %1 ], [ 3, %17 ], [ 3, %35 ], [ %32, %30 ], [ %34, %33 ]
ret i32 %43
}