#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*/ O_RDONLY;
int /*<<< orphan*/ S_IRUSR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ ft_putstr(char *);
int /*<<< orphan*/ on_empty();
int /*<<< orphan*/ on_error(char *);
int open(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int read(int, char *, int);
int main(int argc, char **argv) {
  int file;
  int re;
  char buffer[29000 + 1];
  int i;
  if (argc == 1)
    on_empty();
  i = 1;
  while (i < argc) {
    file = open(argv[i], O_RDONLY, S_IRUSR);
    if (file == -1)
      on_error(argv[i]);
    else {
      re = read(file, buffer, 29000);
      buffer[re] = '\0';
      ft_putstr(buffer);
      close(file);
    }
    i++;
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7180,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    118a <main+0x2a>
mov    $0x0,%al
call   1050 <on_empty@plt>
movl   $0x1,-0x7174(%rbp)
mov    -0x7174(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    123a <main+0xda>
mov    -0x10(%rbp),%rax
movslq -0x7174(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2e2f(%rip),%rax
mov    (%rax),%esi
mov    0x2e16(%rip),%rax
mov    (%rax),%edx
call   1060 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11ef <main+0x8f>
mov    -0x10(%rbp),%rax
movslq -0x7174(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1080 <on_error@plt>
jmp    1226 <main+0xc6>
mov    -0x14(%rbp),%edi
lea    -0x7170(%rbp),%rsi
mov    $0x7148,%edx
call   1040 <read@plt>
mov    %eax,-0x18(%rbp)
movslq -0x18(%rbp),%rax
movb   $0x0,-0x7170(%rbp,%rax,1)
lea    -0x7170(%rbp),%rdi
call   1070 <ft_putstr@plt>
mov    -0x14(%rbp),%edi
call   1030 <close@plt>
mov    -0x7174(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7174(%rbp)
jmp    1194 <main+0x34>
xor    %eax,%eax
add    $0x7180,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7158,%rsp
cmp    $0x1,%edi
jne    117f <main+0x1f>
xor    %eax,%eax
call   1050 <on_empty@plt>
jmp    11f5 <main+0x95>
jle    11f5 <main+0x95>
mov    %rsi,%r12
mov    %edi,%r15d
mov    $0x1,%ebx
mov    0x2e45(%rip),%r13
mov    %rsp,%r14
jmp    11cf <main+0x6f>
nopl   0x0(%rax,%rax,1)
mov    %eax,%ebp
mov    %eax,%edi
mov    %r14,%rsi
mov    $0x7148,%edx
call   1040 <read@plt>
cltq
movb   $0x0,(%rsp,%rax,1)
mov    %r14,%rdi
call   1070 <ft_putstr@plt>
mov    %ebp,%edi
call   1030 <close@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
je     11f5 <main+0x95>
mov    (%r12,%rbx,8),%rdi
mov    0x2e0e(%rip),%rax
mov    (%rax),%esi
mov    0x0(%r13),%edx
call   1060 <open@plt>
cmp    $0xffffffff,%eax
jne    11a0 <main+0x40>
mov    (%r12,%rbx,8),%rdi
call   1080 <on_error@plt>
jmp    11c6 <main+0x66>
xor    %eax,%eax
add    $0x7158,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
@S_IRUSR = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [29001 x i8]
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (...) @on_empty()
br label %14
14: ; preds = %12, %2
store i32 1, i32* %9
br label %15
15: ; preds = %48, %14
%16 = load i32, i32* %9
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %51
19: ; preds = %15
%20 = load i8**, i8*** %5
%21 = load i32, i32* %9
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = load i32, i32* @O_RDONLY
%26 = load i32, i32* @S_IRUSR
%27 = call i32 @open(i8* %24, i32 %25, i32 %26)
store i32 %27, i32* %6
%28 = load i32, i32* %6
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %37
30: ; preds = %19
%31 = load i8**, i8*** %5
%32 = load i32, i32* %9
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = call i32 @on_error(i8* %35)
br label %48
37: ; preds = %19
%38 = load i32, i32* %6
%39 = getelementptr inbounds [29001 x i8], [29001 x i8]* %8, i64 0, i64 0
%40 = call i32 @read(i32 %38, i8* %39, i32 29000)
store i32 %40, i32* %7
%41 = load i32, i32* %7
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [29001 x i8], [29001 x i8]* %8, i64 0, i64 %42
store i8 0, i8* %43
%44 = getelementptr inbounds [29001 x i8], [29001 x i8]* %8, i64 0, i64 0
%45 = call i32 @ft_putstr(i8* %44)
%46 = load i32, i32* %6
%47 = call i32 @close(i32 %46)
br label %48
48: ; preds = %37, %30
%49 = load i32, i32* %9
%50 = add nsw i32 %49, 1
store i32 %50, i32* %9
br label %15
51: ; preds = %15
ret i32 0
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@S_IRUSR = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [29001 x i8]
%4 = getelementptr inbounds [29001 x i8], [29001 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 1
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 (...) @on_empty()
br label %32
8: ; preds = %2
%9 = icmp sgt i32 %0, 1
br i1 %9, label %10, label %32
10: ; preds = %8
%11 = zext i32 %0 to i64
br label %12
12: ; preds = %10, %29
%13 = phi i64 [ 1, %10 ], [ %30, %29 ]
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = load i32, i32* @O_RDONLY
%17 = load i32, i32* @S_IRUSR
%18 = call i32 @open(i8* %15, i32 %16, i32 %17)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %23
20: ; preds = %12
%21 = load i8*, i8** %14
%22 = call i32 @on_error(i8* %21)
br label %29
23: ; preds = %12
%24 = call i32 @read(i32 %18, i8* %4, i32 29000)
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [29001 x i8], [29001 x i8]* %3, i64 0, i64 %25
store i8 0, i8* %26
%27 = call i32 @ft_putstr(i8* %4)
%28 = call i32 @close(i32 %18)
br label %29
29: ; preds = %23, %20
%30 = add nuw nsw i64 %13, 1
%31 = icmp eq i64 %30, %11
br i1 %31, label %32, label %12
32: ; preds = %29, %6, %8
ret i32 0
}