#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*/ cut_string(char *, char *, int);
int do_open(char *, int);
int /*<<< orphan*/ do_read(int, char *, int);
int /*<<< orphan*/ puts(char *);
void command_show(char *inputed_command) {
  char fname[256], str[1024];
  int fd;
  cut_string(inputed_command, fname, 5);
  if ((fd = do_open(fname, 0x01)) != -1) {
    do_read(fd, str, 2);
    puts(str);
  } else {
    puts("file not found.");
  }
  return;
}


x86 assembly (clang, -O0):
<command_show>:
push   %rbp
mov    %rsp,%rbp
sub    $0x520,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x110(%rbp),%rsi
mov    $0x5,%edx
call   1060 <cut_string@plt>
lea    -0x110(%rbp),%rdi
mov    $0x1,%esi
call   1050 <do_open@plt>
mov    %eax,-0x514(%rbp)
cmp    $0xffffffff,%eax
je     11ac <command_show+0x6c>
mov    -0x514(%rbp),%edi
lea    -0x510(%rbp),%rsi
mov    $0x2,%edx
call   1030 <do_read@plt>
lea    -0x510(%rbp),%rdi
call   1040 <puts@plt>
jmp    11b8 <command_show+0x78>
lea    0xe4d(%rip),%rdi
call   1040 <puts@plt>
add    $0x520,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<command_show>:
push   %rbx
sub    $0x500,%rsp
mov    %rsp,%rbx
mov    %rbx,%rsi
mov    $0x5,%edx
call   1060 <cut_string@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1050 <do_open@plt>
cmp    $0xffffffff,%eax
je     1186 <command_show+0x46>
lea    0x100(%rsp),%rbx
mov    %eax,%edi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <do_read@plt>
mov    %rbx,%rdi
jmp    118d <command_show+0x4d>
lea    0xe73(%rip),%rdi
call   1040 <puts@plt>
add    $0x500,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"file not found.\00"
define void @command_show(i8* %0) {
%2 = alloca i8*
%3 = alloca [256 x i8]
%4 = alloca [1024 x i8]
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%8 = call i32 @cut_string(i8* %6, i8* %7, i32 5)
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%10 = call i32 @do_open(i8* %9, i32 1)
store i32 %10, i32* %5
%11 = icmp ne i32 %10, -1
br i1 %11, label %12, label %18
12: ; preds = %1
%13 = load i32, i32* %5
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%15 = call i32 @do_read(i32 %13, i8* %14, i32 2)
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%17 = call i32 @puts(i8* %16)
br label %20
18: ; preds = %1
%19 = call i32 @puts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %18, %12
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"file not found.\00"
define void @command_show(i8* %0) {
%2 = alloca [256 x i8]
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = call i32 @cut_string(i8* %0, i8* %4, i32 5)
%7 = call i32 @do_open(i8* %4, i32 1)
%8 = icmp eq i32 %7, -1
br i1 %8, label %12, label %9
9: ; preds = %1
%10 = call i32 @do_read(i32 %7, i8* %5, i32 2)
%11 = call i32 @puts(i8* %5)
br label %14
12: ; preds = %1
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %9
ret void
}