#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*/ cat_file(char *);
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char const *, char *);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
void cmd_line_cat(const char *arg_line) {
  if (strcmp(arg_line, "--HELP") == 0) {
    printf(
        "Print contents of a file to screen\nusage: cat <file1, file2, ...>\n");
    return;
  }
  char arg_line_copy[256];
  strcpy(arg_line_copy, arg_line);
  char *fname = arg_line_copy;
  int i;
  for (i = 0; i < strlen(arg_line); i++) {
    if (arg_line_copy[i] == ' ') {
      arg_line_copy[i] = '\0';
      cat_file(fname);
      fname = arg_line_copy + i + 1;
    }
  }
  cat_file(fname);
}


x86 assembly (clang, -O0):
<cmd_line_cat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    118a <cmd_line_cat+0x3a>
lea    0xe87(%rip),%rdi
call   1050 <printf@plt>
jmp    124b <cmd_line_cat+0xfb>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x110(%rbp),%rax
mov    %rax,-0x118(%rbp)
movl   $0x0,-0x11c(%rbp)
mov    -0x11c(%rbp),%eax
mov    %eax,-0x120(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x120(%rbp),%eax
cmp    %ecx,%eax
jge    123f <cmd_line_cat+0xef>
movslq -0x11c(%rbp),%rax
movsbl -0x110(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
jne    1226 <cmd_line_cat+0xd6>
movslq -0x11c(%rbp),%rax
movb   $0x0,-0x110(%rbp,%rax,1)
mov    -0x118(%rbp),%rdi
call   1070 <cat_file@plt>
lea    -0x110(%rbp),%rax
movslq -0x11c(%rbp),%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x118(%rbp)
jmp    122b <cmd_line_cat+0xdb>
mov    -0x11c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x11c(%rbp)
jmp    11b2 <cmd_line_cat+0x62>
mov    -0x118(%rbp),%rdi
call   1070 <cat_file@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_line_cat>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%r14
lea    0xe98(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11e5 <cmd_line_cat+0x95>
mov    %rsp,%r15
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    11ce <cmd_line_cat+0x7e>
mov    %rsp,%r15
lea    0x1(%rsp),%rbx
xor    %r12d,%r12d
jmp    11b7 <cmd_line_cat+0x67>
nopl   0x0(%rax)
add    $0x1,%r12
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
add    $0x1,%rbx
cmp    %rax,%r12
jge    11ce <cmd_line_cat+0x7e>
cmpb   $0x20,-0x1(%rbx)
jne    11a0 <cmd_line_cat+0x50>
movb   $0x0,-0x1(%rbx)
mov    %r15,%rdi
call   1070 <cat_file@plt>
mov    %rbx,%r15
jmp    11a0 <cmd_line_cat+0x50>
mov    %r15,%rdi
call   1070 <cat_file@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe1b(%rip),%rdi
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"--HELP\00"
@.str.1 = [67 x i8] c"Print contents of a file to screen\0Ausage: cat <file1, file2, ...>\0A\00"
define void @cmd_line_cat(i8* %0) {
%2 = alloca i8*
%3 = alloca [256 x i8]
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0))
br label %46
11: ; preds = %1
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%13 = load i8*, i8** %2
%14 = call i32 @strcpy(i8* %12, i8* %13)
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
store i8* %15, i8** %4
store i32 0, i32* %5
br label %16
16: ; preds = %40, %11
%17 = load i32, i32* %5
%18 = load i8*, i8** %2
%19 = call i32 @strlen(i8* %18)
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %43
21: ; preds = %16
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 32
br i1 %27, label %28, label %39
28: ; preds = %21
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %30
store i8 0, i8* %31
%32 = load i8*, i8** %4
%33 = call i32 @cat_file(i8* %32)
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = getelementptr inbounds i8, i8* %37, i64 1
store i8* %38, i8** %4
br label %39
39: ; preds = %28, %21
br label %40
40: ; preds = %39
%41 = load i32, i32* %5
%42 = add nsw i32 %41, 1
store i32 %42, i32* %5
br label %16
43: ; preds = %16
%44 = load i8*, i8** %4
%45 = call i32 @cat_file(i8* %44)
br label %46
46: ; preds = %43, %9
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"--HELP\00"
@str = [66 x i8] c"Print contents of a file to screen\0Ausage: cat <file1, file2, ...>\00"
define void @cmd_line_cat(i8* %0) {
%2 = alloca [256 x i8]
%3 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str, i64 0, i64 0))
br label %30
7: ; preds = %1
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%9 = call i32 @strcpy(i8* %8, i8* %0)
%10 = call i32 @strlen(i8* %0)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %27
12: ; preds = %7, %21
%13 = phi i64 [ %23, %21 ], [ 0, %7 ]
%14 = phi i8* [ %22, %21 ], [ %8, %7 ]
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %13
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 32
br i1 %17, label %18, label %21
18: ; preds = %12
store i8 0, i8* %15
%19 = call i32 @cat_file(i8* %14)
%20 = getelementptr inbounds i8, i8* %15, i64 1
br label %21
21: ; preds = %12, %18
%22 = phi i8* [ %20, %18 ], [ %14, %12 ]
%23 = add nuw nsw i64 %13, 1
%24 = call i32 @strlen(i8* %0)
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %23, %25
br i1 %26, label %12, label %27
27: ; preds = %21, %7
%28 = phi i8* [ %8, %7 ], [ %22, %21 ]
%29 = call i32 @cat_file(i8* %28)
br label %30
30: ; preds = %27, %5
ret void
}