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


x86 assembly (clang, -O0):
<dodir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0x2f8a(%rip),%rdi
mov    $0x0,%al
call   1050 <tmpnam@plt>
cmpl   $0x0,-0xc(%rbp)
je     117c <dodir+0x4c>
mov    -0x8(%rbp),%rdx
lea    0x2eee(%rip),%rdi
lea    0xe97(%rip),%rsi
lea    0x2f60(%rip),%rcx
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    119c <dodir+0x6c>
mov    -0x8(%rbp),%rdx
lea    0x2ec9(%rip),%rdi
lea    0xe80(%rip),%rsi
lea    0x2f3b(%rip),%rcx
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    0x2ead(%rip),%rdi
mov    $0x0,%al
call   1030 <system@plt>
lea    0x2e9f(%rip),%rdi
lea    0xe61(%rip),%rsi
lea    0x2f11(%rip),%rdx
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    0x2e83(%rip),%rdi
mov    $0x0,%al
call   1030 <system@plt>
lea    0x2e75(%rip),%rdi
lea    0xe3f(%rip),%rsi
lea    0x2ee7(%rip),%rdx
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    0x2e59(%rip),%rdi
mov    $0x0,%al
call   1030 <system@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dodir>:
push   %r15
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %rdi,%r15
lea    0x2f8f(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <tmpnam@plt>
test   %ebx,%ebx
lea    0xeba(%rip),%rax
lea    0xea5(%rip),%rsi
cmove  %rax,%rsi
lea    0x2eea(%rip),%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    0xe92(%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    0xe7c(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <sprintf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <system@plt>

LLVM IR (-O0):
@dodir.cmd = internal global [128 x i8] zeroinitializer
@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
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = 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 = load i32, i32* %4
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i8*, i8** %3
%10 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @dodir.cmd, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %9, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @dodir.name, i64 0, i64 0))
br label %14
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @dodir.cmd, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %12, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @dodir.name, i64 0, i64 0))
br label %14
14: ; preds = %11, %8
%15 = call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @dodir.cmd, i64 0, i64 0))
%16 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @dodir.cmd, i64 0, i64 0), 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))
%17 = call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @dodir.cmd, i64 0, i64 0))
%18 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @dodir.cmd, i64 0, i64 0), 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))
%19 = call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @dodir.cmd, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@dodir.cmd = internal global [128 x i8] zeroinitializer
@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 = 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))
%4 = icmp eq i32 %1, 0
%5 = select i1 %4, 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)
%6 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([128 x i8], [128 x i8]* @dodir.cmd, i64 0, i64 0), i8* dereferenceable(1) %5, i8* %0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @dodir.name, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @dodir.cmd, i64 0, i64 0))
%8 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([128 x i8], [128 x i8]* @dodir.cmd, i64 0, i64 0), 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))
%9 = tail call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @dodir.cmd, i64 0, i64 0))
%10 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([128 x i8], [128 x i8]* @dodir.cmd, i64 0, i64 0), 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))
%11 = tail call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @dodir.cmd, i64 0, i64 0))
ret void
}