#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*/ is_length_valid(char const *, int);
scalar_t__ strcasecmp(char const *, char *);
int check_valid(const char *type, const char *code) {
  if ((strcasecmp(type, "POSTNET") == 0))
    if (!is_length_valid(code, 5) && !is_length_valid(code, 6) &&
        !is_length_valid(code, 9) && !is_length_valid(code, 11))
      return 0;
  if ((strcasecmp(type, "POSTNET-5") == 0))
    if (!is_length_valid(code, 5))
      return 0;
  if ((strcasecmp(type, "POSTNET-6") == 0))
    if (!is_length_valid(code, 6))
      return 0;
  if ((strcasecmp(type, "POSTNET-9") == 0))
    if (!is_length_valid(code, 9))
      return 0;
  if ((strcasecmp(type, "POSTNET-11") == 0))
    if (!is_length_valid(code, 11))
      return 0;
  if ((strcasecmp(type, "CEPNET") == 0))
    if (!is_length_valid(code, 8))
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<check_valid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec5(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11b7 <check_valid+0x97>
mov    -0x18(%rbp),%rdi
mov    $0x5,%esi
call   1040 <is_length_valid@plt>
cmp    $0x0,%eax
jne    11b2 <check_valid+0x92>
mov    -0x18(%rbp),%rdi
mov    $0x6,%esi
call   1040 <is_length_valid@plt>
cmp    $0x0,%eax
jne    11b2 <check_valid+0x92>
mov    -0x18(%rbp),%rdi
mov    $0x9,%esi
call   1040 <is_length_valid@plt>
cmp    $0x0,%eax
jne    11b2 <check_valid+0x92>
mov    -0x18(%rbp),%rdi
mov    $0xb,%esi
call   1040 <is_length_valid@plt>
cmp    $0x0,%eax
jne    11b2 <check_valid+0x92>
movl   $0x0,-0x4(%rbp)
jmp    1308 <check_valid+0x1e8>
jmp    11b7 <check_valid+0x97>
mov    -0x10(%rbp),%rdi
lea    0xe46(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11f9 <check_valid+0xd9>
mov    -0x18(%rbp),%rdi
mov    $0x5,%esi
call   1040 <is_length_valid@plt>
cmp    $0x0,%eax
jne    11f4 <check_valid+0xd4>
movl   $0x0,-0x4(%rbp)
jmp    1308 <check_valid+0x1e8>
jmp    11f9 <check_valid+0xd9>
mov    -0x10(%rbp),%rdi
lea    0xe0e(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    123b <check_valid+0x11b>
mov    -0x18(%rbp),%rdi
mov    $0x6,%esi
call   1040 <is_length_valid@plt>
cmp    $0x0,%eax
jne    1236 <check_valid+0x116>
movl   $0x0,-0x4(%rbp)
jmp    1308 <check_valid+0x1e8>
jmp    123b <check_valid+0x11b>
mov    -0x10(%rbp),%rdi
lea    0xdd6(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    127d <check_valid+0x15d>
mov    -0x18(%rbp),%rdi
mov    $0x9,%esi
call   1040 <is_length_valid@plt>
cmp    $0x0,%eax
jne    1278 <check_valid+0x158>
movl   $0x0,-0x4(%rbp)
jmp    1308 <check_valid+0x1e8>
jmp    127d <check_valid+0x15d>
mov    -0x10(%rbp),%rdi
lea    0xd9e(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    12bf <check_valid+0x19f>
mov    -0x18(%rbp),%rdi
mov    $0xb,%esi
call   1040 <is_length_valid@plt>
cmp    $0x0,%eax
jne    12ba <check_valid+0x19a>
movl   $0x0,-0x4(%rbp)
jmp    1308 <check_valid+0x1e8>
jmp    12bf <check_valid+0x19f>
mov    -0x10(%rbp),%rdi
lea    0xd67(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1301 <check_valid+0x1e1>
mov    -0x18(%rbp),%rdi
mov    $0x8,%esi
call   1040 <is_length_valid@plt>
cmp    $0x0,%eax
jne    12fc <check_valid+0x1dc>
movl   $0x0,-0x4(%rbp)
jmp    1308 <check_valid+0x1e8>
jmp    1301 <check_valid+0x1e1>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_valid>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xecf(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
jne    1183 <check_valid+0x63>
mov    %r14,%rdi
mov    $0x5,%esi
call   1040 <is_length_valid@plt>
test   %eax,%eax
jne    1183 <check_valid+0x63>
mov    %r14,%rdi
mov    $0x6,%esi
call   1040 <is_length_valid@plt>
test   %eax,%eax
jne    1183 <check_valid+0x63>
mov    %r14,%rdi
mov    $0x9,%esi
call   1040 <is_length_valid@plt>
test   %eax,%eax
jne    1183 <check_valid+0x63>
mov    %r14,%rdi
mov    $0xb,%esi
call   1040 <is_length_valid@plt>
test   %eax,%eax
je     1247 <check_valid+0x127>
lea    0xe7e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
jne    11ac <check_valid+0x8c>
mov    %r14,%rdi
mov    $0x5,%esi
call   1040 <is_length_valid@plt>
test   %eax,%eax
je     1247 <check_valid+0x127>
lea    0xe5f(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
jne    11d1 <check_valid+0xb1>
mov    %r14,%rdi
mov    $0x6,%esi
call   1040 <is_length_valid@plt>
test   %eax,%eax
je     1247 <check_valid+0x127>
lea    0xe44(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
jne    11f6 <check_valid+0xd6>
mov    %r14,%rdi
mov    $0x9,%esi
call   1040 <is_length_valid@plt>
test   %eax,%eax
je     1247 <check_valid+0x127>
lea    0xe29(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
jne    121b <check_valid+0xfb>
mov    %r14,%rdi
mov    $0xb,%esi
call   1040 <is_length_valid@plt>
test   %eax,%eax
je     1247 <check_valid+0x127>
lea    0xe0f(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
jne    1240 <check_valid+0x120>
mov    %r14,%rdi
mov    $0x8,%esi
call   1040 <is_length_valid@plt>
test   %eax,%eax
je     1247 <check_valid+0x127>
mov    $0x1,%eax
jmp    1249 <check_valid+0x129>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [8 x i8] c"POSTNET\00"
@.str.1 = [10 x i8] c"POSTNET-5\00"
@.str.2 = [10 x i8] c"POSTNET-6\00"
@.str.3 = [10 x i8] c"POSTNET-9\00"
@.str.4 = [11 x i8] c"POSTNET-11\00"
@.str.5 = [7 x i8] c"CEPNET\00"
define i32 @check_valid(i8* nocapture %0, i8* %1) {
%3 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %17
5: ; preds = %2
%6 = tail call i32 @is_length_valid(i8* %1, i32 5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %17
8: ; preds = %5
%9 = tail call i32 @is_length_valid(i8* %1, i32 6)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %8
%12 = tail call i32 @is_length_valid(i8* %1, i32 9)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = tail call i32 @is_length_valid(i8* %1, i32 11)
%16 = icmp eq i32 %15, 0
br i1 %16, label %48, label %17
17: ; preds = %5, %8, %11, %14, %2
%18 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = tail call i32 @is_length_valid(i8* %1, i32 5)
%22 = icmp eq i32 %21, 0
br i1 %22, label %48, label %23
23: ; preds = %20, %17
%24 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = tail call i32 @is_length_valid(i8* %1, i32 6)
%28 = icmp eq i32 %27, 0
br i1 %28, label %48, label %29
29: ; preds = %26, %23
%30 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = tail call i32 @is_length_valid(i8* %1, i32 9)
%34 = icmp eq i32 %33, 0
br i1 %34, label %48, label %35
35: ; preds = %32, %29
%36 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %35
%39 = tail call i32 @is_length_valid(i8* %1, i32 11)
%40 = icmp eq i32 %39, 0
br i1 %40, label %48, label %41
41: ; preds = %38, %35
%42 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %41
%45 = tail call i32 @is_length_valid(i8* %1, i32 8)
%46 = icmp eq i32 %45, 0
br i1 %46, label %48, label %47
47: ; preds = %44, %41
br label %48
48: ; preds = %44, %38, %32, %26, %20, %14, %47
%49 = phi i32 [ 1, %47 ], [ 0, %14 ], [ 0, %20 ], [ 0, %26 ], [ 0, %32 ], [ 0, %38 ], [ 0, %44 ]
ret i32 %49
}