#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 /*<<< orphan*/ config_error(char *, int);
int strlen(char *);
int checkmode(char *mode, char *opt, int linenum) {
  if (mode == NULL || strlen(mode) == 0) {
    config_error("Syntax error, line %d: Mode field isn't specified.", linenum);
    return -1;
  } else if (strlen(mode) == 1) {
    if (opt == NULL) {
      config_error("Syntax error, line %d: 2-char special mode required to "
                   "omit content field.",
                   linenum);
      return -1;
    } else if (mode[0] == 'n') {
      config_error("Syntax error, line %d: Mode 'n' must be accompanied with "
                   "2nd char specifying a special mode.",
                   linenum);
      return -1;
    }
  } else if (strlen(mode) == 2 && mode[0] != 'n') {
    config_error("Syntax error, line %d: Mode may only be 2 chars long if the "
                 "first char is \"n\".",
                 linenum);
    return -1;
  } else if (strlen(mode) > 2) {
    config_error("Syntax error, line %d: Mode may only be 1 to 2 chars long.",
                 linenum);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<checkmode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1150 <checkmode+0x30>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
jne    116b <checkmode+0x4b>
mov    -0x1c(%rbp),%esi
lea    0xea6(%rip),%rdi
call   1040 <config_error@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1258 <checkmode+0x138>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jne    11d8 <checkmode+0xb8>
cmpq   $0x0,-0x18(%rbp)
jne    11a3 <checkmode+0x83>
mov    -0x1c(%rbp),%esi
lea    0xea1(%rip),%rdi
call   1040 <config_error@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1258 <checkmode+0x138>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x6e,%eax
jne    11ce <checkmode+0xae>
mov    -0x1c(%rbp),%esi
lea    0xec1(%rip),%rdi
call   1040 <config_error@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1258 <checkmode+0x138>
jmp    11d3 <checkmode+0xb3>
jmp    124c <checkmode+0x12c>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jne    1215 <checkmode+0xf5>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x6e,%eax
je     1215 <checkmode+0xf5>
mov    -0x1c(%rbp),%esi
lea    0xed7(%rip),%rdi
call   1040 <config_error@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1258 <checkmode+0x138>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jle    1242 <checkmode+0x122>
mov    -0x1c(%rbp),%esi
lea    0xef9(%rip),%rdi
call   1040 <config_error@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1258 <checkmode+0x138>
jmp    1247 <checkmode+0x127>
jmp    124c <checkmode+0x12c>
jmp    1251 <checkmode+0x131>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkmode>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
lea    0xecf(%rip),%rbp
test   %rdi,%rdi
je     11a3 <checkmode+0x83>
mov    %rsi,%r15
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
je     11a3 <checkmode+0x83>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jne    1167 <checkmode+0x47>
test   %r15,%r15
je     1193 <checkmode+0x73>
xor    %eax,%eax
cmpb   $0x6e,(%rbx)
jne    11b3 <checkmode+0x93>
lea    0xf19(%rip),%rbp
jmp    11a3 <checkmode+0x83>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jne    1179 <checkmode+0x59>
cmpb   $0x6e,(%rbx)
jne    119c <checkmode+0x7c>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x3,%ecx
jl     11b3 <checkmode+0x93>
lea    0xf99(%rip),%rbp
jmp    11a3 <checkmode+0x83>
lea    0xe99(%rip),%rbp
jmp    11a3 <checkmode+0x83>
lea    0xf38(%rip),%rbp
mov    %rbp,%rdi
mov    %r14d,%esi
call   1040 <config_error@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [51 x i8] c"Syntax error, line %d: Mode field isn't specified.\00"
@.str.1 = [75 x i8] c"Syntax error, line %d: 2-char special mode required to omit content field.\00"
@.str.2 = [93 x i8] c"Syntax error, line %d: Mode 'n' must be accompanied with 2nd char specifying a special mode.\00"
@.str.3 = [79 x i8] c"Syntax error, line %d: Mode may only be 2 chars long if the first char is \22n\22.\00"
@.str.4 = [59 x i8] c"Syntax error, line %d: Mode may only be 1 to 2 chars long.\00"
define i32 @checkmode(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%8 = load i8*, i8** %5
%9 = icmp eq i8* %8, null
br i1 %9, label %14, label %10
10: ; preds = %3
%11 = load i8*, i8** %5
%12 = call i32 @strlen(i8* %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10, %3
%15 = load i32, i32* %7
%16 = call i32 @config_error(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i32 %15)
store i32 -1, i32* %4
br label %62
17: ; preds = %10
%18 = load i8*, i8** %5
%19 = call i32 @strlen(i8* %18)
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %38
21: ; preds = %17
%22 = load i8*, i8** %6
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i32, i32* %7
%26 = call i32 @config_error(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.1, i64 0, i64 0), i32 %25)
store i32 -1, i32* %4
br label %62
27: ; preds = %21
%28 = load i8*, i8** %5
%29 = getelementptr inbounds i8, i8* %28, i64 0
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 110
br i1 %32, label %33, label %36
33: ; preds = %27
%34 = load i32, i32* %7
%35 = call i32 @config_error(i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str.2, i64 0, i64 0), i32 %34)
store i32 -1, i32* %4
br label %62
36: ; preds = %27
br label %37
37: ; preds = %36
br label %60
38: ; preds = %17
%39 = load i8*, i8** %5
%40 = call i32 @strlen(i8* %39)
%41 = icmp eq i32 %40, 2
br i1 %41, label %42, label %51
42: ; preds = %38
%43 = load i8*, i8** %5
%44 = getelementptr inbounds i8, i8* %43, i64 0
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp ne i32 %46, 110
br i1 %47, label %48, label %51
48: ; preds = %42
%49 = load i32, i32* %7
%50 = call i32 @config_error(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.3, i64 0, i64 0), i32 %49)
store i32 -1, i32* %4
br label %62
51: ; preds = %42, %38
%52 = load i8*, i8** %5
%53 = call i32 @strlen(i8* %52)
%54 = icmp sgt i32 %53, 2
br i1 %54, label %55, label %58
55: ; preds = %51
%56 = load i32, i32* %7
%57 = call i32 @config_error(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i64 0, i64 0), i32 %56)
store i32 -1, i32* %4
br label %62
58: ; preds = %51
br label %59
59: ; preds = %58
br label %60
60: ; preds = %59, %37
br label %61
61: ; preds = %60
store i32 0, i32* %4
br label %62
62: ; preds = %61, %55, %48, %33, %24, %14
%63 = load i32, i32* %4
ret i32 %63
}

LLVM IR (-O2):
@.str = [51 x i8] c"Syntax error, line %d: Mode field isn't specified.\00"
@.str.1 = [75 x i8] c"Syntax error, line %d: 2-char special mode required to omit content field.\00"
@.str.2 = [93 x i8] c"Syntax error, line %d: Mode 'n' must be accompanied with 2nd char specifying a special mode.\00"
@.str.3 = [79 x i8] c"Syntax error, line %d: Mode may only be 2 chars long if the first char is \22n\22.\00"
@.str.4 = [59 x i8] c"Syntax error, line %d: Mode may only be 1 to 2 chars long.\00"
define i32 @checkmode(i8* %0, i8* readnone %1, i32 %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %25, label %5
5: ; preds = %3
%6 = tail call i32 @strlen(i8* %0)
%7 = icmp eq i32 %6, 0
br i1 %7, label %25, label %8
8: ; preds = %5
%9 = tail call i32 @strlen(i8* %0)
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %8
%12 = icmp eq i8* %1, null
br i1 %12, label %25, label %13
13: ; preds = %11
%14 = load i8, i8* %0
%15 = icmp eq i8 %14, 110
br i1 %15, label %25, label %28
16: ; preds = %8
%17 = tail call i32 @strlen(i8* %0)
%18 = icmp eq i32 %17, 2
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i8, i8* %0
%21 = icmp eq i8 %20, 110
br i1 %21, label %22, label %25
22: ; preds = %19, %16
%23 = tail call i32 @strlen(i8* %0)
%24 = icmp sgt i32 %23, 2
br i1 %24, label %25, label %28
25: ; preds = %22, %19, %13, %11, %3, %5
%26 = phi i8* [ getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), %5 ], [ getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), %3 ], [ getelementptr inbounds ([75 x i8], [75 x i8]* @.str.1, i64 0, i64 0), %11 ], [ getelementptr inbounds ([93 x i8], [93 x i8]* @.str.2, i64 0, i64 0), %13 ], [ getelementptr inbounds ([79 x i8], [79 x i8]* @.str.3, i64 0, i64 0), %19 ], [ getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i64 0, i64 0), %22 ]
%27 = tail call i32 @config_error(i8* %26, i32 %2)
br label %28
28: ; preds = %25, %22, %13
%29 = phi i32 [ 0, %13 ], [ 0, %22 ], [ -1, %25 ]
ret i32 %29
}