#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 */
scalar_t__ strstr(char *, char *);
int imc_fits_dtype_string(char *dtype) {
  int fitsdtype = -1;
  if (dtype != NULL && dtype[0] != '\0') {
    if (strstr(dtype, "SHORT")) {
      fitsdtype = 16;
    } else if (strstr(dtype, "INT")) {
      fitsdtype = 32;
    } else if (strstr(dtype, "CHAR")) {
      fitsdtype = 8;
    } else if (strstr(dtype, "FLOAT")) {
      fitsdtype = -32;
    }
  }
  return fitsdtype;
}


x86 assembly (clang, -O0):
<imc_fits_dtype_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11e5 <imc_fits_dtype_string+0xd5>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11e5 <imc_fits_dtype_string+0xd5>
mov    -0x8(%rbp),%rdi
lea    0xeb7(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     1164 <imc_fits_dtype_string+0x54>
movl   $0x10,-0xc(%rbp)
jmp    11e0 <imc_fits_dtype_string+0xd0>
mov    -0x8(%rbp),%rdi
lea    0xe97(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     118a <imc_fits_dtype_string+0x7a>
movl   $0x20,-0xc(%rbp)
jmp    11db <imc_fits_dtype_string+0xcb>
mov    -0x8(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     11b0 <imc_fits_dtype_string+0xa0>
movl   $0x8,-0xc(%rbp)
jmp    11d6 <imc_fits_dtype_string+0xc6>
mov    -0x8(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     11d1 <imc_fits_dtype_string+0xc1>
movl   $0xffffffe0,-0xc(%rbp)
jmp    11d6 <imc_fits_dtype_string+0xc6>
jmp    11db <imc_fits_dtype_string+0xcb>
jmp    11e0 <imc_fits_dtype_string+0xd0>
jmp    11e5 <imc_fits_dtype_string+0xd5>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<imc_fits_dtype_string>:
push   %rbx
mov    $0xffffffff,%eax
test   %rdi,%rdi
je     113f <imc_fits_dtype_string+0x2f>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     113f <imc_fits_dtype_string+0x2f>
lea    0xed6(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
mov    %rax,%rcx
mov    $0x10,%eax
test   %rcx,%rcx
je     1141 <imc_fits_dtype_string+0x31>
pop    %rbx
ret
lea    0xebe(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
mov    %rax,%rcx
mov    $0x20,%eax
test   %rcx,%rcx
jne    113f <imc_fits_dtype_string+0x2f>
lea    0xea6(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
mov    %rax,%rcx
mov    $0x8,%eax
test   %rcx,%rcx
jne    113f <imc_fits_dtype_string+0x2f>
lea    0xe8f(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
cmp    $0x1,%rax
sbb    %eax,%eax
or     $0xffffffe0,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"SHORT\00"
@.str.1 = [4 x i8] c"INT\00"
@.str.2 = [5 x i8] c"CHAR\00"
@.str.3 = [6 x i8] c"FLOAT\00"
define i32 @imc_fits_dtype_string(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %19, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %19, label %6
6: ; preds = %3
%7 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %6
%10 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
%18 = select i1 %17, i32 -1, i32 -32
br label %19
19: ; preds = %15, %12, %9, %6, %3, %1
%20 = phi i32 [ -1, %3 ], [ -1, %1 ], [ 16, %6 ], [ 32, %9 ], [ 8, %12 ], [ %18, %15 ]
ret i32 %20
}