#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*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcat(char *, char *);
void modificar(FILE *c, char nFich[], int idCampo, char campo[], int p, int d) {
  c = fopen(nFich, "r+");
  if (c == NULL) {
    printf("CALENDARIO mod NO ENCONTRADO.\n");
  } else {
    strcat(campo, "----------");
    switch (idCampo) {
    case 1:
      p = p + (d * 11) + 4;
      break;
    case 2:
      p = (p + 354) + (11 * d) + 4;
      break;
    case 3:
      p = (p + (354 * 2)) + (11 * d) + 4;
      break;
    }
    fseek(c, p, SEEK_SET);
    if (idCampo == 3)
      fwrite(campo, 9, 1, c);
    else {
      fwrite(campo, 7, 1, c);
    }
  }
  fclose(c);
}


x86 assembly (clang, -O0):
<modificar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11af <modificar+0x4f>
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
jmp    128d <modificar+0x12d>
mov    -0x20(%rbp),%rdi
lea    0xe68(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x1,%eax
je     11f5 <modificar+0x95>
jmp    11d3 <modificar+0x73>
mov    -0x2c(%rbp),%eax
sub    $0x2,%eax
je     1209 <modificar+0xa9>
jmp    11e4 <modificar+0x84>
mov    -0x2c(%rbp),%eax
sub    $0x3,%eax
je     1222 <modificar+0xc2>
jmp    1236 <modificar+0xd6>
mov    -0x24(%rbp),%eax
imul   $0xb,-0x28(%rbp),%ecx
add    %ecx,%eax
add    $0x4,%eax
mov    %eax,-0x24(%rbp)
jmp    1236 <modificar+0xd6>
mov    -0x24(%rbp),%eax
add    $0x162,%eax
imul   $0xb,-0x28(%rbp),%ecx
add    %ecx,%eax
add    $0x4,%eax
mov    %eax,-0x24(%rbp)
jmp    1236 <modificar+0xd6>
mov    -0x24(%rbp),%eax
add    $0x2c4,%eax
imul   $0xb,-0x28(%rbp),%ecx
add    %ecx,%eax
add    $0x4,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    0x2d9c(%rip),%rax
mov    (%rax),%edx
call   1050 <fseek@plt>
cmpl   $0x3,-0x14(%rbp)
jne    1271 <modificar+0x111>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x9,%esi
mov    $0x1,%edx
call   1080 <fwrite@plt>
jmp    1288 <modificar+0x128>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x7,%esi
mov    $0x1,%edx
call   1080 <fwrite@plt>
jmp    128d <modificar+0x12d>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<modificar>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r9d,%r12d
mov    %r8d,%r15d
mov    %rcx,%r14
mov    %edx,%ebp
mov    %rsi,%rdi
lea    0xe83(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11b9 <modificar+0x59>
lea    0xe72(%rip),%rsi
mov    %r14,%rdi
call   1070 <strcat@plt>
cmp    $0x3,%ebp
je     11c7 <modificar+0x67>
cmp    $0x2,%ebp
je     11f4 <modificar+0x94>
cmp    $0x1,%ebp
jne    1206 <modificar+0xa6>
lea    (%r12,%r12,4),%eax
lea    (%r12,%rax,2),%eax
add    %eax,%r15d
add    $0x4,%r15d
jmp    1206 <modificar+0xa6>
lea    0xe4e(%rip),%rdi
call   1030 <puts@plt>
jmp    122f <modificar+0xcf>
lea    (%r12,%r12,4),%eax
lea    (%r12,%rax,2),%eax
lea    (%r15,%rax,1),%esi
add    $0x2c8,%esi
mov    0x2e00(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
call   1050 <fseek@plt>
mov    %r14,%rdi
mov    $0x9,%esi
jmp    1222 <modificar+0xc2>
lea    (%r12,%r12,4),%eax
lea    (%r12,%rax,2),%eax
add    %eax,%r15d
add    $0x166,%r15d
mov    0x2dd3(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %r15d,%esi
call   1050 <fseek@plt>
mov    %r14,%rdi
mov    $0x7,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fclose@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"r+\00"
@.str.1 = [31 x i8] c"CALENDARIO mod NO ENCONTRADO.\0A\00"
@.str.2 = [11 x i8] c"----------\00"
@SEEK_SET = global i32 0
define void @modificar(i32* %0, i8* %1, i32 %2, i8* %3, i32 %4, i32 %5) {
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i8* %3, i8** %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%13 = load i8*, i8** %8
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %7
%15 = load i32*, i32** %7
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %19
17: ; preds = %6
%18 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %59
19: ; preds = %6
%20 = load i8*, i8** %10
%21 = call i32 @strcat(i8* %20, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%22 = load i32, i32* %9
switch i32 %22, label %43 [
i32 1, label %23
i32 2, label %29
i32 3, label %36
]
23: ; preds = %19
%24 = load i32, i32* %11
%25 = load i32, i32* %12
%26 = mul nsw i32 %25, 11
%27 = add nsw i32 %24, %26
%28 = add nsw i32 %27, 4
store i32 %28, i32* %11
br label %43
29: ; preds = %19
%30 = load i32, i32* %11
%31 = add nsw i32 %30, 354
%32 = load i32, i32* %12
%33 = mul nsw i32 11, %32
%34 = add nsw i32 %31, %33
%35 = add nsw i32 %34, 4
store i32 %35, i32* %11
br label %43
36: ; preds = %19
%37 = load i32, i32* %11
%38 = add nsw i32 %37, 708
%39 = load i32, i32* %12
%40 = mul nsw i32 11, %39
%41 = add nsw i32 %38, %40
%42 = add nsw i32 %41, 4
store i32 %42, i32* %11
br label %43
43: ; preds = %19, %36, %29, %23
%44 = load i32*, i32** %7
%45 = load i32, i32* %11
%46 = load i32, i32* @SEEK_SET
%47 = call i32 @fseek(i32* %44, i32 %45, i32 %46)
%48 = load i32, i32* %9
%49 = icmp eq i32 %48, 3
br i1 %49, label %50, label %54
50: ; preds = %43
%51 = load i8*, i8** %10
%52 = load i32*, i32** %7
%53 = call i32 @fwrite(i8* %51, i32 9, i32 1, i32* %52)
br label %58
54: ; preds = %43
%55 = load i8*, i8** %10
%56 = load i32*, i32** %7
%57 = call i32 @fwrite(i8* %55, i32 7, i32 1, i32* %56)
br label %58
58: ; preds = %54, %50
br label %59
59: ; preds = %58, %17
%60 = load i32*, i32** %7
%61 = call i32 @fclose(i32* %60)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"r+\00"
@.str.2 = [11 x i8] c"----------\00"
@SEEK_SET = global i32 0
@str = [30 x i8] c"CALENDARIO mod NO ENCONTRADO.\00"
define void @modificar(i32* nocapture readnone %0, i8* nocapture %1, i32 %2, i8* %3, i32 %4, i32 %5) {
%7 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %33
11: ; preds = %6
%12 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
switch i32 %2, label %28 [
i32 1, label %13
i32 2, label %17
i32 3, label %21
]
13: ; preds = %11
%14 = mul nsw i32 %5, 11
%15 = add i32 %4, 4
%16 = add i32 %15, %14
br label %28
17: ; preds = %11
%18 = mul nsw i32 %5, 11
%19 = add i32 %4, 358
%20 = add i32 %19, %18
br label %28
21: ; preds = %11
%22 = mul nsw i32 %5, 11
%23 = add i32 %4, 712
%24 = add i32 %23, %22
%25 = load i32, i32* @SEEK_SET
%26 = tail call i32 @fseek(i32* %7, i32 %24, i32 %25)
%27 = tail call i32 @fwrite(i8* %3, i32 9, i32 1, i32* %7)
br label %33
28: ; preds = %11, %17, %13
%29 = phi i32 [ %16, %13 ], [ %20, %17 ], [ %4, %11 ]
%30 = load i32, i32* @SEEK_SET
%31 = tail call i32 @fseek(i32* %7, i32 %29, i32 %30)
%32 = tail call i32 @fwrite(i8* %3, i32 7, i32 1, i32* %7)
br label %33
33: ; preds = %21, %28, %9
%34 = tail call i32 @fclose(i32* %7)
ret void
}