void dodir(path, full) char *path;
int full;
{
  char cmd[128];
  static char name[32];
  tmpnam(name);
  if (full)
    sprintf(cmd, "ls -l %s > %s", path, name);
  else
    sprintf(cmd, "ls %s > %s", path, name);
  system(cmd);
  sprintf(cmd, "more %s", name);
  system(cmd);
  sprintf(cmd, "rm %s", name);
  system(cmd);
}


x86 assembly (clang, -O0):
<dodir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0x2f07(%rip),%rdi
mov    $0x0,%al
call   1050 <tmpnam@plt>
cmpl   $0x0,-0xc(%rbp)
je     117f <dodir+0x4f>
lea    -0x90(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe94(%rip),%rsi
lea    0x2edd(%rip),%rcx
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    119f <dodir+0x6f>
lea    -0x90(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe7d(%rip),%rsi
lea    0x2eb8(%rip),%rcx
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x90(%rbp),%rdi
mov    $0x0,%al
call   1030 <system@plt>
lea    -0x90(%rbp),%rdi
lea    0xe5e(%rip),%rsi
lea    0x2e8e(%rip),%rdx
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x90(%rbp),%rdi
mov    $0x0,%al
call   1030 <system@plt>
lea    -0x90(%rbp),%rdi
lea    0xe3c(%rip),%rsi
lea    0x2e64(%rip),%rdx
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x90(%rbp),%rdi
mov    $0x0,%al
call   1030 <system@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dodir>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %esi,%ebx
mov    %rdi,%r15
lea    0x2f08(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <tmpnam@plt>
test   %ebx,%ebx
lea    0xeb3(%rip),%rax
lea    0xe9e(%rip),%rsi
cmove  %rax,%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1040 <sprintf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <system@plt>
lea    0xe8f(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <sprintf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <system@plt>
lea    0xe79(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <sprintf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <system@plt>
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@dodir.name = internal global [32 x i8] zeroinitializer
@.str = [14 x i8] c"ls -l %s > %s\00"
@.str.1 = [11 x i8] c"ls %s > %s\00"
@.str.2 = [8 x i8] c"more %s\00"
@.str.3 = [6 x i8] c"rm %s\00"
define void @dodir(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [128 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = call i32 (i8*, ...) bitcast (i32 (...)* @tmpnam to i32 (i8*, ...)*)(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @dodir.name, i64 0, i64 0))
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%11 = load i8*, i8** %3
%12 = call i32 (i8*, i8*, ...) @sprintf(i8* %10, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %11, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @dodir.name, i64 0, i64 0))
br label %17
13: ; preds = %2
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%15 = load i8*, i8** %3
%16 = call i32 (i8*, i8*, ...) @sprintf(i8* %14, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %15, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @dodir.name, i64 0, i64 0))
br label %17
17: ; preds = %13, %9
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%19 = call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* %18)
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%21 = call i32 (i8*, i8*, ...) @sprintf(i8* %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @dodir.name, i64 0, i64 0))
%22 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%23 = call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* %22)
%24 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%25 = call i32 (i8*, i8*, ...) @sprintf(i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @dodir.name, i64 0, i64 0))
%26 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%27 = call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* %26)
ret void
}

LLVM IR (-O2):
@dodir.name = internal global [32 x i8] zeroinitializer
@.str = [14 x i8] c"ls -l %s > %s\00"
@.str.1 = [11 x i8] c"ls %s > %s\00"
@.str.2 = [8 x i8] c"more %s\00"
@.str.3 = [6 x i8] c"rm %s\00"
define void @dodir(i8* %0, i32 %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%5 = tail call i32 (i8*, ...) bitcast (i32 (...)* @tmpnam to i32 (i8*, ...)*)(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @dodir.name, i64 0, i64 0))
%6 = icmp eq i32 %1, 0
%7 = select i1 %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0)
%8 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) %7, i8* %0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @dodir.name, i64 0, i64 0))
%9 = call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* %4)
%10 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @dodir.name, i64 0, i64 0))
%11 = call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* %4)
%12 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @dodir.name, i64 0, i64 0))
%13 = call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* %4)
ret void
}