#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 */
char *malloc(scalar_t__);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  char *v[3];
  char *command;
  if (argc < 2) {
    printf("Please type a file name.\n");
    return 1;
  }
  v[0] = "/bin/cat";
  v[1] = argv[1];
  v[2] = NULL;
  command = malloc(strlen(v[0]) + strlen(v[1]) + 2);
  sprintf(command, "%s %s", v[0], v[1]);
  system(command);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1188 <main+0x38>
lea    0xe89(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f9 <main+0xa9>
lea    0xe8b(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x40(%rbp),%rdi
add    %rax,%rdi
add    $0x2,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xe3f(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x38(%rbp),%rdi
call   1040 <system@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jg     116c <main+0x1c>
lea    0xeaf(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
jmp    11a7 <main+0x57>
mov    0x8(%rsi),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0xa(%rax),%rdi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe7e(%rip),%rsi
lea    0xe6e(%rip),%rdx
mov    %rax,%rdi
mov    %r14,%rcx
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Please type a file name.\0A\00"
@.str.1 = [9 x i8] c"/bin/cat\00"
@.str.2 = [6 x i8] c"%s %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [3 x i8*]
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %36
12: ; preds = %2
%13 = getelementptr inbounds [3 x i8*], [3 x i8*]* %6, i64 0, i64 0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %13
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = getelementptr inbounds [3 x i8*], [3 x i8*]* %6, i64 0, i64 1
store i8* %16, i8** %17
%18 = getelementptr inbounds [3 x i8*], [3 x i8*]* %6, i64 0, i64 2
store i8* null, i8** %18
%19 = getelementptr inbounds [3 x i8*], [3 x i8*]* %6, i64 0, i64 0
%20 = load i8*, i8** %19
%21 = call i64 @strlen(i8* %20)
%22 = getelementptr inbounds [3 x i8*], [3 x i8*]* %6, i64 0, i64 1
%23 = load i8*, i8** %22
%24 = call i64 @strlen(i8* %23)
%25 = add nsw i64 %21, %24
%26 = add nsw i64 %25, 2
%27 = call i8* @malloc(i64 %26)
store i8* %27, i8** %7
%28 = load i8*, i8** %7
%29 = getelementptr inbounds [3 x i8*], [3 x i8*]* %6, i64 0, i64 0
%30 = load i8*, i8** %29
%31 = getelementptr inbounds [3 x i8*], [3 x i8*]* %6, i64 0, i64 1
%32 = load i8*, i8** %31
%33 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %30, i8* %32)
%34 = load i8*, i8** %7
%35 = call i32 @system(i8* %34)
store i32 0, i32* %3
br label %36
36: ; preds = %12, %10
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"/bin/cat\00"
@.str.2 = [6 x i8] c"%s %s\00"
@str = [25 x i8] c"Please type a file name.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %14
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strlen(i8* dereferenceable(1) %8)
%10 = add nsw i64 %9, 10
%11 = tail call i8* @malloc(i64 %10)
%12 = tail call i32 @sprintf(i8* dereferenceable(1) %11, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%13 = tail call i32 @system(i8* %11)
br label %14
14: ; preds = %6, %4
%15 = phi i32 [ 1, %4 ], [ 0, %6 ]
ret i32 %15
}