#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*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getbirth(char *);
int gettime(char *);
int getweight(char *);
int /*<<< orphan*/ put(char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int strlen(char *);
int time(int /*<<< orphan*/ *);
void list() {
  char buf[64], tmp[64];
  unsigned int ctr, num = 0;
  FILE *ptr;
  if ((ptr = fopen("tamas", "r")) == NULL) {
    put("Error: Can't open Tamagotchi file. Please try again later.\n");
    return;
  }
  put("\nName\t\tAge\n-------------------------------\n");
  while (fgets(buf, 64, ptr) != NULL) {
    for (ctr = 0; ctr < 64; ctr++)
      if (buf[ctr] == ':') {
        buf[ctr] = 0;
        break;
      }
    if ((time(NULL) - gettime(buf)) / 3600 - getweight(buf) > 48)
      continue;
    num++;
    if (num == 20)
      break;
    put(buf);
    if (strlen(buf) < 8)
      put("\t\t");
    else
      put("\t");
    sprintf(tmp, "%d hours\n", ((int)time(NULL) - getbirth(buf)) / 3600);
    put(tmp);
  }
  fclose(ptr);
  put("\n");
  return;
}


x86 assembly (clang, -O0):
<list>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x88(%rbp)
lea    0xe44(%rip),%rdi
lea    0xe43(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x90(%rbp)
cmp    $0x0,%rax
jne    11ea <list+0x4a>
lea    0xe28(%rip),%rdi
call   1040 <put@plt>
jmp    1383 <list+0x1e3>
lea    0xe53(%rip),%rdi
call   1040 <put@plt>
lea    -0x40(%rbp),%rdi
mov    -0x90(%rbp),%rdx
mov    $0x40,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     136b <list+0x1cb>
movl   $0x0,-0x84(%rbp)
cmpl   $0x40,-0x84(%rbp)
jae    1269 <list+0xc9>
mov    -0x84(%rbp),%eax
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x3a,%eax
jne    1250 <list+0xb0>
mov    -0x84(%rbp),%eax
movb   $0x0,-0x40(%rbp,%rax,1)
jmp    1269 <list+0xc9>
jmp    1255 <list+0xb5>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    121f <list+0x7f>
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    %eax,-0x98(%rbp)
lea    -0x40(%rbp),%rdi
call   10c0 <gettime@plt>
mov    %eax,%ecx
mov    -0x98(%rbp),%eax
sub    %ecx,%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,-0x94(%rbp)
lea    -0x40(%rbp),%rdi
call   1030 <getweight@plt>
mov    %eax,%ecx
mov    -0x94(%rbp),%eax
sub    %ecx,%eax
cmp    $0x30,%eax
jle    12ba <list+0x11a>
jmp    11f6 <list+0x56>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
cmpl   $0x14,-0x88(%rbp)
jne    12db <list+0x13b>
jmp    136b <list+0x1cb>
lea    -0x40(%rbp),%rdi
call   1040 <put@plt>
lea    -0x40(%rbp),%rdi
call   1070 <strlen@plt>
cmp    $0x8,%eax
jge    1307 <list+0x167>
lea    0xd73(%rip),%rdi
call   1040 <put@plt>
jmp    1313 <list+0x173>
lea    0xd63(%rip),%rdi
call   1040 <put@plt>
lea    -0x80(%rbp),%rax
mov    %rax,-0xa8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    %eax,-0x9c(%rbp)
lea    -0x40(%rbp),%rdi
call   1060 <getbirth@plt>
mov    -0xa8(%rbp),%rdi
mov    %eax,%ecx
mov    -0x9c(%rbp),%eax
sub    %ecx,%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
lea    0xd1b(%rip),%rsi
call   10b0 <sprintf@plt>
lea    -0x80(%rbp),%rdi
call   1040 <put@plt>
jmp    11f6 <list+0x56>
mov    -0x90(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xcf0(%rip),%rdi
call   1040 <put@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<list>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
lea    0xe48(%rip),%rdi
lea    0xe47(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     133b <list+0x19b>
mov    %rax,%r14
lea    0xe6d(%rip),%rdi
call   1040 <put@plt>
xor    %r13d,%r13d
mov    %rsp,%rbx
lea    0xe8a(%rip),%r15
lea    0x40(%rsp),%r12
jmp    1236 <list+0x96>
add    $0x1,%rax
mov    %eax,%eax
movb   $0x0,(%rsp,%rax,1)
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   10c0 <gettime@plt>
sub    %eax,%ebp
movslq %ebp,%rbp
imul   $0xffffffff91a2b3c5,%rbp,%rax
shr    $0x20,%rax
add    %eax,%ebp
mov    %ebp,%eax
shr    $0x1f,%eax
sar    $0xb,%ebp
add    %eax,%ebp
mov    %rbx,%rdi
call   1030 <getweight@plt>
sub    %eax,%ebp
cmp    $0x30,%ebp
jle    129c <list+0xfc>
mov    %rbx,%rdi
mov    $0x40,%esi
mov    %r14,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     1315 <list+0x175>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmpb   $0x3a,(%rsp,%rax,1)
je     11f4 <list+0x54>
cmpb   $0x3a,0x1(%rsp,%rax,1)
je     11f0 <list+0x50>
cmpb   $0x3a,0x2(%rsp,%rax,1)
je     128a <list+0xea>
cmpb   $0x3a,0x3(%rsp,%rax,1)
je     1293 <list+0xf3>
add    $0x4,%rax
cmp    $0x40,%rax
jne    1260 <list+0xc0>
jmp    11fa <list+0x5a>
add    $0x2,%rax
jmp    11f4 <list+0x54>
add    $0x3,%rax
jmp    11f4 <list+0x54>
add    $0x1,%r13d
cmp    $0x14,%r13d
je     1315 <list+0x175>
mov    %rbx,%rdi
call   1040 <put@plt>
mov    %rbx,%rdi
call   1070 <strlen@plt>
cmp    $0x8,%eax
lea    0xdb1(%rip),%rdi
lea    0xda9(%rip),%rax
cmovl  %rax,%rdi
call   1040 <put@plt>
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1060 <getbirth@plt>
sub    %eax,%ebp
movslq %ebp,%rdx
imul   $0xffffffff91a2b3c5,%rdx,%rax
shr    $0x20,%rax
add    %eax,%edx
mov    %edx,%eax
shr    $0x1f,%eax
sar    $0xb,%edx
add    %eax,%edx
mov    %r12,%rdi
mov    %r15,%rsi
call   10b0 <sprintf@plt>
mov    %r12,%rdi
call   1040 <put@plt>
jmp    1236 <list+0x96>
mov    %r14,%rdi
call   1050 <fclose@plt>
lea    0xd4a(%rip),%rdi
call   1040 <put@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcc6(%rip),%rdi
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <put@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"tamas\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [60 x i8] c"Error: Can't open Tamagotchi file. Please try again later.\0A\00"
@.str.3 = [44 x i8] c"\0AName\09\09Age\0A-------------------------------\0A\00"
@.str.4 = [3 x i8] c"\09\09\00"
@.str.5 = [2 x i8] c"\09\00"
@.str.6 = [10 x i8] c"%d hours\0A\00"
@.str.7 = [2 x i8] c"\0A\00"
define void @list() {
%1 = alloca [64 x i8]
%2 = alloca [64 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
store i32 0, i32* %4
%6 = 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* %6, i32** %5
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @put(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0))
br label %77
10: ; preds = %0
%11 = call i32 @put(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
br label %12
12: ; preds = %63, %46, %10
%13 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%14 = load i32*, i32** %5
%15 = call i32* @fgets(i8* %13, i32 64, i32* %14)
%16 = icmp ne i32* %15, null
br i1 %16, label %17, label %73
17: ; preds = %12
store i32 0, i32* %3
br label %18
18: ; preds = %33, %17
%19 = load i32, i32* %3
%20 = icmp ult i32 %19, 64
br i1 %20, label %21, label %36
21: ; preds = %18
%22 = load i32, i32* %3
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 58
br i1 %27, label %28, label %32
28: ; preds = %21
%29 = load i32, i32* %3
%30 = zext i32 %29 to i64
%31 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 %30
store i8 0, i8* %31
br label %36
32: ; preds = %21
br label %33
33: ; preds = %32
%34 = load i32, i32* %3
%35 = add i32 %34, 1
store i32 %35, i32* %3
br label %18
36: ; preds = %28, %18
%37 = call i32 @time(i32* null)
%38 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%39 = call i32 @gettime(i8* %38)
%40 = sub nsw i32 %37, %39
%41 = sdiv i32 %40, 3600
%42 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%43 = call i32 @getweight(i8* %42)
%44 = sub nsw i32 %41, %43
%45 = icmp sgt i32 %44, 48
br i1 %45, label %46, label %47
46: ; preds = %36
br label %12
47: ; preds = %36
%48 = load i32, i32* %4
%49 = add i32 %48, 1
store i32 %49, i32* %4
%50 = load i32, i32* %4
%51 = icmp eq i32 %50, 20
br i1 %51, label %52, label %53
52: ; preds = %47
br label %73
53: ; preds = %47
%54 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%55 = call i32 @put(i8* %54)
%56 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%57 = call i32 @strlen(i8* %56)
%58 = icmp slt i32 %57, 8
br i1 %58, label %59, label %61
59: ; preds = %53
%60 = call i32 @put(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %63
61: ; preds = %53
%62 = call i32 @put(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %63
63: ; preds = %61, %59
%64 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%65 = call i32 @time(i32* null)
%66 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%67 = call i32 @getbirth(i8* %66)
%68 = sub nsw i32 %65, %67
%69 = sdiv i32 %68, 3600
%70 = call i32 @sprintf(i8* %64, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %69)
%71 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%72 = call i32 @put(i8* %71)
br label %12
73: ; preds = %52, %12
%74 = load i32*, i32** %5
%75 = call i32 @fclose(i32* %74)
%76 = call i32 @put(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %77
77: ; preds = %73, %8
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"tamas\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [60 x i8] c"Error: Can't open Tamagotchi file. Please try again later.\0A\00"
@.str.3 = [44 x i8] c"\0AName\09\09Age\0A-------------------------------\0A\00"
@.str.4 = [3 x i8] c"\09\09\00"
@.str.5 = [2 x i8] c"\09\00"
@.str.6 = [10 x i8] c"%d hours\0A\00"
@.str.7 = [2 x i8] c"\0A\00"
define void @list() {
%1 = alloca [64 x i8]
%2 = alloca [64 x i8]
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%5 = 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))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = tail call i32 @put(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0))
br label %69
9: ; preds = %0
%10 = tail call i32 @put(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
br label %11
11: ; preds = %54, %9
%12 = phi i32 [ %52, %54 ], [ 0, %9 ]
br label %13
13: ; preds = %11, %43
%14 = call i32* @fgets(i8* %3, i32 64, i32* %5)
%15 = icmp eq i32* %14, null
br i1 %15, label %66, label %16
16: ; preds = %13, %40
%17 = phi i64 [ %41, %40 ], [ 0, %13 ]
%18 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 58
br i1 %20, label %21, label %25
21: ; preds = %35, %30, %25, %16
%22 = phi i64 [ %17, %16 ], [ %26, %25 ], [ %31, %30 ], [ %36, %35 ]
%23 = and i64 %22, 4294967295
%24 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 %23
store i8 0, i8* %24
br label %43
25: ; preds = %16
%26 = or i64 %17, 1
%27 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 58
br i1 %29, label %21, label %30
30: ; preds = %25
%31 = or i64 %17, 2
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = icmp eq i8 %33, 58
br i1 %34, label %21, label %35
35: ; preds = %30
%36 = or i64 %17, 3
%37 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = icmp eq i8 %38, 58
br i1 %39, label %21, label %40
40: ; preds = %35
%41 = add nuw nsw i64 %17, 4
%42 = icmp eq i64 %41, 64
br i1 %42, label %43, label %16
43: ; preds = %40, %21
%44 = call i32 @time(i32* null)
%45 = call i32 @gettime(i8* %3)
%46 = sub nsw i32 %44, %45
%47 = sdiv i32 %46, 3600
%48 = call i32 @getweight(i8* %3)
%49 = sub nsw i32 %47, %48
%50 = icmp sgt i32 %49, 48
br i1 %50, label %13, label %51
51: ; preds = %43
%52 = add nuw nsw i32 %12, 1
%53 = icmp eq i32 %52, 20
br i1 %53, label %66, label %54
54: ; preds = %51
%55 = call i32 @put(i8* %3)
%56 = call i32 @strlen(i8* %3)
%57 = icmp slt i32 %56, 8
%58 = select i1 %57, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0)
%59 = call i32 @put(i8* %58)
%60 = call i32 @time(i32* null)
%61 = call i32 @getbirth(i8* %3)
%62 = sub nsw i32 %60, %61
%63 = sdiv i32 %62, 3600
%64 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %63)
%65 = call i32 @put(i8* %4)
br label %11
66: ; preds = %51, %13
%67 = call i32 @fclose(i32* %5)
%68 = call i32 @put(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %69
69: ; preds = %66, %7
ret void
}