#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__ strcasecmp(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strncat(char *, char *, int);
bool chk_add_tbl_op(char *op, char *errstr) {
  int is_ok = 1;
  if ((op == NULL) || (*op == '\0')) {
    is_ok = 0;
  }
  if (is_ok == 1) {
    if ((strcasecmp(op, "new") != 0) && (strcasecmp(op, "loadcsv") != 0) &&
        (strcasecmp(op, "loadbin") != 0) && (strcasecmp(op, "loadhdfs") != 0)) {
      is_ok = 0;
    }
  }
  if (is_ok == 0) {
    strcpy(errstr, "op can be any one of [New,LoadCSV,LoadBin,LoadHDFS].");
    strcat(errstr, "First 8 characters of user provided op = ");
    strncat(errstr, op, 8);
    return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<chk_add_tbl_op>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1172 <chk_add_tbl_op+0x32>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1179 <chk_add_tbl_op+0x39>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    11f7 <chk_add_tbl_op+0xb7>
mov    -0x10(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     11f2 <chk_add_tbl_op+0xb2>
mov    -0x10(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     11f2 <chk_add_tbl_op+0xb2>
mov    -0x10(%rbp),%rdi
lea    0xe4a(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     11f2 <chk_add_tbl_op+0xb2>
mov    -0x10(%rbp),%rdi
lea    0xe38(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     11f2 <chk_add_tbl_op+0xb2>
movl   $0x0,-0x1c(%rbp)
jmp    11f7 <chk_add_tbl_op+0xb7>
cmpl   $0x0,-0x1c(%rbp)
jne    123f <chk_add_tbl_op+0xff>
mov    -0x18(%rbp),%rdi
lea    0xe11(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rdi
lea    0xe36(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x8,%edx
call   1050 <strncat@plt>
movl   $0x0,-0x4(%rbp)
jmp    1246 <chk_add_tbl_op+0x106>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chk_add_tbl_op>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
test   %rdi,%rdi
je     11a9 <chk_add_tbl_op+0x69>
cmpb   $0x0,(%rbx)
je     11a9 <chk_add_tbl_op+0x69>
lea    0xea5(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     11d9 <chk_add_tbl_op+0x99>
lea    0xe90(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11d9 <chk_add_tbl_op+0x99>
lea    0xe84(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11d9 <chk_add_tbl_op+0x99>
lea    0xe78(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11d9 <chk_add_tbl_op+0x99>
lea    0xe6d(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcpy@plt>
lea    0xe93(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcat@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1050 <strncat@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"new\00"
@.str.1 = [8 x i8] c"loadcsv\00"
@.str.2 = [8 x i8] c"loadbin\00"
@.str.3 = [9 x i8] c"loadhdfs\00"
@.str.4 = [53 x i8] c"op can be any one of [New,LoadCSV,LoadBin,LoadHDFS].\00"
@.str.5 = [42 x i8] c"First 8 characters of user provided op = \00"
define i32 @chk_add_tbl_op(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 1, i32* %6
%7 = load i8*, i8** %4
%8 = icmp eq i8* %7, null
br i1 %8, label %14, label %9
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %9, %2
store i32 0, i32* %6
br label %15
15: ; preds = %14, %9
%16 = load i32, i32* %6
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %36
18: ; preds = %15
%19 = load i8*, i8** %4
%20 = call i64 @strcasecmp(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %35
22: ; preds = %18
%23 = load i8*, i8** %4
%24 = call i64 @strcasecmp(i8* %23, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %35
26: ; preds = %22
%27 = load i8*, i8** %4
%28 = call i64 @strcasecmp(i8* %27, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %26
%31 = load i8*, i8** %4
%32 = call i64 @strcasecmp(i8* %31, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %30
store i32 0, i32* %6
br label %35
35: ; preds = %34, %30, %26, %22, %18
br label %36
36: ; preds = %35, %15
%37 = load i32, i32* %6
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %47
39: ; preds = %36
%40 = load i8*, i8** %5
%41 = call i32 @strcpy(i8* %40, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0))
%42 = load i8*, i8** %5
%43 = call i32 @strcat(i8* %42, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0))
%44 = load i8*, i8** %5
%45 = load i8*, i8** %4
%46 = call i32 @strncat(i8* %44, i8* %45, i32 8)
store i32 0, i32* %3
br label %48
47: ; preds = %36
store i32 1, i32* %3
br label %48
48: ; preds = %47, %39
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@.str = [4 x i8] c"new\00"
@.str.1 = [8 x i8] c"loadcsv\00"
@.str.2 = [8 x i8] c"loadbin\00"
@.str.3 = [9 x i8] c"loadhdfs\00"
@.str.4 = [53 x i8] c"op can be any one of [New,LoadCSV,LoadBin,LoadHDFS].\00"
@.str.5 = [42 x i8] c"First 8 characters of user provided op = \00"
define i32 @chk_add_tbl_op(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %19, label %4
4: ; preds = %2
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %19, label %7
7: ; preds = %4
%8 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %23, label %10
10: ; preds = %7
%11 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %23, label %13
13: ; preds = %10
%14 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %23, label %16
16: ; preds = %13
%17 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %4, %2, %16
%20 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0))
%21 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0))
%22 = tail call i32 @strncat(i8* %1, i8* %0, i32 8)
br label %23
23: ; preds = %16, %7, %10, %13, %19
%24 = phi i32 [ 0, %19 ], [ 1, %13 ], [ 1, %10 ], [ 1, %7 ], [ 1, %16 ]
ret i32 %24
}