#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 charToNumber(char);
int /*<<< orphan*/ isNumber(char);
int /*<<< orphan*/ printf(char *, int, ...);
scalar_t__ strlen(char *);
int /*<<< orphan*/ throwError(char *);
int isConfValid(char *conf, int quants) {
  int len = (int)strlen(conf);
  if (len / 2 == quants) {
    if (len % 2 == 0) {
      int i;
      for (i = 0; i < len; i++) {
        if (i % 2 == 0) {
          if (!isNumber(conf[i])) {
            throwError("ES ESTE1");
            return 0;
          } else {
            if (charToNumber(conf[i]) > 4) {
              throwError("ORDENACIO NO SUPORTADA");
              printf("\nERROR DONAT A %d, el seu caracter era %c", i, conf[i]);
            }
          }
        } else {
          if (conf[i] != '<' && conf[i] != '>') {
            throwError("ES ESTE2");
            return 0;
          }
        }
      }
      return 1;
    } else {
      throwError("LONGITUD INVALIDA");
      return 0;
    }
  } else {
    throwError("ERROR DE LEN");
    printf("\nLEN: %d\n", len / 2);
    printf("\nQUANTS: %d\n", quants);
    return 0;
  }
}


x86 assembly (clang, -O0):
<isConfValid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    -0x14(%rbp),%eax
jne    12b7 <isConfValid+0x167>
mov    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    129f <isConfValid+0x14f>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1293 <isConfValid+0x143>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1239 <isConfValid+0xe9>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <isNumber@plt>
cmp    $0x0,%eax
jne    11ec <isConfValid+0x9c>
lea    0xe25(%rip),%rdi
call   1060 <throwError@plt>
movl   $0x0,-0x4(%rbp)
jmp    12f6 <isConfValid+0x1a6>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1070 <charToNumber@plt>
cmp    $0x4,%eax
jle    122f <isConfValid+0xdf>
lea    0xdfc(%rip),%rdi
call   1060 <throwError@plt>
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1234 <isConfValid+0xe4>
jmp    1280 <isConfValid+0x130>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3c,%eax
je     127b <isConfValid+0x12b>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3e,%eax
je     127b <isConfValid+0x12b>
lea    0xde0(%rip),%rdi
call   1060 <throwError@plt>
movl   $0x0,-0x4(%rbp)
jmp    12f6 <isConfValid+0x1a6>
jmp    1280 <isConfValid+0x130>
jmp    1285 <isConfValid+0x135>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    119a <isConfValid+0x4a>
movl   $0x1,-0x4(%rbp)
jmp    12f6 <isConfValid+0x1a6>
lea    0xdad(%rip),%rdi
call   1060 <throwError@plt>
movl   $0x0,-0x4(%rbp)
jmp    12f6 <isConfValid+0x1a6>
lea    0xda7(%rip),%rdi
call   1060 <throwError@plt>
mov    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xd94(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isConfValid>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
cmp    %r14d,%ebp
jne    11f1 <isConfValid+0xa1>
test   $0x1,%al
jne    1223 <isConfValid+0xd3>
mov    $0x1,%r12d
test   %eax,%eax
jle    1232 <isConfValid+0xe2>
mov    %eax,%r13d
lea    0xe75(%rip),%r14
lea    0xe85(%rip),%r15
xor    %ebp,%ebp
jmp    11b3 <isConfValid+0x63>
nop
or     $0x2,%al
cmp    $0x3e,%al
jne    124d <isConfValid+0xfd>
add    $0x1,%rbp
cmp    %rbp,%r13
je     1232 <isConfValid+0xe2>
movzbl (%rbx,%rbp,1),%eax
test   $0x1,%bpl
jne    11a0 <isConfValid+0x50>
movsbl %al,%edi
call   1050 <isNumber@plt>
test   %eax,%eax
je     1244 <isConfValid+0xf4>
movsbl (%rbx,%rbp,1),%edi
call   1070 <charToNumber@plt>
cmp    $0x5,%eax
jl     11aa <isConfValid+0x5a>
mov    %r14,%rdi
call   1060 <throwError@plt>
movsbl (%rbx,%rbp,1),%edx
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11aa <isConfValid+0x5a>
lea    0xe6d(%rip),%rdi
call   1060 <throwError@plt>
lea    0xe6e(%rip),%rdi
xor    %r12d,%r12d
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe65(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1232 <isConfValid+0xe2>
lea    0xe29(%rip),%rdi
call   1060 <throwError@plt>
xor    %r12d,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdb5(%rip),%rdi
jmp    122a <isConfValid+0xda>
lea    0xdf6(%rip),%rdi
jmp    122a <isConfValid+0xda>

LLVM IR (-O0):
@.str = [9 x i8] c"ES ESTE1\00"
@.str.1 = [23 x i8] c"ORDENACIO NO SUPORTADA\00"
@.str.2 = [42 x i8] c"\0AERROR DONAT A %d, el seu caracter era %c\00"
@.str.3 = [9 x i8] c"ES ESTE2\00"
@.str.4 = [18 x i8] c"LONGITUD INVALIDA\00"
@.str.5 = [13 x i8] c"ERROR DE LEN\00"
@.str.6 = [10 x i8] c"\0ALEN: %d\0A\00"
@.str.7 = [13 x i8] c"\0AQUANTS: %d\0A\00"
define i32 @isConfValid(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%8 = load i8*, i8** %4
%9 = call i64 @strlen(i8* %8)
%10 = trunc i64 %9 to i32
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = sdiv i32 %11, 2
%13 = load i32, i32* %5
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %84
15: ; preds = %2
%16 = load i32, i32* %6
%17 = srem i32 %16, 2
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %82
19: ; preds = %15
store i32 0, i32* %7
br label %20
20: ; preds = %78, %19
%21 = load i32, i32* %7
%22 = load i32, i32* %6
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %81
24: ; preds = %20
%25 = load i32, i32* %7
%26 = srem i32 %25, 2
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %58
28: ; preds = %24
%29 = load i8*, i8** %4
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = call i32 @isNumber(i8 signext %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %38, label %36
36: ; preds = %28
%37 = call i32 @throwError(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %91
38: ; preds = %28
%39 = load i8*, i8** %4
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = call i32 @charToNumber(i8 signext %43)
%45 = icmp sgt i32 %44, 4
br i1 %45, label %46, label %56
46: ; preds = %38
%47 = call i32 @throwError(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%48 = load i32, i32* %7
%49 = load i8*, i8** %4
%50 = load i32, i32* %7
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %49, i64 %51
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i32 %48, i32 %54)
br label %56
56: ; preds = %46, %38
br label %57
57: ; preds = %56
br label %77
58: ; preds = %24
%59 = load i8*, i8** %4
%60 = load i32, i32* %7
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %59, i64 %61
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp ne i32 %64, 60
br i1 %65, label %66, label %76
66: ; preds = %58
%67 = load i8*, i8** %4
%68 = load i32, i32* %7
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %67, i64 %69
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = icmp ne i32 %72, 62
br i1 %73, label %74, label %76
74: ; preds = %66
%75 = call i32 @throwError(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %91
76: ; preds = %66, %58
br label %77
77: ; preds = %76, %57
br label %78
78: ; preds = %77
%79 = load i32, i32* %7
%80 = add nsw i32 %79, 1
store i32 %80, i32* %7
br label %20
81: ; preds = %20
store i32 1, i32* %3
br label %91
82: ; preds = %15
%83 = call i32 @throwError(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %91
84: ; preds = %2
%85 = call i32 @throwError(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%86 = load i32, i32* %6
%87 = sdiv i32 %86, 2
%88 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %87)
%89 = load i32, i32* %5
%90 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i32 %89)
store i32 0, i32* %3
br label %91
91: ; preds = %84, %82, %81, %74, %36
%92 = load i32, i32* %3
ret i32 %92
}

LLVM IR (-O2):
@.str = [9 x i8] c"ES ESTE1\00"
@.str.1 = [23 x i8] c"ORDENACIO NO SUPORTADA\00"
@.str.2 = [42 x i8] c"\0AERROR DONAT A %d, el seu caracter era %c\00"
@.str.3 = [9 x i8] c"ES ESTE2\00"
@.str.4 = [18 x i8] c"LONGITUD INVALIDA\00"
@.str.5 = [13 x i8] c"ERROR DE LEN\00"
@.str.6 = [10 x i8] c"\0ALEN: %d\0A\00"
@.str.7 = [13 x i8] c"\0AQUANTS: %d\0A\00"
define i32 @isConfValid(i8* nocapture %0, i32 %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = trunc i64 %3 to i32
%5 = sdiv i32 %4, 2
%6 = icmp eq i32 %5, %1
br i1 %6, label %7, label %43
7: ; preds = %2
%8 = and i32 %4, 1
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %41
10: ; preds = %7
%11 = icmp sgt i32 %4, 0
br i1 %11, label %12, label %47
12: ; preds = %10
%13 = and i64 %3, 4294967295
br label %14
14: ; preds = %12, %38
%15 = phi i64 [ 0, %12 ], [ %39, %38 ]
%16 = trunc i64 %15 to i32
%17 = and i32 %16, 1
%18 = icmp eq i32 %17, 0
%19 = getelementptr inbounds i8, i8* %0, i64 %15
%20 = load i8, i8* %19
br i1 %18, label %21, label %35
21: ; preds = %14
%22 = tail call i32 @isNumber(i8 signext %20)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = tail call i32 @throwError(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %47
26: ; preds = %21
%27 = load i8, i8* %19
%28 = tail call i32 @charToNumber(i8 signext %27)
%29 = icmp sgt i32 %28, 4
br i1 %29, label %30, label %38
30: ; preds = %26
%31 = tail call i32 @throwError(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%32 = load i8, i8* %19
%33 = sext i8 %32 to i32
%34 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i32 %16, i32 %33)
br label %38
35: ; preds = %14
switch i8 %20, label %36 [
i8 60, label %38
i8 62, label %38
]
36: ; preds = %35
%37 = tail call i32 @throwError(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %47
38: ; preds = %35, %35, %26, %30
%39 = add nuw nsw i64 %15, 1
%40 = icmp eq i64 %39, %13
br i1 %40, label %47, label %14
41: ; preds = %7
%42 = tail call i32 @throwError(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %47
43: ; preds = %2
%44 = tail call i32 @throwError(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%45 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %5)
%46 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i32 %1)
br label %47
47: ; preds = %38, %10, %24, %36, %43, %41
%48 = phi i32 [ 0, %41 ], [ 0, %43 ], [ 0, %24 ], [ 0, %36 ], [ 1, %10 ], [ 1, %38 ]
ret i32 %48
}