#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*/ fprintf(int /*<<< orphan*/ *, char *, char *, int, int,
                           scalar_t__);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ freopen(char *, char *, int /*<<< orphan*/ *);
int getc(int /*<<< orphan*/ *);
int getpet(char *);
int gettime(char *);
scalar_t__ getweight(char *);
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 time(int /*<<< orphan*/ *);
int /*<<< orphan*/ *tmpfile();
int feed(char *name) {
  FILE *ptr, *tmp;
  char buf[64], tama[16 + 1];
  int ctr, num = 0;
  if ((time(NULL) - gettime(name)) / 3600 < 3)
    return 1;
  if ((ptr = fopen("tamas", "r")) == NULL)
    return -1;
  if ((tmp = tmpfile()) == NULL)
    return -1;
  strncpy(tama, name, 16);
  strcat(tama, ":");
  while (fgets(buf, 64, ptr) != NULL) {
    if (strstr(buf, tama) == buf) {
      for (ctr = 0; ctr < 64; ctr++) {
        if (buf[ctr] == ':')
          num++;
        if (num == 3)
          break;
      }
      buf[ctr + 1] = '\0';
      fprintf(tmp, "%s%d:%d:%d:\n", buf, (int)time(NULL), getpet(name),
              getweight(name) + 1);
      continue;
    }
    fputs(buf, tmp);
  }
  freopen("tamas", "w", ptr);
  rewind(tmp);
  while ((ctr = getc(tmp)) != EOF)
    putc(ctr, ptr);
  fclose(ptr);
  fclose(tmp);
  return 0;
}


x86 assembly (clang, -O0):
<feed>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x88(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   10e0 <time@plt>
mov    %eax,-0x8c(%rbp)
mov    -0x10(%rbp),%rdi
call   1130 <gettime@plt>
mov    %eax,%ecx
mov    -0x8c(%rbp),%eax
sub    %ecx,%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
cmp    $0x3,%eax
jge    1268 <feed+0x58>
movl   $0x1,-0x4(%rbp)
jmp    1471 <feed+0x261>
lea    0xd91(%rip),%rdi
lea    0xd90(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1295 <feed+0x85>
movl   $0xffffffff,-0x4(%rbp)
jmp    1471 <feed+0x261>
mov    $0x0,%al
call   10a0 <tmpfile@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    12b6 <feed+0xa6>
movl   $0xffffffff,-0x4(%rbp)
jmp    1471 <feed+0x261>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x10,%edx
call   1030 <strncpy@plt>
lea    -0x80(%rbp),%rdi
lea    0xd35(%rip),%rsi
call   1100 <strcat@plt>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x40,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     1406 <feed+0x1f6>
lea    -0x60(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1120 <strstr@plt>
lea    -0x60(%rbp),%rcx
cmp    %rcx,%rax
jne    13f4 <feed+0x1e4>
movl   $0x0,-0x84(%rbp)
cmpl   $0x40,-0x84(%rbp)
jge    1374 <feed+0x164>
movslq -0x84(%rbp),%rax
movsbl -0x60(%rbp,%rax,1),%eax
cmp    $0x3a,%eax
jne    1349 <feed+0x139>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
cmpl   $0x3,-0x88(%rbp)
jne    135b <feed+0x14b>
jmp    1374 <feed+0x164>
jmp    1360 <feed+0x150>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    1318 <feed+0x108>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,-0x60(%rbp,%rax,1)
mov    -0x20(%rbp),%rax
mov    %rax,-0xa8(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0xa0(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   10e0 <time@plt>
mov    %eax,-0x94(%rbp)
mov    -0x10(%rbp),%rdi
call   10c0 <getpet@plt>
mov    %eax,-0x90(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <getweight@plt>
mov    -0xa8(%rbp),%rdi
mov    -0xa0(%rbp),%rdx
mov    -0x94(%rbp),%ecx
mov    -0x90(%rbp),%r8d
mov    %rax,%r9
add    $0x1,%r9
lea    0xc20(%rip),%rsi
call   10d0 <fprintf@plt>
jmp    12d8 <feed+0xc8>
lea    -0x60(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <fputs@plt>
jmp    12d8 <feed+0xc8>
mov    -0x18(%rbp),%rdx
lea    0xbef(%rip),%rdi
lea    0xbff(%rip),%rsi
call   1080 <freopen@plt>
mov    -0x20(%rbp),%rdi
call   1060 <rewind@plt>
mov    -0x20(%rbp),%rdi
call   1110 <getc@plt>
mov    %eax,-0x84(%rbp)
mov    0x2bac(%rip),%rcx
cmp    (%rcx),%eax
je     1458 <feed+0x248>
mov    -0x84(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   10b0 <putc@plt>
jmp    1426 <feed+0x216>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<feed>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rdi,%r15
xor    %edi,%edi
call   1100 <time@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1140 <gettime@plt>
sub    %eax,%ebp
mov    $0x1,%ebx
cmp    $0x2a30,%ebp
jl     1418 <feed+0x1f8>
lea    0xda4(%rip),%rdi
lea    0xda3(%rip),%rsi
call   1110 <fopen@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
je     1418 <feed+0x1f8>
mov    %rax,%r13
xor    %eax,%eax
call   10c0 <tmpfile@plt>
test   %rax,%rax
je     1418 <feed+0x1f8>
mov    %rax,%r14
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x10,%edx
call   1030 <strncpy@plt>
lea    0xd60(%rip),%rsi
mov    %rbx,%rdi
call   1120 <strcat@plt>
lea    0x30(%rsp),%rdi
mov    $0x40,%esi
mov    %r13,%rdx
call   10b0 <fgets@plt>
test   %rax,%rax
je     13b5 <feed+0x195>
xor    %ebp,%ebp
lea    0x10(%rsp),%r12
lea    0x30(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1070 <strlen@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %rax,%rdx
call   1040 <strncmp@plt>
test   %eax,%eax
je     131f <feed+0xff>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <fputs@plt>
mov    %rbx,%rdi
mov    $0x40,%esi
mov    %r13,%rdx
call   10b0 <fgets@plt>
test   %rax,%rax
jne    12e0 <feed+0xc0>
jmp    13b5 <feed+0x195>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%ecx
xor    %ebp,%ebp
cmpb   $0x3a,0x30(%rsp,%rax,1)
sete   %bpl
add    %ecx,%ebp
cmp    $0x3,%ebp
je     136a <feed+0x14a>
xor    %ecx,%ecx
cmpb   $0x3a,0x31(%rsp,%rax,1)
sete   %cl
add    %ecx,%ebp
cmp    $0x3,%ebp
je     1366 <feed+0x146>
add    $0x2,%rax
cmp    $0x40,%rax
jne    1330 <feed+0x110>
mov    $0x40,%eax
jmp    136a <feed+0x14a>
add    $0x1,%rax
add    $0x1,%eax
movb   $0x0,0x30(%rsp,%rax,1)
xor    %edi,%edi
call   1100 <time@plt>
mov    %eax,0xc(%rsp)
mov    %r15,%rdi
call   10e0 <getpet@plt>
mov    %eax,0x8(%rsp)
mov    %r15,%rdi
call   1050 <getweight@plt>
lea    0x1(%rax),%r9
mov    %r14,%rdi
lea    0xc6b(%rip),%rsi
mov    %rbx,%rdx
mov    0xc(%rsp),%ecx
mov    0x8(%rsp),%r8d
call   10f0 <fprintf@plt>
jmp    1305 <feed+0xe5>
lea    0xc44(%rip),%rdi
lea    0xc54(%rip),%rsi
mov    %r13,%rdx
call   10a0 <freopen@plt>
mov    %r14,%rdi
call   1080 <rewind@plt>
mov    %r14,%rdi
call   1130 <getc@plt>
mov    0x2c06(%rip),%rbx
cmp    (%rbx),%eax
je     1406 <feed+0x1e6>
cs nopw 0x0(%rax,%rax,1)
mov    %eax,%edi
mov    %r13,%rsi
call   10d0 <putc@plt>
mov    %r14,%rdi
call   1130 <getc@plt>
cmp    (%rbx),%eax
jne    13f0 <feed+0x1d0>
mov    %r13,%rdi
call   1060 <fclose@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
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 = [13 x i8] c"%s%d:%d:%d:\0A\00"
@.str.4 = [2 x i8] c"w\00"
@EOF = global i32 0
define i32 @feed(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca [64 x i8]
%7 = alloca [17 x i8]
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %9
%10 = call i32 @time(i32* null)
%11 = load i8*, i8** %3
%12 = call i32 @gettime(i8* %11)
%13 = sub nsw i32 %10, %12
%14 = sdiv i32 %13, 3600
%15 = icmp slt i32 %14, 3
br i1 %15, label %16, label %17
16: ; preds = %1
store i32 1, i32* %2
br label %101
17: ; preds = %1
%18 = 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* %18, i32** %4
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %21
20: ; preds = %17
store i32 -1, i32* %2
br label %101
21: ; preds = %17
%22 = call i32* (...) @tmpfile()
store i32* %22, i32** %5
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %25
24: ; preds = %21
store i32 -1, i32* %2
br label %101
25: ; preds = %21
%26 = getelementptr inbounds [17 x i8], [17 x i8]* %7, i64 0, i64 0
%27 = load i8*, i8** %3
%28 = call i32 @strncpy(i8* %26, i8* %27, i32 16)
%29 = getelementptr inbounds [17 x i8], [17 x i8]* %7, i64 0, i64 0
%30 = call i32 @strcat(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %31
31: ; preds = %78, %64, %25
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%33 = load i32*, i32** %4
%34 = call i32* @fgets(i8* %32, i32 64, i32* %33)
%35 = icmp ne i32* %34, null
br i1 %35, label %36, label %82
36: ; preds = %31
%37 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%38 = getelementptr inbounds [17 x i8], [17 x i8]* %7, i64 0, i64 0
%39 = call i8* @strstr(i8* %37, i8* %38)
%40 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%41 = icmp eq i8* %39, %40
br i1 %41, label %42, label %78
42: ; preds = %36
store i32 0, i32* %8
br label %43
43: ; preds = %61, %42
%44 = load i32, i32* %8
%45 = icmp slt i32 %44, 64
br i1 %45, label %46, label %64
46: ; preds = %43
%47 = load i32, i32* %8
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 58
br i1 %52, label %53, label %56
53: ; preds = %46
%54 = load i32, i32* %9
%55 = add nsw i32 %54, 1
store i32 %55, i32* %9
br label %56
56: ; preds = %53, %46
%57 = load i32, i32* %9
%58 = icmp eq i32 %57, 3
br i1 %58, label %59, label %60
59: ; preds = %56
br label %64
60: ; preds = %56
br label %61
61: ; preds = %60
%62 = load i32, i32* %8
%63 = add nsw i32 %62, 1
store i32 %63, i32* %8
br label %43
64: ; preds = %59, %43
%65 = load i32, i32* %8
%66 = add nsw i32 %65, 1
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %67
store i8 0, i8* %68
%69 = load i32*, i32** %5
%70 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%71 = call i32 @time(i32* null)
%72 = load i8*, i8** %3
%73 = call i32 @getpet(i8* %72)
%74 = load i8*, i8** %3
%75 = call i64 @getweight(i8* %74)
%76 = add nsw i64 %75, 1
%77 = call i32 @fprintf(i32* %69, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %70, i32 %71, i32 %73, i64 %76)
br label %31
78: ; preds = %36
%79 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%80 = load i32*, i32** %5
%81 = call i32 @fputs(i8* %79, i32* %80)
br label %31
82: ; preds = %31
%83 = load i32*, i32** %4
%84 = 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.4, i64 0, i64 0), i32* %83)
%85 = load i32*, i32** %5
%86 = call i32 @rewind(i32* %85)
br label %87
87: ; preds = %92, %82
%88 = load i32*, i32** %5
%89 = call i32 @getc(i32* %88)
store i32 %89, i32* %8
%90 = load i32, i32* @EOF
%91 = icmp ne i32 %89, %90
br i1 %91, label %92, label %96
92: ; preds = %87
%93 = load i32, i32* %8
%94 = load i32*, i32** %4
%95 = call i32 @putc(i32 %93, i32* %94)
br label %87
96: ; preds = %87
%97 = load i32*, i32** %4
%98 = call i32 @fclose(i32* %97)
%99 = load i32*, i32** %5
%100 = call i32 @fclose(i32* %99)
store i32 0, i32* %2
br label %101
101: ; preds = %96, %24, %20, %16
%102 = load i32, i32* %2
ret i32 %102
}

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 = [13 x i8] c"%s%d:%d:%d:\0A\00"
@.str.4 = [2 x i8] c"w\00"
@EOF = global i32 0
define i32 @feed(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 @time(i32* null)
%7 = tail call i32 @gettime(i8* %0)
%8 = sub nsw i32 %6, %7
%9 = icmp slt i32 %8, 10800
br i1 %9, label %79, label %10
10: ; preds = %1
%11 = 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))
%12 = icmp eq i32* %11, null
br i1 %12, label %79, label %13
13: ; preds = %10
%14 = tail call i32* (...) @tmpfile()
%15 = icmp eq i32* %14, null
br i1 %15, label %79, label %16
16: ; preds = %13
%17 = call i32 @strncpy(i8* %5, i8* %0, i32 16)
%18 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32* @fgets(i8* %4, i32 64, i32* %11)
%20 = icmp eq i32* %19, null
br i1 %20, label %64, label %21
21: ; preds = %16, %47
%22 = phi i32 [ %48, %47 ], [ 0, %16 ]
br label %23
23: ; preds = %21, %60
%24 = call i64 @strlen(i8* %5)
%25 = call i32 @strncmp(i8* %4, i8* %5, i64 %24)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %60
27: ; preds = %23, %44
%28 = phi i64 [ %45, %44 ], [ 0, %23 ]
%29 = phi i32 [ %42, %44 ], [ %22, %23 ]
%30 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 %28
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 58
%33 = zext i1 %32 to i32
%34 = add nsw i32 %29, %33
%35 = icmp eq i32 %34, 3
br i1 %35, label %47, label %36
36: ; preds = %27
%37 = or i64 %28, 1
%38 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = icmp eq i8 %39, 58
%41 = zext i1 %40 to i32
%42 = add nsw i32 %34, %41
%43 = icmp eq i32 %42, 3
br i1 %43, label %47, label %44
44: ; preds = %36
%45 = add nuw nsw i64 %28, 2
%46 = icmp eq i64 %45, 64
br i1 %46, label %47, label %27
47: ; preds = %44, %36, %27
%48 = phi i32 [ %34, %27 ], [ %42, %36 ], [ %42, %44 ]
%49 = phi i64 [ %28, %27 ], [ %37, %36 ], [ 64, %44 ]
%50 = add nuw i64 %49, 1
%51 = and i64 %50, 4294967295
%52 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 %51
store i8 0, i8* %52
%53 = call i32 @time(i32* null)
%54 = call i32 @getpet(i8* %0)
%55 = call i64 @getweight(i8* %0)
%56 = add nsw i64 %55, 1
%57 = call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %4, i32 %53, i32 %54, i64 %56)
%58 = call i32* @fgets(i8* %4, i32 64, i32* %11)
%59 = icmp eq i32* %58, null
br i1 %59, label %64, label %21
60: ; preds = %23
%61 = call i32 @fputs(i8* %4, i32* %14)
%62 = call i32* @fgets(i8* %4, i32 64, i32* %11)
%63 = icmp eq i32* %62, null
br i1 %63, label %64, label %23
64: ; preds = %47, %60, %16
%65 = 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.4, i64 0, i64 0), i32* %11)
%66 = call i32 @rewind(i32* %14)
%67 = call i32 @getc(i32* %14)
%68 = load i32, i32* @EOF
%69 = icmp eq i32 %67, %68
br i1 %69, label %76, label %70
70: ; preds = %64, %70
%71 = phi i32 [ %73, %70 ], [ %67, %64 ]
%72 = call i32 @putc(i32 %71, i32* %11)
%73 = call i32 @getc(i32* %14)
%74 = load i32, i32* @EOF
%75 = icmp eq i32 %73, %74
br i1 %75, label %76, label %70
76: ; preds = %70, %64
%77 = call i32 @fclose(i32* %11)
%78 = call i32 @fclose(i32* %14)
br label %79
79: ; preds = %13, %10, %1, %76
%80 = phi i32 [ 0, %76 ], [ 1, %1 ], [ -1, %10 ], [ -1, %13 ]
ret i32 %80
}