#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 */

/* Variables and functions */
int /*<<< orphan*/ exit(int);
scalar_t__ mksfs(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sfs_clean();
int sfs_fclose(int);
int sfs_fopen(char *);
int sfs_fread(int, char *, int);
int sfs_fwrite(int, char *, int);
int /*<<< orphan*/ sfs_ls();
int sfs_remove(char *);
int main(void) {
  int i;
  char as[2048 + 23];
  char bs[2048 + 567];
  if (mksfs(1)) {
    printf("Error in initializing the disk\n");
    exit(1);
  }
  printf("Currently no files have been created.\n");
  printf("We run ls() : \n");
  sfs_ls();
  for (i = 0; i < 2048 + 23; i++) {
    as[i] = 'a';
  }
  for (i = 0; i < 2048 + 567; i++) {
    bs[i] = 'b';
  }
  int file1 = sfs_fopen("File1");
  int file2 = sfs_fopen("File2");
  int file3 = sfs_fopen("big_file_number3.txt");
  printf("Now, 3 files have been created.\n\n");
  printf("The file descriptor ids are : %d %d %d\n", file1, file2, file3);
  printf("We run ls():\n\n");
  sfs_ls();
  printf("\n Now we will write %d a's into the second file\n", 2048 + 23);
  int wr_result = sfs_fwrite(file2, &as[0], 2048 + 23);
  printf("Result : %d bytes written\n", wr_result);
  printf("And we will write %d b's into the 1st file\n", 2048 + 567);
  wr_result = sfs_fwrite(file1, &bs[0], 2048 + 567);
  printf("Result : %d bytes written\n", wr_result);
  printf("And now, ls() : \n\n");
  sfs_ls();
  printf("Now, I will close file 'File1'. sfs_fclose returns -1 on error and 0 "
         "on success\n");
  int fclosereturn = sfs_fclose(file1);
  if (fclosereturn) {
    printf("Invalid filedescriptor\n");
  } else {
    printf("Success!\n");
  }
  printf("We do ls() : \n\n");
  sfs_ls();
  printf("Now we open the file that we just closed.\n");
  file1 = sfs_fopen("File1");
  printf("The new file descriptor is %d \n", file1);
  printf("Now we close and then remove File2 from the disk\n");
  fclosereturn = sfs_fclose(file2);
  if (fclosereturn) {
    printf("Invalid filedescriptor\n");
  } else {
    printf("Success!\n");
  }
  int removeres = sfs_remove("File2");
  if (removeres) {
    printf("%d Error in removal", removeres);
  } else {
    printf("Success! file was removed\n");
  }
  printf("\nNow we do ls() : \n");
  sfs_ls();
  char scrap_book[2 * 2048];
  printf("Now it's time to read stuff that was copied inside File1\n");
  printf("First let's read 1000 bytes, then 1200, and then 600\n");
  printf("sfs_fread return the number of bytes that were read.\n");
  int pos;
  int read_res = sfs_fread(file1, &scrap_book[0], 1000);
  printf("%d bytes read.\n", read_res);
  pos = pos + read_res;
  read_res = sfs_fread(file1, &scrap_book[pos], 1200);
  printf("%d bytes read.\n", read_res);
  pos = pos + read_res;
  read_res = sfs_fread(file1, &scrap_book[pos], 600);
  printf("%d bytes read.\n", read_res);
  pos = pos + read_res;
  scrap_book[pos] = '\0';
  printf("What we have read: \n%s\n", &scrap_book[0]);
  printf("It doesn't read past EOF.\n");
  printf("We will now write what we have read into big_file_number3.txt\n");
  sfs_fwrite(file3, &scrap_book[0], pos);
  printf("And now, we ls() : \n");
  sfs_ls();
  printf("Now we reset the filesystem\n");
  sfs_clean();
  printf("FileSystem Reset\n");
  printf("We want to reload the disk\n");
  mksfs(0);
  printf("Filesystem reloaded. We do ls \n");
  sfs_ls();
  int open_result = sfs_fopen("File1");
  if (open_result >= 0) {
    printf("File File1 opened with success, fdesc id: %d\n", open_result);
  }
  char test5[80];
  for (i = 0; i < 80; i++) {
    test5[i] = '0';
  }
  wr_result = sfs_fwrite(open_result, &test5[0], 79);
  printf("%d bytes written to file File1.\n", wr_result);
  sfs_ls();
  read_res = sfs_fread(open_result, &scrap_book[0], 2 * 2048 - 2);
  scrap_book[read_res] = '\0';
  printf("Print what we have read : %d bytes\n", read_res);
  printf("%s\n", &scrap_book[0]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x22e0,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%edi
call   1030 <mksfs@plt>
cmp    $0x0,%rax
je     11de <main+0x3e>
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <sfs_ls@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x817,-0x8(%rbp)
jge    122f <main+0x8f>
movslq -0x8(%rbp),%rax
movb   $0x61,-0x820(%rbp,%rax,1)
61
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1208 <main+0x68>
movl   $0x0,-0x8(%rbp)
cmpl   $0xa37,-0x8(%rbp)
jge    125d <main+0xbd>
movslq -0x8(%rbp),%rax
movb   $0x62,-0x1260(%rbp,%rax,1)
62
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1236 <main+0x96>
lea    0xdf3(%rip),%rdi
call   10c0 <sfs_fopen@plt>
mov    %eax,-0x1264(%rbp)
lea    0xde7(%rip),%rdi
call   10c0 <sfs_fopen@plt>
mov    %eax,-0x1268(%rbp)
lea    0xddb(%rip),%rdi
call   10c0 <sfs_fopen@plt>
mov    %eax,-0x126c(%rbp)
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1264(%rbp),%esi
mov    -0x1268(%rbp),%edx
mov    -0x126c(%rbp),%ecx
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <sfs_ls@plt>
lea    0xdf4(%rip),%rdi
mov    $0x817,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1268(%rbp),%edi
lea    -0x820(%rbp),%rsi
mov    $0x817,%edx
call   1060 <sfs_fwrite@plt>
mov    %eax,-0x1270(%rbp)
mov    -0x1270(%rbp),%esi
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdfc(%rip),%rdi
mov    $0xa37,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1264(%rbp),%edi
lea    -0x1260(%rbp),%rsi
mov    $0xa37,%edx
call   1060 <sfs_fwrite@plt>
mov    %eax,-0x1270(%rbp)
mov    -0x1270(%rbp),%esi
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <sfs_ls@plt>
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1264(%rbp),%edi
call   1080 <sfs_fclose@plt>
mov    %eax,-0x1274(%rbp)
cmpl   $0x0,-0x1274(%rbp)
je     13b2 <main+0x212>
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13c0 <main+0x220>
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <sfs_ls@plt>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc6d(%rip),%rdi
call   10c0 <sfs_fopen@plt>
mov    %eax,-0x1264(%rbp)
mov    -0x1264(%rbp),%esi
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1268(%rbp),%edi
call   1080 <sfs_fclose@plt>
mov    %eax,-0x1274(%rbp)
cmpl   $0x0,-0x1274(%rbp)
je     1448 <main+0x2a8>
lea    0xd71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1456 <main+0x2b6>
lea    0xd76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc00(%rip),%rdi
call   1050 <sfs_remove@plt>
mov    %eax,-0x1278(%rbp)
cmpl   $0x0,-0x1278(%rbp)
je     148e <main+0x2ee>
mov    -0x1278(%rbp),%esi
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    149c <main+0x2fc>
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <sfs_ls@plt>
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1264(%rbp),%edi
lea    -0x2280(%rbp),%rsi
mov    $0x3e8,%edx
call   1090 <sfs_fread@plt>
mov    %eax,-0x2288(%rbp)
mov    -0x2288(%rbp),%esi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2284(%rbp),%eax
add    -0x2288(%rbp),%eax
mov    %eax,-0x2284(%rbp)
mov    -0x1264(%rbp),%edi
movslq -0x2284(%rbp),%rax
lea    -0x2280(%rbp),%rsi
add    %rax,%rsi
mov    $0x4b0,%edx
call   1090 <sfs_fread@plt>
mov    %eax,-0x2288(%rbp)
mov    -0x2288(%rbp),%esi
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2284(%rbp),%eax
add    -0x2288(%rbp),%eax
mov    %eax,-0x2284(%rbp)
mov    -0x1264(%rbp),%edi
movslq -0x2284(%rbp),%rax
lea    -0x2280(%rbp),%rsi
add    %rax,%rsi
mov    $0x258,%edx
call   1090 <sfs_fread@plt>
mov    %eax,-0x2288(%rbp)
mov    -0x2288(%rbp),%esi
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2284(%rbp),%eax
add    -0x2288(%rbp),%eax
mov    %eax,-0x2284(%rbp)
movslq -0x2284(%rbp),%rax
movb   $0x0,-0x2280(%rbp,%rax,1)
lea    -0x2280(%rbp),%rsi
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x126c(%rbp),%edi
lea    -0x2280(%rbp),%rsi
mov    -0x2284(%rbp),%edx
call   1060 <sfs_fwrite@plt>
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <sfs_ls@plt>
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   10a0 <sfs_clean@plt>
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1030 <mksfs@plt>
lea    0xdc3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <sfs_ls@plt>
lea    0x9de(%rip),%rdi
call   10c0 <sfs_fopen@plt>
mov    %eax,-0x228c(%rbp)
cmpl   $0x0,-0x228c(%rbp)
jl     16a5 <main+0x505>
mov    -0x228c(%rbp),%esi
lea    0xda9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x50,-0x8(%rbp)
jge    16d0 <main+0x530>
movslq -0x8(%rbp),%rax
movb   $0x30,-0x22e0(%rbp,%rax,1)
30
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    16ac <main+0x50c>
mov    -0x228c(%rbp),%edi
lea    -0x22e0(%rbp),%rsi
mov    $0x4f,%edx
call   1060 <sfs_fwrite@plt>
mov    %eax,-0x1270(%rbp)
mov    -0x1270(%rbp),%esi
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <sfs_ls@plt>
mov    -0x228c(%rbp),%edi
lea    -0x2280(%rbp),%rsi
mov    $0xffe,%edx
call   1090 <sfs_fread@plt>
mov    %eax,-0x2288(%rbp)
movslq -0x2288(%rbp),%rax
movb   $0x0,-0x2280(%rbp,%rax,1)
mov    -0x2288(%rbp),%esi
lea    0xd55(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x2280(%rbp),%rsi
lea    0xc13(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x22e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x22a8,%rsp
mov    $0x1,%edi
call   1040 <mksfs@plt>
test   %rax,%rax
jne    159d <main+0x3dd>
lea    0xf9a(%rip),%rdi
call   1030 <puts@plt>
lea    0xfb4(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1090 <sfs_ls@plt>
lea    0x1050(%rsp),%r14
mov    $0x817,%edx
mov    %r14,%rdi
mov    $0x61,%esi
call   1070 <memset@plt>
lea    0x1870(%rsp),%r13
mov    $0xa37,%edx
mov    %r13,%rdi
mov    $0x62,%esi
call   1070 <memset@plt>
lea    0x10e0(%rip),%rdi
call   10e0 <sfs_fopen@plt>
mov    %eax,%ebx
lea    0xdc4(%rip),%rdi
call   10e0 <sfs_fopen@plt>
mov    %eax,%r15d
lea    0x1176(%rip),%rdi
call   10e0 <sfs_fopen@plt>
mov    %eax,%r12d
lea    0xf50(%rip),%rdi
call   1030 <puts@plt>
lea    0xda0(%rip),%rdi
mov    %ebx,%esi
mov    %r15d,%edx
mov    %r12d,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf4f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1090 <sfs_ls@plt>
lea    0xd9f(%rip),%rdi
mov    $0x817,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0x817,%edx
call   1080 <sfs_fwrite@plt>
lea    0xdad(%rip),%rbp
mov    %rbp,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdb5(%rip),%rdi
mov    $0xa37,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%edi
mov    %r13,%rsi
mov    $0xa37,%edx
call   1080 <sfs_fwrite@plt>
mov    %rbp,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xee6(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1090 <sfs_ls@plt>
lea    0xee5(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
call   10a0 <sfs_fclose@plt>
test   %eax,%eax
lea    0xf8a(%rip),%r14
lea    0x112f(%rip),%rbp
mov    %rbp,%rdi
cmove  %r14,%rdi
call   1030 <puts@plt>
lea    0xf06(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1090 <sfs_ls@plt>
lea    0xf02(%rip),%rdi
call   1030 <puts@plt>
lea    0xfba(%rip),%rdi
call   10e0 <sfs_fopen@plt>
mov    %eax,%ebx
lea    0xd44(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf02(%rip),%rdi
call   1030 <puts@plt>
mov    %r15d,%edi
call   10a0 <sfs_fclose@plt>
test   %eax,%eax
cmove  %r14,%rbp
mov    %rbp,%rdi
call   1030 <puts@plt>
lea    0xc6c(%rip),%rdi
call   1060 <sfs_remove@plt>
test   %eax,%eax
je     13bf <main+0x1ff>
lea    0xd22(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    13cb <main+0x20b>
lea    0xef8(%rip),%rdi
call   1030 <puts@plt>
lea    0xf06(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1090 <sfs_ls@plt>
lea    0xf06(%rip),%rdi
call   1030 <puts@plt>
lea    0xf33(%rip),%rdi
call   1030 <puts@plt>
lea    0xf5c(%rip),%rdi
call   1030 <puts@plt>
lea    0x50(%rsp),%r14
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x3e8,%edx
call   10b0 <sfs_fread@plt>
lea    0xccd(%rip),%rbp
mov    %rbp,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x4b0,%edx
call   10b0 <sfs_fread@plt>
mov    %rbp,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x258,%edx
call   10b0 <sfs_fread@plt>
mov    %rbp,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movb   $0x0,0x50(%rsp)
lea    0xc8f(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf12(%rip),%rdi
call   1030 <puts@plt>
lea    0xf20(%rip),%rdi
call   1030 <puts@plt>
mov    %r12d,%edi
mov    %r14,%rsi
call   1080 <sfs_fwrite@plt>
lea    0xf47(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1090 <sfs_ls@plt>
lea    0xf48(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   10c0 <sfs_clean@plt>
lea    0xf51(%rip),%rdi
call   1030 <puts@plt>
lea    0xf56(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1040 <mksfs@plt>
lea    0xf5e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1090 <sfs_ls@plt>
lea    0xe27(%rip),%rdi
call   10e0 <sfs_fopen@plt>
mov    %eax,%ebx
test   %eax,%eax
js     1512 <main+0x352>
lea    0xc09(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movaps 0xae7(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x4f,%edx
call   1080 <sfs_fwrite@plt>
lea    0xbf9(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1090 <sfs_ls@plt>
lea    0x50(%rsp),%rbp
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0xffe,%edx
call   10b0 <sfs_fread@plt>
movslq %eax,%rsi
movb   $0x0,0x50(%rsp,%rsi,1)
lea    0xbe7(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x22a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xed4(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"Error in initializing the disk\0A\00"
@.str.1 = [39 x i8] c"Currently no files have been created.\0A\00"
@.str.2 = [16 x i8] c"We run ls() : \0A\00"
@.str.3 = [6 x i8] c"File1\00"
@.str.4 = [6 x i8] c"File2\00"
@.str.5 = [21 x i8] c"big_file_number3.txt\00"
@.str.6 = [34 x i8] c"Now, 3 files have been created.\0A\0A\00"
@.str.7 = [40 x i8] c"The file descriptor ids are : %d %d %d\0A\00"
@.str.8 = [15 x i8] c"We run ls():\0A\0A\00"
@.str.9 = [49 x i8] c"\0A Now we will write %d a's into the second file\0A\00"
@.str.10 = [27 x i8] c"Result : %d bytes written\0A\00"
@.str.11 = [44 x i8] c"And we will write %d b's into the 1st file\0A\00"
@.str.12 = [19 x i8] c"And now, ls() : \0A\0A\00"
@.str.13 = [81 x i8] c"Now, I will close file 'File1'. sfs_fclose returns -1 on error and 0 on success\0A\00"
@.str.14 = [24 x i8] c"Invalid filedescriptor\0A\00"
@.str.15 = [10 x i8] c"Success!\0A\00"
@.str.16 = [16 x i8] c"We do ls() : \0A\0A\00"
@.str.17 = [43 x i8] c"Now we open the file that we just closed.\0A\00"
@.str.18 = [32 x i8] c"The new file descriptor is %d \0A\00"
@.str.19 = [50 x i8] c"Now we close and then remove File2 from the disk\0A\00"
@.str.20 = [20 x i8] c"%d Error in removal\00"
@.str.21 = [27 x i8] c"Success! file was removed\0A\00"
@.str.22 = [20 x i8] c"\0ANow we do ls() : \0A\00"
@.str.23 = [58 x i8] c"Now it's time to read stuff that was copied inside File1\0A\00"
@.str.24 = [54 x i8] c"First let's read 1000 bytes, then 1200, and then 600\0A\00"
@.str.25 = [54 x i8] c"sfs_fread return the number of bytes that were read.\0A\00"
@.str.26 = [16 x i8] c"%d bytes read.\0A\00"
@.str.27 = [24 x i8] c"What we have read: \0A%s\0A\00"
@.str.28 = [27 x i8] c"It doesn't read past EOF.\0A\00"
@.str.29 = [63 x i8] c"We will now write what we have read into big_file_number3.txt\0A\00"
@.str.30 = [21 x i8] c"And now, we ls() : \0A\00"
@.str.31 = [29 x i8] c"Now we reset the filesystem\0A\00"
@.str.32 = [18 x i8] c"FileSystem Reset\0A\00"
@.str.33 = [28 x i8] c"We want to reload the disk\0A\00"
@.str.34 = [32 x i8] c"Filesystem reloaded. We do ls \0A\00"
@.str.35 = [46 x i8] c"File File1 opened with success, fdesc id: %d\0A\00"
@.str.36 = [33 x i8] c"%d bytes written to file File1.\0A\00"
@.str.37 = [36 x i8] c"Print what we have read : %d bytes\0A\00"
@.str.38 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [2071 x i8]
%4 = alloca [2615 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [4096 x i8]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca [80 x i8]
store i32 0, i32* %1
%16 = call i64 @mksfs(i32 1)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 (...) @sfs_ls()
store i32 0, i32* %2
br label %25
25: ; preds = %32, %21
%26 = load i32, i32* %2
%27 = icmp slt i32 %26, 2071
br i1 %27, label %28, label %35
28: ; preds = %25
%29 = load i32, i32* %2
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [2071 x i8], [2071 x i8]* %3, i64 0, i64 %30
store i8 97, i8* %31
br label %32
32: ; preds = %28
%33 = load i32, i32* %2
%34 = add nsw i32 %33, 1
store i32 %34, i32* %2
br label %25
35: ; preds = %25
store i32 0, i32* %2
br label %36
36: ; preds = %43, %35
%37 = load i32, i32* %2
%38 = icmp slt i32 %37, 2615
br i1 %38, label %39, label %46
39: ; preds = %36
%40 = load i32, i32* %2
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [2615 x i8], [2615 x i8]* %4, i64 0, i64 %41
store i8 98, i8* %42
br label %43
43: ; preds = %39
%44 = load i32, i32* %2
%45 = add nsw i32 %44, 1
store i32 %45, i32* %2
br label %36
46: ; preds = %36
%47 = call i32 @sfs_fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i32 %47, i32* %5
%48 = call i32 @sfs_fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
store i32 %48, i32* %6
%49 = call i32 @sfs_fopen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
store i32 %49, i32* %7
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
%51 = load i32, i32* %5
%52 = load i32, i32* %6
%53 = load i32, i32* %7
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0), i32 %51, i32 %52, i32 %53)
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
%56 = call i32 (...) @sfs_ls()
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.9, i64 0, i64 0), i32 2071)
%58 = load i32, i32* %6
%59 = getelementptr inbounds [2071 x i8], [2071 x i8]* %3, i64 0, i64 0
%60 = call i32 @sfs_fwrite(i32 %58, i8* %59, i32 2071)
store i32 %60, i32* %8
%61 = load i32, i32* %8
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), i32 %61)
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.11, i64 0, i64 0), i32 2615)
%64 = load i32, i32* %5
%65 = getelementptr inbounds [2615 x i8], [2615 x i8]* %4, i64 0, i64 0
%66 = call i32 @sfs_fwrite(i32 %64, i8* %65, i32 2615)
store i32 %66, i32* %8
%67 = load i32, i32* %8
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), i32 %67)
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
%70 = call i32 (...) @sfs_ls()
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.13, i64 0, i64 0))
%72 = load i32, i32* %5
%73 = call i32 @sfs_fclose(i32 %72)
store i32 %73, i32* %9
%74 = load i32, i32* %9
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %46
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.14, i64 0, i64 0))
br label %80
78: ; preds = %46
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0))
br label %80
80: ; preds = %78, %76
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.16, i64 0, i64 0))
%82 = call i32 (...) @sfs_ls()
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.17, i64 0, i64 0))
%84 = call i32 @sfs_fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i32 %84, i32* %5
%85 = load i32, i32* %5
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.18, i64 0, i64 0), i32 %85)
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.19, i64 0, i64 0))
%88 = load i32, i32* %6
%89 = call i32 @sfs_fclose(i32 %88)
store i32 %89, i32* %9
%90 = load i32, i32* %9
%91 = icmp ne i32 %90, 0
br i1 %91, label %92, label %94
92: ; preds = %80
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.14, i64 0, i64 0))
br label %96
94: ; preds = %80
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0))
br label %96
96: ; preds = %94, %92
%97 = call i32 @sfs_remove(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
store i32 %97, i32* %10
%98 = load i32, i32* %10
%99 = icmp ne i32 %98, 0
br i1 %99, label %100, label %103
100: ; preds = %96
%101 = load i32, i32* %10
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.20, i64 0, i64 0), i32 %101)
br label %105
103: ; preds = %96
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.21, i64 0, i64 0))
br label %105
105: ; preds = %103, %100
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.22, i64 0, i64 0))
%107 = call i32 (...) @sfs_ls()
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.23, i64 0, i64 0))
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.24, i64 0, i64 0))
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.25, i64 0, i64 0))
%111 = load i32, i32* %5
%112 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%113 = call i32 @sfs_fread(i32 %111, i8* %112, i32 1000)
store i32 %113, i32* %13
%114 = load i32, i32* %13
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.26, i64 0, i64 0), i32 %114)
%116 = load i32, i32* %12
%117 = load i32, i32* %13
%118 = add nsw i32 %116, %117
store i32 %118, i32* %12
%119 = load i32, i32* %5
%120 = load i32, i32* %12
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 %121
%123 = call i32 @sfs_fread(i32 %119, i8* %122, i32 1200)
store i32 %123, i32* %13
%124 = load i32, i32* %13
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.26, i64 0, i64 0), i32 %124)
%126 = load i32, i32* %12
%127 = load i32, i32* %13
%128 = add nsw i32 %126, %127
store i32 %128, i32* %12
%129 = load i32, i32* %5
%130 = load i32, i32* %12
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 %131
%133 = call i32 @sfs_fread(i32 %129, i8* %132, i32 600)
store i32 %133, i32* %13
%134 = load i32, i32* %13
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.26, i64 0, i64 0), i32 %134)
%136 = load i32, i32* %12
%137 = load i32, i32* %13
%138 = add nsw i32 %136, %137
store i32 %138, i32* %12
%139 = load i32, i32* %12
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 %140
store i8 0, i8* %141
%142 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.27, i64 0, i64 0), i8* %142)
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.28, i64 0, i64 0))
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.29, i64 0, i64 0))
%146 = load i32, i32* %7
%147 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%148 = load i32, i32* %12
%149 = call i32 @sfs_fwrite(i32 %146, i8* %147, i32 %148)
%150 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.30, i64 0, i64 0))
%151 = call i32 (...) @sfs_ls()
%152 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.31, i64 0, i64 0))
%153 = call i32 (...) @sfs_clean()
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.32, i64 0, i64 0))
%155 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.33, i64 0, i64 0))
%156 = call i64 @mksfs(i32 0)
%157 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.34, i64 0, i64 0))
%158 = call i32 (...) @sfs_ls()
%159 = call i32 @sfs_fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i32 %159, i32* %14
%160 = load i32, i32* %14
%161 = icmp sge i32 %160, 0
br i1 %161, label %162, label %165
162: ; preds = %105
%163 = load i32, i32* %14
%164 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.35, i64 0, i64 0), i32 %163)
br label %165
165: ; preds = %162, %105
store i32 0, i32* %2
br label %166
166: ; preds = %173, %165
%167 = load i32, i32* %2
%168 = icmp slt i32 %167, 80
br i1 %168, label %169, label %176
169: ; preds = %166
%170 = load i32, i32* %2
%171 = sext i32 %170 to i64
%172 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 %171
store i8 48, i8* %172
br label %173
173: ; preds = %169
%174 = load i32, i32* %2
%175 = add nsw i32 %174, 1
store i32 %175, i32* %2
br label %166
176: ; preds = %166
%177 = load i32, i32* %14
%178 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 0
%179 = call i32 @sfs_fwrite(i32 %177, i8* %178, i32 79)
store i32 %179, i32* %8
%180 = load i32, i32* %8
%181 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.36, i64 0, i64 0), i32 %180)
%182 = call i32 (...) @sfs_ls()
%183 = load i32, i32* %14
%184 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%185 = call i32 @sfs_fread(i32 %183, i8* %184, i32 4094)
store i32 %185, i32* %13
%186 = load i32, i32* %13
%187 = sext i32 %186 to i64
%188 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 %187
store i8 0, i8* %188
%189 = load i32, i32* %13
%190 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.37, i64 0, i64 0), i32 %189)
%191 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%192 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.38, i64 0, i64 0), i8* %191)
%193 = load i32, i32* %1
ret i32 %193
}

LLVM IR (-O2):
@.str.3 = [6 x i8] c"File1\00"
@.str.4 = [6 x i8] c"File2\00"
@.str.5 = [21 x i8] c"big_file_number3.txt\00"
@.str.7 = [40 x i8] c"The file descriptor ids are : %d %d %d\0A\00"
@.str.9 = [49 x i8] c"\0A Now we will write %d a's into the second file\0A\00"
@.str.10 = [27 x i8] c"Result : %d bytes written\0A\00"
@.str.11 = [44 x i8] c"And we will write %d b's into the 1st file\0A\00"
@.str.18 = [32 x i8] c"The new file descriptor is %d \0A\00"
@.str.20 = [20 x i8] c"%d Error in removal\00"
@.str.26 = [16 x i8] c"%d bytes read.\0A\00"
@.str.27 = [24 x i8] c"What we have read: \0A%s\0A\00"
@.str.35 = [46 x i8] c"File File1 opened with success, fdesc id: %d\0A\00"
@.str.36 = [33 x i8] c"%d bytes written to file File1.\0A\00"
@.str.37 = [36 x i8] c"Print what we have read : %d bytes\0A\00"
@str = [38 x i8] c"Currently no files have been created.\00"
@str.39 = [15 x i8] c"We run ls() : \00"
@str.40 = [33 x i8] c"Now, 3 files have been created.\0A\00"
@str.41 = [14 x i8] c"We run ls():\0A\00"
@str.42 = [18 x i8] c"And now, ls() : \0A\00"
@str.43 = [80 x i8] c"Now, I will close file 'File1'. sfs_fclose returns -1 on error and 0 on success\00"
@str.45 = [15 x i8] c"We do ls() : \0A\00"
@str.46 = [42 x i8] c"Now we open the file that we just closed.\00"
@str.47 = [49 x i8] c"Now we close and then remove File2 from the disk\00"
@str.48 = [9 x i8] c"Success!\00"
@str.49 = [26 x i8] c"Success! file was removed\00"
@str.50 = [19 x i8] c"\0ANow we do ls() : \00"
@str.51 = [57 x i8] c"Now it's time to read stuff that was copied inside File1\00"
@str.52 = [53 x i8] c"First let's read 1000 bytes, then 1200, and then 600\00"
@str.53 = [53 x i8] c"sfs_fread return the number of bytes that were read.\00"
@str.54 = [26 x i8] c"It doesn't read past EOF.\00"
@str.55 = [62 x i8] c"We will now write what we have read into big_file_number3.txt\00"
@str.56 = [20 x i8] c"And now, we ls() : \00"
@str.57 = [28 x i8] c"Now we reset the filesystem\00"
@str.58 = [17 x i8] c"FileSystem Reset\00"
@str.59 = [27 x i8] c"We want to reload the disk\00"
@str.60 = [31 x i8] c"Filesystem reloaded. We do ls \00"
@str.62 = [23 x i8] c"Invalid filedescriptor\00"
@str.63 = [31 x i8] c"Error in initializing the disk\00"
define i32 @main() {
%1 = alloca [2071 x i8]
%2 = alloca [2615 x i8]
%3 = alloca [4096 x i8]
%4 = alloca [80 x i8]
%5 = getelementptr inbounds [2071 x i8], [2071 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [2615 x i8], [2615 x i8]* %2, i64 0, i64 0
%7 = tail call i64 @mksfs(i32 1)
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %0
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.63, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %0
%13 = getelementptr inbounds [2615 x i8], [2615 x i8]* %2, i64 0, i64 0
%14 = getelementptr inbounds [2071 x i8], [2071 x i8]* %1, i64 0, i64 0
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.39, i64 0, i64 0))
%17 = tail call i32 (...) @sfs_ls()
%18 = tail call i32 @sfs_fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%19 = tail call i32 @sfs_fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%20 = tail call i32 @sfs_fopen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.40, i64 0, i64 0))
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0), i32 %18, i32 %19, i32 %20)
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.41, i64 0, i64 0))
%24 = tail call i32 (...) @sfs_ls()
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.9, i64 0, i64 0), i32 2071)
%26 = call i32 @sfs_fwrite(i32 %19, i8* %5, i32 2071)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.11, i64 0, i64 0), i32 2615)
%29 = call i32 @sfs_fwrite(i32 %18, i8* %6, i32 2615)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), i32 %29)
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.42, i64 0, i64 0))
%32 = call i32 (...) @sfs_ls()
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @str.43, i64 0, i64 0))
%34 = call i32 @sfs_fclose(i32 %18)
%35 = icmp eq i32 %34, 0
%36 = select i1 %35, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.48, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @str.62, i64 0, i64 0)
%37 = call i32 @puts(i8* dereferenceable(1) %36)
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.45, i64 0, i64 0))
%39 = call i32 (...) @sfs_ls()
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.46, i64 0, i64 0))
%41 = call i32 @sfs_fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.18, i64 0, i64 0), i32 %41)
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.47, i64 0, i64 0))
%44 = call i32 @sfs_fclose(i32 %19)
%45 = icmp eq i32 %44, 0
%46 = select i1 %45, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.48, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @str.62, i64 0, i64 0)
%47 = call i32 @puts(i8* dereferenceable(1) %46)
%48 = call i32 @sfs_remove(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%49 = icmp eq i32 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %12
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.20, i64 0, i64 0), i32 %48)
br label %54
52: ; preds = %12
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.49, i64 0, i64 0))
br label %54
54: ; preds = %52, %50
%55 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.50, i64 0, i64 0))
%56 = call i32 (...) @sfs_ls()
%57 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%58 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.51, i64 0, i64 0))
%59 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.52, i64 0, i64 0))
%60 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.53, i64 0, i64 0))
%61 = call i32 @sfs_fread(i32 %41, i8* %57, i32 1000)
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.26, i64 0, i64 0), i32 %61)
%63 = call i32 @sfs_fread(i32 %41, i8* %57, i32 1200)
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.26, i64 0, i64 0), i32 %63)
%65 = call i32 @sfs_fread(i32 %41, i8* %57, i32 600)
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.26, i64 0, i64 0), i32 %65)
store i8 0, i8* %57
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.27, i64 0, i64 0), i8* %57)
%68 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.54, i64 0, i64 0))
%69 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str.55, i64 0, i64 0))
%70 = call i32 @sfs_fwrite(i32 %20, i8* %57, i32 undef)
%71 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.56, i64 0, i64 0))
%72 = call i32 (...) @sfs_ls()
%73 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.57, i64 0, i64 0))
%74 = call i32 (...) @sfs_clean()
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.58, i64 0, i64 0))
%76 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.59, i64 0, i64 0))
%77 = call i64 @mksfs(i32 0)
%78 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.60, i64 0, i64 0))
%79 = call i32 (...) @sfs_ls()
%80 = call i32 @sfs_fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%81 = icmp sgt i32 %80, -1
br i1 %81, label %82, label %84
82: ; preds = %54
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.35, i64 0, i64 0), i32 %80)
br label %84
84: ; preds = %82, %54
%85 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%86 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%87 = call i32 @sfs_fwrite(i32 %80, i8* %86, i32 79)
%88 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.36, i64 0, i64 0), i32 %87)
%89 = call i32 (...) @sfs_ls()
%90 = call i32 @sfs_fread(i32 %80, i8* %57, i32 4094)
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 %91
store i8 0, i8* %92
%93 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.37, i64 0, i64 0), i32 %90)
%94 = call i32 @puts(i8* %57)
ret i32 0
}