#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 STDIN_FILENO;
int cat_file(int);
int /*<<< orphan*/ close(int);
int open(char const *, int /*<<< orphan*/);
scalar_t__ strcmp(char const *, char *);
const char *process_files(const char *files[]) {
  if (*files == NULL) {
    if (!cat_file(STDIN_FILENO))
      return "stdin";
  } else {
    for (; *files; files++) {
      if (strcmp(*files, "-") == 0) {
        if (!cat_file(STDIN_FILENO))
          return "stdin";
      } else {
        int fd = open(*files, O_RDONLY);
        if (fd < 0)
          return *files;
        bool cat_result = cat_file(fd);
        close(fd);
        if (!cat_result)
          return *files;
      }
    }
  }
  return NULL;
}


x86 assembly (clang, -O0):
<process_files>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1186 <process_files+0x46>
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
call   1060 <cat_file@plt>
cmp    $0x0,%eax
jne    1181 <process_files+0x41>
lea    0xe88(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1269 <process_files+0x129>
jmp    1261 <process_files+0x121>
jmp    118b <process_files+0x4b>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     125c <process_files+0x11c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe5f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11e2 <process_files+0xa2>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
call   1060 <cat_file@plt>
cmp    $0x0,%eax
jne    11dd <process_files+0x9d>
lea    0xe2c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1269 <process_files+0x129>
jmp    1246 <process_files+0x106>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    0x2df8(%rip),%rax
mov    (%rax),%esi
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1214 <process_files+0xd4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    1269 <process_files+0x129>
mov    -0x14(%rbp),%edi
call   1060 <cat_file@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <close@plt>
cmpl   $0x0,-0x18(%rbp)
jne    1241 <process_files+0x101>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    1269 <process_files+0x129>
jmp    1246 <process_files+0x106>
jmp    124b <process_files+0x10b>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    118b <process_files+0x4b>
jmp    1261 <process_files+0x121>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_files>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     11c9 <process_files+0x89>
lea    0xea9(%rip),%r15
lea    0xe9c(%rip),%r14
mov    0x2e7d(%rip),%r13
jmp    118f <process_files+0x4f>
nopl   (%rax)
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
call   1060 <cat_file@plt>
test   %eax,%eax
je     11e7 <process_files+0xa7>
mov    0x8(%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
je     11db <process_files+0x9b>
mov    %r15,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1170 <process_files+0x30>
mov    (%rbx),%rdi
mov    0x0(%r13),%esi
call   1050 <open@plt>
test   %eax,%eax
js     11c4 <process_files+0x84>
mov    %eax,%ebp
mov    %eax,%edi
call   1060 <cat_file@plt>
mov    %eax,%r12d
mov    %ebp,%edi
call   1030 <close@plt>
test   %r12d,%r12d
jne    1182 <process_files+0x42>
mov    (%rbx),%r14
jmp    11e7 <process_files+0xa7>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
call   1060 <cat_file@plt>
test   %eax,%eax
je     11e0 <process_files+0xa0>
xor    %r14d,%r14d
jmp    11e7 <process_files+0xa7>
lea    0xe19(%rip),%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
@.str = [6 x i8] c"stdin\00"
@.str.1 = [2 x i8] c"-\00"
@O_RDONLY = global i32 0
define i8* @process_files(i8** %0) {
%2 = alloca i8*
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i32
store i8** %0, i8*** %3
%6 = load i8**, i8*** %3
%7 = load i8*, i8** %6
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %15
9: ; preds = %1
%10 = load i32, i32* @STDIN_FILENO
%11 = call i32 @cat_file(i32 %10)
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %9
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %2
br label %58
14: ; preds = %9
br label %57
15: ; preds = %1
br label %16
16: ; preds = %53, %15
%17 = load i8**, i8*** %3
%18 = load i8*, i8** %17
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %56
20: ; preds = %16
%21 = load i8**, i8*** %3
%22 = load i8*, i8** %21
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %20
%26 = load i32, i32* @STDIN_FILENO
%27 = call i32 @cat_file(i32 %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %25
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %2
br label %58
30: ; preds = %25
br label %52
31: ; preds = %20
%32 = load i8**, i8*** %3
%33 = load i8*, i8** %32
%34 = load i32, i32* @O_RDONLY
%35 = call i32 @open(i8* %33, i32 %34)
store i32 %35, i32* %4
%36 = load i32, i32* %4
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %31
%39 = load i8**, i8*** %3
%40 = load i8*, i8** %39
store i8* %40, i8** %2
br label %58
41: ; preds = %31
%42 = load i32, i32* %4
%43 = call i32 @cat_file(i32 %42)
store i32 %43, i32* %5
%44 = load i32, i32* %4
%45 = call i32 @close(i32 %44)
%46 = load i32, i32* %5
%47 = icmp ne i32 %46, 0
br i1 %47, label %51, label %48
48: ; preds = %41
%49 = load i8**, i8*** %3
%50 = load i8*, i8** %49
store i8* %50, i8** %2
br label %58
51: ; preds = %41
br label %52
52: ; preds = %51, %30
br label %53
53: ; preds = %52
%54 = load i8**, i8*** %3
%55 = getelementptr inbounds i8*, i8** %54, i32 1
store i8** %55, i8*** %3
br label %16
56: ; preds = %16
br label %57
57: ; preds = %56, %14
store i8* null, i8** %2
br label %58
58: ; preds = %57, %48, %38, %29, %13
%59 = load i8*, i8** %2
ret i8* %59
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@.str = [6 x i8] c"stdin\00"
@.str.1 = [2 x i8] c"-\00"
@O_RDONLY = global i32 0
define i8* @process_files(i8** nocapture %0) {
%2 = load i8*, i8** %0
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = load i32, i32* @STDIN_FILENO
%6 = tail call i32 @cat_file(i32 %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %35, label %34
8: ; preds = %1, %30
%9 = phi i8** [ %31, %30 ], [ %0, %1 ]
%10 = phi i8* [ %32, %30 ], [ %2, %1 ]
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = load i32, i32* @STDIN_FILENO
%15 = tail call i32 @cat_file(i32 %14)
%16 = icmp eq i32 %15, 0
br i1 %16, label %35, label %30
17: ; preds = %8
%18 = load i8*, i8** %9
%19 = load i32, i32* @O_RDONLY
%20 = tail call i32 @open(i8* %18, i32 %19)
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = load i8*, i8** %9
br label %35
24: ; preds = %17
%25 = tail call i32 @cat_file(i32 %20)
%26 = tail call i32 @close(i32 %20)
%27 = icmp eq i32 %25, 0
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = load i8*, i8** %9
br label %35
30: ; preds = %24, %13
%31 = getelementptr inbounds i8*, i8** %9, i64 1
%32 = load i8*, i8** %31
%33 = icmp eq i8* %32, null
br i1 %33, label %34, label %8
34: ; preds = %30, %4
br label %35
35: ; preds = %13, %28, %22, %4, %34
%36 = phi i8* [ null, %34 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %4 ], [ %29, %28 ], [ %23, %22 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %13 ]
ret i8* %36
}