#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 EOF;
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*/ freopen(char *, char *, int /*<<< orphan*/ *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstr(char *, char *);
int /*<<< orphan*/ *tmpfile();
void del(char *name) {
  FILE *ptr, *tmp;
  char buf[64], tama[16 + 1];
  int ctr;
  if ((ptr = fopen("tamas", "r")) == NULL)
    return;
  if ((tmp = tmpfile()) == NULL)
    return;
  strncpy(tama, name, 16);
  strcat(tama, ":");
  while (fgets(buf, 64, ptr) != NULL) {
    if (strstr(buf, tama) == buf)
      continue;
    fputs(buf, tmp);
  }
  freopen("tamas", "w", ptr);
  rewind(tmp);
  while ((ctr = getc(tmp)) != EOF)
    putc(ctr, ptr);
  fclose(ptr);
  fclose(tmp);
  return;
}


x86 assembly (clang, -O0):
<del>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe2a(%rip),%rdi
lea    0xe29(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11f5 <del+0x35>
jmp    12e2 <del+0x122>
mov    $0x0,%al
call   1090 <tmpfile@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    120f <del+0x4f>
jmp    12e2 <del+0x122>
lea    -0x80(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x10,%edx
call   1030 <strncpy@plt>
lea    -0x80(%rbp),%rdi
lea    0xddc(%rip),%rsi
call   10c0 <strcat@plt>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x40,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     127e <del+0xbe>
lea    -0x60(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   10e0 <strstr@plt>
lea    -0x60(%rbp),%rcx
cmp    %rcx,%rax
jne    126c <del+0xac>
jmp    1231 <del+0x71>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <fputs@plt>
jmp    1231 <del+0x71>
mov    -0x10(%rbp),%rdx
lea    0xd77(%rip),%rdi
lea    0xd7a(%rip),%rsi
call   1070 <freopen@plt>
mov    -0x18(%rbp),%rdi
call   1050 <rewind@plt>
mov    -0x18(%rbp),%rdi
call   10d0 <getc@plt>
mov    %eax,-0x84(%rbp)
mov    0x2d34(%rip),%rcx
cmp    (%rcx),%eax
je     12d0 <del+0x110>
mov    -0x84(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   10a0 <putc@plt>
jmp    129e <del+0xde>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<del>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rdi,%rbx
lea    0xe1b(%rip),%rdi
lea    0xe1a(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     12f6 <del+0x126>
mov    %rax,%r15
xor    %eax,%eax
call   10b0 <tmpfile@plt>
test   %rax,%rax
je     12f6 <del+0x126>
mov    %rax,%r14
mov    %rsp,%r12
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x10,%edx
call   1030 <strncpy@plt>
lea    0xdde(%rip),%rsi
mov    %r12,%rdi
call   10e0 <strcat@plt>
lea    0x20(%rsp),%rdi
mov    $0x40,%esi
mov    %r15,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     129c <del+0xcc>
mov    %rsp,%r12
lea    0x20(%rsp),%rbx
jmp    1275 <del+0xa5>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    $0x40,%esi
mov    %r15,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     129c <del+0xcc>
mov    %r12,%rdi
call   1060 <strlen@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %rax,%rdx
call   1040 <strncmp@plt>
test   %eax,%eax
je     1260 <del+0x90>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <fputs@plt>
jmp    1260 <del+0x90>
lea    0xd5d(%rip),%rdi
lea    0xd60(%rip),%rsi
mov    %r15,%rdx
call   1090 <freopen@plt>
mov    %r14,%rdi
call   1070 <rewind@plt>
mov    %r14,%rdi
call   10f0 <getc@plt>
mov    0x2d1f(%rip),%rbx
cmp    (%rbx),%eax
je     12e6 <del+0x116>
nopl   (%rax)
mov    %eax,%edi
mov    %r15,%rsi
call   10c0 <putc@plt>
mov    %r14,%rdi
call   10f0 <getc@plt>
cmp    (%rbx),%eax
jne    12d0 <del+0x100>
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"tamas\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c":\00"
@.str.3 = [2 x i8] c"w\00"
@EOF = global i32 0
define void @del(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [64 x i8]
%6 = alloca [17 x i8]
%7 = alloca i32
store i8* %0, i8** %2
%8 = call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %3
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %11
10: ; preds = %1
br label %56
11: ; preds = %1
%12 = call i32* (...) @tmpfile()
store i32* %12, i32** %4
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %15
14: ; preds = %11
br label %56
15: ; preds = %11
%16 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%17 = load i8*, i8** %2
%18 = call i32 @strncpy(i8* %16, i8* %17, i32 16)
%19 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%20 = call i32 @strcat(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %33, %32, %15
%22 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%23 = load i32*, i32** %3
%24 = call i32* @fgets(i8* %22, i32 64, i32* %23)
%25 = icmp ne i32* %24, null
br i1 %25, label %26, label %37
26: ; preds = %21
%27 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%28 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%29 = call i8* @strstr(i8* %27, i8* %28)
%30 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%31 = icmp eq i8* %29, %30
br i1 %31, label %32, label %33
32: ; preds = %26
br label %21
33: ; preds = %26
%34 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%35 = load i32*, i32** %4
%36 = call i32 @fputs(i8* %34, i32* %35)
br label %21
37: ; preds = %21
%38 = load i32*, i32** %3
%39 = call i32 @freopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32* %38)
%40 = load i32*, i32** %4
%41 = call i32 @rewind(i32* %40)
br label %42
42: ; preds = %47, %37
%43 = load i32*, i32** %4
%44 = call i32 @getc(i32* %43)
store i32 %44, i32* %7
%45 = load i32, i32* @EOF
%46 = icmp ne i32 %44, %45
br i1 %46, label %47, label %51
47: ; preds = %42
%48 = load i32, i32* %7
%49 = load i32*, i32** %3
%50 = call i32 @putc(i32 %48, i32* %49)
br label %42
51: ; preds = %42
%52 = load i32*, i32** %3
%53 = call i32 @fclose(i32* %52)
%54 = load i32*, i32** %4
%55 = call i32 @fclose(i32* %54)
br label %56
56: ; preds = %51, %14, %10
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"tamas\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c":\00"
@.str.3 = [2 x i8] c"w\00"
@EOF = global i32 0
define void @del(i8* %0) {
%2 = alloca [64 x i8]
%3 = alloca [17 x i8]
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 0
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %40, label %8
8: ; preds = %1
%9 = tail call i32* (...) @tmpfile()
%10 = icmp eq i32* %9, null
br i1 %10, label %40, label %11
11: ; preds = %8
%12 = call i32 @strncpy(i8* %5, i8* %0, i32 16)
%13 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32* @fgets(i8* %4, i32 64, i32* %6)
%15 = icmp eq i32* %14, null
br i1 %15, label %25, label %16
16: ; preds = %11, %22
%17 = call i64 @strlen(i8* %5)
%18 = call i32 @strncmp(i8* %4, i8* %5, i64 %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %16
%21 = call i32 @fputs(i8* %4, i32* %9)
br label %22
22: ; preds = %20, %16
%23 = call i32* @fgets(i8* %4, i32 64, i32* %6)
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %16
25: ; preds = %22, %11
%26 = call i32 @freopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32* %6)
%27 = call i32 @rewind(i32* %9)
%28 = call i32 @getc(i32* %9)
%29 = load i32, i32* @EOF
%30 = icmp eq i32 %28, %29
br i1 %30, label %37, label %31
31: ; preds = %25, %31
%32 = phi i32 [ %34, %31 ], [ %28, %25 ]
%33 = call i32 @putc(i32 %32, i32* %6)
%34 = call i32 @getc(i32* %9)
%35 = load i32, i32* @EOF
%36 = icmp eq i32 %34, %35
br i1 %36, label %37, label %31
37: ; preds = %31, %25
%38 = call i32 @fclose(i32* %6)
%39 = call i32 @fclose(i32* %9)
br label %40
40: ; preds = %8, %1, %37
ret void
}