#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 atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ strcat(char *, char *);
void cancel(char STRING[]) {
  char s[80];
  char date[9];
  char leftout[4];
  FILE *fp, *faltu;
  int i = 0, j = 0, k = 0;
  for (i = 0; i < 8; i++) {
    date[i] = STRING[j];
    j++;
  }
  j++;
  date[9] = '\0';
  for (i = 0; i < 3; i++) {
    leftout[i] = STRING[j];
    j++;
  }
  leftout[4] = '\0';
  k = atoi(leftout);
  char a[18] = "request/";
  a[8] = '\0';
  strcat(a, date);
  a[16] = '\0';
  fp = fopen(a, "r");
  faltu = fopen("faltu.c", "w+");
  for (i = 0; i < k - 1; i++) {
    fgets(s, 79, fp);
    fputs(s, faltu);
  }
  fgets(s, 79, fp);
  s[0] = 'c';
  fputs(s, faltu);
  while (fgets(s, 79, fp) != NULL) {
    fputs(s, faltu);
  }
  fclose(fp);
  fclose(faltu);
  fp = fopen(a, "w+");
  faltu = fopen("faltu.c", "r");
  while (fgets(s, 79, faltu) != NULL) {
    fputs(s, fp);
  }
  fclose(fp);
  fclose(faltu);
}


x86 assembly (clang, -O0):
<cancel>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x84(%rbp)
movl   $0x0,-0x88(%rbp)
movl   $0x0,-0x8c(%rbp)
movl   $0x0,-0x84(%rbp)
cmpl   $0x8,-0x84(%rbp)
jge    11e0 <cancel+0x80>
mov    -0x8(%rbp),%rax
movslq -0x88(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x84(%rbp),%rax
mov    %cl,-0x69(%rbp,%rax,1)
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    1197 <cancel+0x37>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
movb   $0x0,-0x60(%rbp)
movl   $0x0,-0x84(%rbp)
cmpl   $0x3,-0x84(%rbp)
jge    1246 <cancel+0xe6>
mov    -0x8(%rbp),%rax
movslq -0x88(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x84(%rbp),%rax
mov    %cl,-0x6d(%rbp,%rax,1)
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    11fd <cancel+0x9d>
movb   $0x0,-0x69(%rbp)
lea    -0x6d(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x8c(%rbp)
mov    0xda0(%rip),%rax
mov    %rax,-0xa0(%rbp)
mov    0xd9a(%rip),%rax
mov    %rax,-0x98(%rbp)
mov    0xd94(%rip),%ax
mov    %ax,-0x90(%rbp)
movb   $0x0,-0x98(%rbp)
lea    -0xa0(%rbp),%rdi
lea    -0x69(%rbp),%rsi
call   1080 <strcat@plt>
movb   $0x0,-0x90(%rbp)
lea    -0xa0(%rbp),%rdi
lea    0xd63(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x78(%rbp)
lea    0xd55(%rip),%rdi
lea    0xd56(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x80(%rbp)
movl   $0x0,-0x84(%rbp)
mov    -0x84(%rbp),%eax
mov    -0x8c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1323 <cancel+0x1c3>
lea    -0x60(%rbp),%rdi
mov    -0x78(%rbp),%rdx
mov    $0x4f,%esi
call   1050 <fgets@plt>
lea    -0x60(%rbp),%rdi
mov    -0x80(%rbp),%rsi
call   1040 <fputs@plt>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    12d9 <cancel+0x179>
lea    -0x60(%rbp),%rdi
mov    -0x78(%rbp),%rdx
mov    $0x4f,%esi
call   1050 <fgets@plt>
movb   $0x63,-0x60(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x80(%rbp),%rsi
call   1040 <fputs@plt>
lea    -0x60(%rbp),%rdi
mov    -0x78(%rbp),%rdx
mov    $0x4f,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1374 <cancel+0x214>
lea    -0x60(%rbp),%rdi
mov    -0x80(%rbp),%rsi
call   1040 <fputs@plt>
jmp    1346 <cancel+0x1e6>
mov    -0x78(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x80(%rbp),%rdi
call   1030 <fclose@plt>
lea    -0xa0(%rbp),%rdi
lea    0xc88(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x78(%rbp)
lea    0xc70(%rip),%rdi
lea    0xc67(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x80(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x80(%rbp),%rdx
mov    $0x4f,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     13e2 <cancel+0x282>
lea    -0x60(%rbp),%rdi
mov    -0x78(%rbp),%rsi
call   1040 <fputs@plt>
jmp    13b4 <cancel+0x254>
mov    -0x78(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x80(%rbp),%rdi
call   1030 <fclose@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cancel>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x98,%rsp
mov    (%rdi),%rax
mov    %rax,0x30(%rsp)
movb   $0x0,0x39(%rsp)
movzwl 0x9(%rdi),%eax
mov    %ax,0xc(%rsp)
mov    0xb(%rdi),%al
mov    %al,0xe(%rsp)
movb   $0x0,0x10(%rsp)
lea    0xc(%rsp),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
movaps 0xe5e(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movw   $0x0,0x20(%rsp)
movb   $0x0,0x18(%rsp)
lea    0x10(%rsp),%rbx
lea    0x30(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
movb   $0x0,0x20(%rsp)
lea    0xe41(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
mov    %rax,%r14
lea    0xe31(%rip),%rdi
lea    0xe32(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
cmp    $0x2,%ebp
jl     1220 <cancel+0xc0>
add    $0xffffffff,%ebp
lea    0x40(%rsp),%r15
nop
mov    %r15,%rdi
mov    $0x4f,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <fputs@plt>
add    $0xffffffff,%ebp
jne    1200 <cancel+0xa0>
lea    0x40(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x4f,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
movb   $0x63,0x40(%rsp)
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <fputs@plt>
mov    %rbp,%rdi
mov    $0x4f,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1280 <cancel+0x120>
lea    0x40(%rsp),%rbp
nop
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <fputs@plt>
mov    %rbp,%rdi
mov    $0x4f,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    1260 <cancel+0x100>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xd85(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1060 <fopen@plt>
mov    %rax,%r14
lea    0xd69(%rip),%rdi
lea    0xd60(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbp
lea    0x40(%rsp),%rdi
mov    $0x4f,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1300 <cancel+0x1a0>
lea    0x40(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <fputs@plt>
mov    %rbx,%rdi
mov    $0x4f,%esi
mov    %rbp,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    12e0 <cancel+0x180>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %rbp,%rdi
call   1030 <fclose@plt>
add    $0x98,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.cancel.a = [18 x i8] c"request/\00\00\00\00\00\00\00\00\00\00"
@.str = [2 x i8] c"r\00"
@.str.1 = [8 x i8] c"faltu.c\00"
@.str.2 = [3 x i8] c"w+\00"
define void @cancel(i8* %0) {
%2 = alloca i8*
%3 = alloca [80 x i8]
%4 = alloca [9 x i8]
%5 = alloca [4 x i8]
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [18 x i8]
store i8* %0, i8** %2
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %8
br label %12
12: ; preds = %26, %1
%13 = load i32, i32* %8
%14 = icmp slt i32 %13, 8
br i1 %14, label %15, label %29
15: ; preds = %12
%16 = load i8*, i8** %2
%17 = load i32, i32* %9
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = load i32, i32* %8
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 %22
store i8 %20, i8* %23
%24 = load i32, i32* %9
%25 = add nsw i32 %24, 1
store i32 %25, i32* %9
br label %26
26: ; preds = %15
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
store i32 %28, i32* %8
br label %12
29: ; preds = %12
%30 = load i32, i32* %9
%31 = add nsw i32 %30, 1
store i32 %31, i32* %9
%32 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 9
store i8 0, i8* %32
store i32 0, i32* %8
br label %33
33: ; preds = %47, %29
%34 = load i32, i32* %8
%35 = icmp slt i32 %34, 3
br i1 %35, label %36, label %50
36: ; preds = %33
%37 = load i8*, i8** %2
%38 = load i32, i32* %9
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
%41 = load i8, i8* %40
%42 = load i32, i32* %8
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 %43
store i8 %41, i8* %44
%45 = load i32, i32* %9
%46 = add nsw i32 %45, 1
store i32 %46, i32* %9
br label %47
47: ; preds = %36
%48 = load i32, i32* %8
%49 = add nsw i32 %48, 1
store i32 %49, i32* %8
br label %33
50: ; preds = %33
%51 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 4
store i8 0, i8* %51
%52 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%53 = call i32 @atoi(i8* %52)
store i32 %53, i32* %10
%54 = bitcast [18 x i8]* %11 to i8*
%55 = getelementptr inbounds [18 x i8], [18 x i8]* %11, i64 0, i64 8
store i8 0, i8* %55
%56 = getelementptr inbounds [18 x i8], [18 x i8]* %11, i64 0, i64 0
%57 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
%58 = call i32 @strcat(i8* %56, i8* %57)
%59 = getelementptr inbounds [18 x i8], [18 x i8]* %11, i64 0, i64 16
store i8 0, i8* %59
%60 = getelementptr inbounds [18 x i8], [18 x i8]* %11, i64 0, i64 0
%61 = call i32* @fopen(i8* %60, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %61, i32** %6
%62 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %62, i32** %7
store i32 0, i32* %8
br label %63
63: ; preds = %75, %50
%64 = load i32, i32* %8
%65 = load i32, i32* %10
%66 = sub nsw i32 %65, 1
%67 = icmp slt i32 %64, %66
br i1 %67, label %68, label %78
68: ; preds = %63
%69 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%70 = load i32*, i32** %6
%71 = call i32* @fgets(i8* %69, i32 79, i32* %70)
%72 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%73 = load i32*, i32** %7
%74 = call i32 @fputs(i8* %72, i32* %73)
br label %75
75: ; preds = %68
%76 = load i32, i32* %8
%77 = add nsw i32 %76, 1
store i32 %77, i32* %8
br label %63
78: ; preds = %63
%79 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%80 = load i32*, i32** %6
%81 = call i32* @fgets(i8* %79, i32 79, i32* %80)
%82 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
store i8 99, i8* %82
%83 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%84 = load i32*, i32** %7
%85 = call i32 @fputs(i8* %83, i32* %84)
br label %86
86: ; preds = %91, %78
%87 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%88 = load i32*, i32** %6
%89 = call i32* @fgets(i8* %87, i32 79, i32* %88)
%90 = icmp ne i32* %89, null
br i1 %90, label %91, label %95
91: ; preds = %86
%92 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%93 = load i32*, i32** %7
%94 = call i32 @fputs(i8* %92, i32* %93)
br label %86
95: ; preds = %86
%96 = load i32*, i32** %6
%97 = call i32 @fclose(i32* %96)
%98 = load i32*, i32** %7
%99 = call i32 @fclose(i32* %98)
%100 = getelementptr inbounds [18 x i8], [18 x i8]* %11, i64 0, i64 0
%101 = call i32* @fopen(i8* %100, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %101, i32** %6
%102 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %102, i32** %7
br label %103
103: ; preds = %108, %95
%104 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%105 = load i32*, i32** %7
%106 = call i32* @fgets(i8* %104, i32 79, i32* %105)
%107 = icmp ne i32* %106, null
br i1 %107, label %108, label %112
108: ; preds = %103
%109 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%110 = load i32*, i32** %6
%111 = call i32 @fputs(i8* %109, i32* %110)
br label %103
112: ; preds = %103
%113 = load i32*, i32** %6
%114 = call i32 @fclose(i32* %113)
%115 = load i32*, i32** %7
%116 = call i32 @fclose(i32* %115)
ret void
}

LLVM IR (-O2):
@__const.cancel.a = [18 x i8] c"request/\00\00\00\00\00\00\00\00\00\00"
@.str = [2 x i8] c"r\00"
@.str.1 = [8 x i8] c"faltu.c\00"
@.str.2 = [3 x i8] c"w+\00"
define void @cancel(i8* nocapture %0) {
%2 = alloca [80 x i8]
%3 = alloca [9 x i8]
%4 = alloca [4 x i8]
%5 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%6 = alloca [18 x i8]
%7 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%10 = bitcast i8* %0 to i64*
%11 = bitcast [9 x i8]* %3 to i64*
%12 = load i64, i64* %10
store i64 %12, i64* %11
%13 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 9
store i8 0, i8* %13
%14 = getelementptr i8, i8* %0, i64 9
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 4
store i8 0, i8* %15
%16 = call i32 @atoi(i8* %9)
%17 = getelementptr inbounds [18 x i8], [18 x i8]* %6, i64 0, i64 0
%18 = getelementptr inbounds [18 x i8], [18 x i8]* %6, i64 0, i64 8
store i8 0, i8* %18
%19 = call i32 @strcat(i8* %17, i8* %8)
%20 = getelementptr inbounds [18 x i8], [18 x i8]* %6, i64 0, i64 16
store i8 0, i8* %20
%21 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%22 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%23 = add i32 %16, -1
%24 = icmp sgt i32 %16, 1
br i1 %24, label %25, label %31
25: ; preds = %1, %25
%26 = phi i32 [ %29, %25 ], [ 0, %1 ]
%27 = call i32* @fgets(i8* %7, i32 79, i32* %21)
%28 = call i32 @fputs(i8* %7, i32* %22)
%29 = add nuw nsw i32 %26, 1
%30 = icmp eq i32 %29, %23
br i1 %30, label %31, label %25
31: ; preds = %25, %1
%32 = call i32* @fgets(i8* %7, i32 79, i32* %21)
store i8 99, i8* %7
%33 = call i32 @fputs(i8* %7, i32* %22)
%34 = call i32* @fgets(i8* %7, i32 79, i32* %21)
%35 = icmp eq i32* %34, null
br i1 %35, label %40, label %36
36: ; preds = %31, %36
%37 = call i32 @fputs(i8* %7, i32* %22)
%38 = call i32* @fgets(i8* %7, i32 79, i32* %21)
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %36
40: ; preds = %36, %31
%41 = call i32 @fclose(i32* %21)
%42 = call i32 @fclose(i32* %22)
%43 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%44 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%45 = call i32* @fgets(i8* %7, i32 79, i32* %44)
%46 = icmp eq i32* %45, null
br i1 %46, label %51, label %47
47: ; preds = %40, %47
%48 = call i32 @fputs(i8* %7, i32* %43)
%49 = call i32* @fgets(i8* %7, i32 79, i32* %44)
%50 = icmp eq i32* %49, null
br i1 %50, label %51, label %47
51: ; preds = %47, %40
%52 = call i32 @fclose(i32* %43)
%53 = call i32 @fclose(i32* %44)
ret void
}