#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char const *);
int /*<<< orphan*/ stdout;
scalar_t__ system(char *);
void show_cpu_dir(const char *sys_cpu_path) {
  char cmd_ls[256];
  sprintf(cmd_ls, "ls -l %s", sys_cpu_path);
  printf("$ %s\n", cmd_ls);
  fflush(stdout);
  if (system(cmd_ls)) {
    perror("system() failed");
    exit(EXIT_FAILURE);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<show_cpu_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe7f(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x110(%rbp),%rsi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
lea    -0x110(%rbp),%rdi
call   1030 <system@plt>
cmp    $0x0,%rax
je     11d9 <show_cpu_dir+0x79>
lea    0xe49(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_cpu_dir>:
push   %rbx
sub    $0x100,%rsp
mov    %rdi,%rdx
lea    0xe7e(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1080 <sprintf@plt>
lea    0xe75(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
test   %rax,%rax
jne    11cc <show_cpu_dir+0x5c>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x100,%rsp
pop    %rbx
ret
lea    0xe3c(%rip),%rdi
call   1070 <perror@plt>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"ls -l %s\00"
@.str.1 = [6 x i8] c"$ %s\0A\00"
@stdout = global i32 0
@.str.2 = [16 x i8] c"system() failed\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [2 x i8] c"\0A\00"
define void @show_cpu_dir(i8* %0) {
%2 = alloca i8*
%3 = alloca [256 x i8]
store i8* %0, i8** %2
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = load i8*, i8** %2
%6 = call i32 @sprintf(i8* %4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = load i32, i32* @stdout
%10 = call i32 @fflush(i32 %9)
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%12 = call i64 @system(i8* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %1
%15 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %1
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"ls -l %s\00"
@.str.1 = [6 x i8] c"$ %s\0A\00"
@stdout = global i32 0
@.str.2 = [16 x i8] c"system() failed\00"
@EXIT_FAILURE = global i32 0
define void @show_cpu_dir(i8* %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%6 = load i32, i32* @stdout
%7 = call i32 @fflush(i32 %6)
%8 = call i64 @system(i8* %3)
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %1
%11 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %1
%15 = call i32 @putchar(i32 10)
ret void
}