#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 ft_atoi(char *);
int /*<<< orphan*/ print_names(int, int, char **);
scalar_t__ read(int, char *, int);
int size_files(int, char **);
int /*<<< orphan*/ write(int, char *, int);
void disp_files(int i, int fd, int ac, char **av) {
  char buffer;
  int offset;
  int readed;
  int size_file;
  size_file = size_files(i, av);
  readed = 0;
  offset = ft_atoi(av[2]);
  print_names(i, ac, av);
  if (av[2][0] == '+') {
    while (readed != offset - 1)
      readed += read(fd, &buffer, 1);
    while (read(fd, &buffer, 1))
      write(1, &buffer, 1);
  } else {
    while (readed < (size_file - offset))
      readed += read(fd, &buffer, 1);
    while (read(fd, &buffer, 1))
      write(1, &buffer, 1);
  }
}


x86 assembly (clang, -O0):
<disp_files>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1050 <size_files@plt>
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <ft_atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1060 <print_names@plt>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
jne    1221 <disp_files+0xd1>
jmp    11b3 <disp_files+0x63>
mov    -0x24(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     11e7 <disp_files+0x97>
mov    -0x8(%rbp),%edi
lea    -0x19(%rbp),%rsi
mov    $0x1,%edx
call   1040 <read@plt>
mov    %rax,%rcx
movslq -0x24(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x24(%rbp)
jmp    11b3 <disp_files+0x63>
jmp    11ec <disp_files+0x9c>
mov    -0x8(%rbp),%edi
lea    -0x19(%rbp),%rsi
mov    $0x1,%edx
call   1040 <read@plt>
cmp    $0x0,%rax
je     121c <disp_files+0xcc>
mov    $0x1,%edx
lea    -0x19(%rbp),%rsi
mov    %edx,%edi
call   1030 <write@plt>
jmp    11ec <disp_files+0x9c>
jmp    1294 <disp_files+0x144>
jmp    1226 <disp_files+0xd6>
mov    -0x24(%rbp),%eax
mov    -0x28(%rbp),%ecx
sub    -0x20(%rbp),%ecx
cmp    %ecx,%eax
jge    125a <disp_files+0x10a>
mov    -0x8(%rbp),%edi
lea    -0x19(%rbp),%rsi
mov    $0x1,%edx
call   1040 <read@plt>
mov    %rax,%rcx
movslq -0x24(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x24(%rbp)
jmp    1226 <disp_files+0xd6>
jmp    125f <disp_files+0x10f>
mov    -0x8(%rbp),%edi
lea    -0x19(%rbp),%rsi
mov    $0x1,%edx
call   1040 <read@plt>
cmp    $0x0,%rax
je     128f <disp_files+0x13f>
mov    $0x1,%edx
lea    -0x19(%rbp),%rsi
mov    %edx,%edi
call   1030 <write@plt>
jmp    125f <disp_files+0x10f>
jmp    1294 <disp_files+0x144>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<disp_files>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %edx,%ebp
mov    %esi,%ebx
mov    %edi,%r13d
mov    %rcx,%rsi
call   1050 <size_files@plt>
mov    %eax,%r14d
mov    0x10(%r15),%rdi
call   1070 <ft_atoi@plt>
mov    %eax,%r12d
mov    %r13d,%edi
mov    %ebp,%esi
mov    %r15,%rdx
call   1060 <print_names@plt>
mov    0x10(%r15),%rax
cmpb   $0x2b,(%rax)
jne    1208 <disp_files+0xb8>
add    $0xffffffff,%r12d
je     11b6 <disp_files+0x66>
xor    %ebp,%ebp
lea    0x7(%rsp),%r14
nop
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1040 <read@plt>
add    %eax,%ebp
cmp    %r12d,%ebp
jne    11a0 <disp_files+0x50>
lea    0x7(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1040 <read@plt>
test   %rax,%rax
je     1286 <disp_files+0x136>
lea    0x7(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x1,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1040 <read@plt>
test   %rax,%rax
jne    11e0 <disp_files+0x90>
jmp    1286 <disp_files+0x136>
sub    %r12d,%r14d
jle    1236 <disp_files+0xe6>
xor    %ebp,%ebp
lea    0x7(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1040 <read@plt>
add    %eax,%ebp
cmp    %r14d,%ebp
jl     1220 <disp_files+0xd0>
lea    0x7(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1040 <read@plt>
test   %rax,%rax
je     1286 <disp_files+0x136>
lea    0x7(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1040 <read@plt>
test   %rax,%rax
jne    1260 <disp_files+0x110>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @disp_files(i32 %0, i32 %1, i32 %2, i8** %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i8
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8** %3, i8*** %8
%13 = load i32, i32* %5
%14 = load i8**, i8*** %8
%15 = call i32 @size_files(i32 %13, i8** %14)
store i32 %15, i32* %12
store i32 0, i32* %11
%16 = load i8**, i8*** %8
%17 = getelementptr inbounds i8*, i8** %16, i64 2
%18 = load i8*, i8** %17
%19 = call i32 @ft_atoi(i8* %18)
store i32 %19, i32* %10
%20 = load i32, i32* %5
%21 = load i32, i32* %7
%22 = load i8**, i8*** %8
%23 = call i32 @print_names(i32 %20, i32 %21, i8** %22)
%24 = load i8**, i8*** %8
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = getelementptr inbounds i8, i8* %26, i64 0
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 43
br i1 %30, label %31, label %52
31: ; preds = %4
br label %32
32: ; preds = %37, %31
%33 = load i32, i32* %11
%34 = load i32, i32* %10
%35 = sub nsw i32 %34, 1
%36 = icmp ne i32 %33, %35
br i1 %36, label %37, label %44
37: ; preds = %32
%38 = load i32, i32* %6
%39 = call i64 @read(i32 %38, i8* %9, i32 1)
%40 = load i32, i32* %11
%41 = sext i32 %40 to i64
%42 = add nsw i64 %41, %39
%43 = trunc i64 %42 to i32
store i32 %43, i32* %11
br label %32
44: ; preds = %32
br label %45
45: ; preds = %49, %44
%46 = load i32, i32* %6
%47 = call i64 @read(i32 %46, i8* %9, i32 1)
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %45
%50 = call i32 @write(i32 1, i8* %9, i32 1)
br label %45
51: ; preds = %45
br label %74
52: ; preds = %4
br label %53
53: ; preds = %59, %52
%54 = load i32, i32* %11
%55 = load i32, i32* %12
%56 = load i32, i32* %10
%57 = sub nsw i32 %55, %56
%58 = icmp slt i32 %54, %57
br i1 %58, label %59, label %66
59: ; preds = %53
%60 = load i32, i32* %6
%61 = call i64 @read(i32 %60, i8* %9, i32 1)
%62 = load i32, i32* %11
%63 = sext i32 %62 to i64
%64 = add nsw i64 %63, %61
%65 = trunc i64 %64 to i32
store i32 %65, i32* %11
br label %53
66: ; preds = %53
br label %67
67: ; preds = %71, %66
%68 = load i32, i32* %6
%69 = call i64 @read(i32 %68, i8* %9, i32 1)
%70 = icmp ne i64 %69, 0
br i1 %70, label %71, label %73
71: ; preds = %67
%72 = call i32 @write(i32 1, i8* %9, i32 1)
br label %67
73: ; preds = %67
br label %74
74: ; preds = %73, %51
ret void
}

LLVM IR (-O2):
define void @disp_files(i32 %0, i32 %1, i32 %2, i8** %3) {
%5 = alloca i8
%6 = tail call i32 @size_files(i32 %0, i8** %3)
%7 = getelementptr inbounds i8*, i8** %3, i64 2
%8 = load i8*, i8** %7
%9 = tail call i32 @ft_atoi(i8* %8)
%10 = tail call i32 @print_names(i32 %0, i32 %2, i8** %3)
%11 = load i8*, i8** %7
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 43
br i1 %13, label %17, label %14
14: ; preds = %4
%15 = sub nsw i32 %6, %9
%16 = icmp sgt i32 %15, 0
br i1 %16, label %36, label %33
17: ; preds = %4
%18 = add nsw i32 %9, -1
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %23, %17
%21 = call i64 @read(i32 %1, i8* %5, i32 1)
%22 = icmp eq i64 %21, 0
br i1 %22, label %46, label %29
23: ; preds = %17, %23
%24 = phi i32 [ %27, %23 ], [ 0, %17 ]
%25 = call i64 @read(i32 %1, i8* %5, i32 1)
%26 = trunc i64 %25 to i32
%27 = add i32 %24, %26
%28 = icmp eq i32 %27, %18
br i1 %28, label %20, label %23
29: ; preds = %20, %29
%30 = call i32 @write(i32 1, i8* %5, i32 1)
%31 = call i64 @read(i32 %1, i8* %5, i32 1)
%32 = icmp eq i64 %31, 0
br i1 %32, label %46, label %29
33: ; preds = %36, %14
%34 = call i64 @read(i32 %1, i8* %5, i32 1)
%35 = icmp eq i64 %34, 0
br i1 %35, label %46, label %42
36: ; preds = %14, %36
%37 = phi i32 [ %40, %36 ], [ 0, %14 ]
%38 = call i64 @read(i32 %1, i8* %5, i32 1)
%39 = trunc i64 %38 to i32
%40 = add i32 %37, %39
%41 = icmp slt i32 %40, %15
br i1 %41, label %36, label %33
42: ; preds = %33, %42
%43 = call i32 @write(i32 1, i8* %5, i32 1)
%44 = call i64 @read(i32 %1, i8* %5, i32 1)
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %42
46: ; preds = %42, %29, %33, %20
ret void
}