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


x86 assembly (clang, -O0):
<chk_add_fld_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_fld_op+0x32>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1179 <chk_add_fld_op+0x39>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    11c3 <chk_add_fld_op+0x83>
mov    -0x10(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     11be <chk_add_fld_op+0x7e>
mov    -0x10(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     11be <chk_add_fld_op+0x7e>
movl   $0x0,-0x1c(%rbp)
jmp    11c3 <chk_add_fld_op+0x83>
cmpl   $0x0,-0x1c(%rbp)
jne    120b <chk_add_fld_op+0xcb>
mov    -0x18(%rbp),%rdi
lea    0xe38(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rdi
lea    0xe50(%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    1212 <chk_add_fld_op+0xd2>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chk_add_fld_op>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
test   %rdi,%rdi
je     1181 <chk_add_fld_op+0x41>
cmpb   $0x0,(%rbx)
je     1181 <chk_add_fld_op+0x41>
lea    0xea5(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     11b1 <chk_add_fld_op+0x71>
lea    0xe94(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11b1 <chk_add_fld_op+0x71>
lea    0xe88(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcpy@plt>
lea    0xea1(%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 = [8 x i8] c"loadcsv\00"
@.str.1 = [8 x i8] c"loadbin\00"
@.str.2 = [40 x i8] c"op can be any one of [LoadCSV,LoadBin].\00"
@.str.3 = [42 x i8] c"First 8 characters of user provided op = \00"
define i32 @chk_add_fld_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 %28
18: ; preds = %15
%19 = load i8*, i8** %4
%20 = call i64 @strcasecmp(i8* %19, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %27
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 %27
26: ; preds = %22
store i32 0, i32* %6
br label %27
27: ; preds = %26, %22, %18
br label %28
28: ; preds = %27, %15
%29 = load i32, i32* %6
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %39
31: ; preds = %28
%32 = load i8*, i8** %5
%33 = call i32 @strcpy(i8* %32, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%34 = load i8*, i8** %5
%35 = call i32 @strcat(i8* %34, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
%36 = load i8*, i8** %5
%37 = load i8*, i8** %4
%38 = call i32 @strncat(i8* %36, i8* %37, i32 8)
store i32 0, i32* %3
br label %40
39: ; preds = %28
store i32 1, i32* %3
br label %40
40: ; preds = %39, %31
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str = [8 x i8] c"loadcsv\00"
@.str.1 = [8 x i8] c"loadbin\00"
@.str.2 = [40 x i8] c"op can be any one of [LoadCSV,LoadBin].\00"
@.str.3 = [42 x i8] c"First 8 characters of user provided op = \00"
define i32 @chk_add_fld_op(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %13, label %4
4: ; preds = %2
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %13, label %7
7: ; preds = %4
%8 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %17, 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 %17, label %13
13: ; preds = %4, %2, %10
%14 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%15 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
%16 = tail call i32 @strncat(i8* %1, i8* %0, i32 8)
br label %17
17: ; preds = %10, %7, %13
%18 = phi i32 [ 0, %13 ], [ 1, %7 ], [ 1, %10 ]
ret i32 %18
}