#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*/ strcpy(char *, char *);
scalar_t__ strncmp(char *, char *, int);
int CargaTiposDATOS(char *spec, char map[20][5]) {
  int i;
  for (i = 0; i < 20; i++) {
    if (strncmp(map[i], "0000", 4) != 0) {
      if (strncmp(spec, map[i], 4) == 0) {
        return (i + 1);
      }
    } else {
      strcpy(map[i], spec);
      return (i + 1);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<CargaTiposDATOS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x14,-0x1c(%rbp)
jge    11de <CargaTiposDATOS+0xbe>
mov    -0x18(%rbp),%rdi
movslq -0x1c(%rbp),%rax
imul   $0x5,%rax,%rax
add    %rax,%rdi
lea    0xea9(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11a5 <CargaTiposDATOS+0x85>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x1c(%rbp),%rax
imul   $0x5,%rax,%rax
add    %rax,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11a0 <CargaTiposDATOS+0x80>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11e5 <CargaTiposDATOS+0xc5>
jmp    11cb <CargaTiposDATOS+0xab>
mov    -0x18(%rbp),%rdi
movslq -0x1c(%rbp),%rax
imul   $0x5,%rax,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11e5 <CargaTiposDATOS+0xc5>
jmp    11d0 <CargaTiposDATOS+0xb0>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1137 <CargaTiposDATOS+0x17>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CargaTiposDATOS>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r15
mov    $0xffffffffffffffec,%r14
lea    0xec4(%rip),%r12
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1178 <CargaTiposDATOS+0x58>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1183 <CargaTiposDATOS+0x63>
add    $0x5,%rbx
inc    %r14
jne    1140 <CargaTiposDATOS+0x20>
xor    %r14d,%r14d
jmp    1187 <CargaTiposDATOS+0x67>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
add    $0x15,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"0000\00"
define i32 @CargaTiposDATOS(i8* %0, [5 x i8]* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [5 x i8]*
%6 = alloca i32
store i8* %0, i8** %4
store [5 x i8]* %1, [5 x i8]** %5
store i32 0, i32* %6
br label %7
7: ; preds = %42, %2
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 20
br i1 %9, label %10, label %45
10: ; preds = %7
%11 = load [5 x i8]*, [5 x i8]** %5
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [5 x i8], [5 x i8]* %11, i64 %13
%15 = getelementptr inbounds [5 x i8], [5 x i8]* %14, i64 0, i64 0
%16 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %31
18: ; preds = %10
%19 = load i8*, i8** %4
%20 = load [5 x i8]*, [5 x i8]** %5
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [5 x i8], [5 x i8]* %20, i64 %22
%24 = getelementptr inbounds [5 x i8], [5 x i8]* %23, i64 0, i64 0
%25 = call i64 @strncmp(i8* %19, i8* %24, i32 4)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %18
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %46
30: ; preds = %18
br label %41
31: ; preds = %10
%32 = load [5 x i8]*, [5 x i8]** %5
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [5 x i8], [5 x i8]* %32, i64 %34
%36 = getelementptr inbounds [5 x i8], [5 x i8]* %35, i64 0, i64 0
%37 = load i8*, i8** %4
%38 = call i32 @strcpy(i8* %36, i8* %37)
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 1
store i32 %40, i32* %3
br label %46
41: ; preds = %30
br label %42
42: ; preds = %41
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %7
45: ; preds = %7
store i32 0, i32* %3
br label %46
46: ; preds = %45, %31, %27
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@.str = [5 x i8] c"0000\00"
define i32 @CargaTiposDATOS(i8* %0, [5 x i8]* %1) {
br label %3
3: ; preds = %2, %18
%4 = phi i64 [ 0, %2 ], [ %19, %18 ]
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 %4, i64 0
%6 = tail call i64 @strncmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%7 = icmp eq i64 %6, 0
br i1 %7, label %14, label %8
8: ; preds = %3
%9 = tail call i64 @strncmp(i8* %0, i8* %5, i32 4)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %8
%12 = trunc i64 %4 to i32
%13 = add nuw nsw i32 %12, 1
br label %21
14: ; preds = %3
%15 = trunc i64 %4 to i32
%16 = tail call i32 @strcpy(i8* %5, i8* %0)
%17 = add nuw nsw i32 %15, 1
br label %21
18: ; preds = %8
%19 = add nuw nsw i64 %4, 1
%20 = icmp eq i64 %19, 20
br i1 %20, label %21, label %3
21: ; preds = %18, %14, %11
%22 = phi i32 [ %13, %11 ], [ %17, %14 ], [ 0, %18 ]
ret i32 %22
}