#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, int);
int /*<<< orphan*/ printf(char *, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
scalar_t__ strncmp(char *, char *, int);
void GuardaMap(char map[20][5], char *origen) {
  FILE *fmap = NULL;
  char archivo[100];
  sprintf(archivo, "%s_MapTipos", origen);
  fmap = fopen(archivo, "w");
  int i;
  for (i = 0; i < 20; i++) {
    if (strncmp(map[i], "0000", 4) != 0) {
      fprintf(fmap, "%s -> %d\n", map[i], (i + 1));
      printf("%s -> %d\n", map[i], (i + 1));
    }
  }
  fclose(fmap);
  return;
}


x86 assembly (clang, -O0):
<GuardaMap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe76(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x80(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x84(%rbp)
cmpl   $0x14,-0x84(%rbp)
jge    1252 <GuardaMap+0xf2>
mov    -0x8(%rbp),%rdi
movslq -0x84(%rbp),%rax
imul   $0x5,%rax,%rax
add    %rax,%rdi
lea    0xe3b(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1239 <GuardaMap+0xd9>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rdx
movslq -0x84(%rbp),%rax
imul   $0x5,%rax,%rax
add    %rax,%rdx
mov    -0x84(%rbp),%ecx
add    $0x1,%ecx
lea    0xe06(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x8(%rbp),%rsi
movslq -0x84(%rbp),%rax
imul   $0x5,%rax,%rax
add    %rax,%rsi
mov    -0x84(%rbp),%edx
add    $0x1,%edx
lea    0xddf(%rip),%rdi
call   1050 <printf@plt>
jmp    123e <GuardaMap+0xde>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    11ad <GuardaMap+0x4d>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GuardaMap>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%rdx
mov    %rdi,%rbx
lea    0xe85(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1080 <sprintf@plt>
lea    0xe7f(%rip),%rsi
mov    %r14,%rdi
call   1070 <fopen@plt>
mov    %rax,%r14
mov    $0xffffffffffffffec,%rbp
lea    0xe68(%rip),%r15
lea    0xe66(%rip),%r12
jmp    11b9 <GuardaMap+0x59>
nop
add    $0x5,%rbx
inc    %rbp
je     11f3 <GuardaMap+0x93>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b0 <GuardaMap+0x50>
lea    0x15(%rbp),%r13d
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %r13d,%ecx
call   1060 <fprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r13d,%edx
call   1050 <printf@plt>
jmp    11b0 <GuardaMap+0x50>
mov    %r14,%rdi
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fclose@plt>

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

LLVM IR (-O2):
@.str = [12 x i8] c"%s_MapTipos\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [5 x i8] c"0000\00"
@.str.3 = [10 x i8] c"%s -> %d\0A\00"
define void @GuardaMap([5 x i8]* %0, i8* %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %1)
%6 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %2, %17
%8 = phi i64 [ 0, %2 ], [ %12, %17 ]
%9 = getelementptr inbounds [5 x i8], [5 x i8]* %0, i64 %8, i64 0
%10 = tail call i64 @strncmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%11 = icmp eq i64 %10, 0
%12 = add nuw nsw i64 %8, 1
br i1 %11, label %17, label %13
13: ; preds = %7
%14 = trunc i64 %12 to i32
%15 = tail call i32 @fprintf(i32* %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %9, i32 %14)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %9, i32 %14)
br label %17
17: ; preds = %7, %13
%18 = icmp eq i64 %12, 20
br i1 %18, label %19, label %7
19: ; preds = %17
%20 = tail call i32 @fclose(i32* %6)
ret void
}