void yap_commandline(int argc, char **argv) {
  int loop;
  char buf[4096];
  sprintf(buf, "COMMAND-LINE: %s ", basename(argv[0]));
  for (loop = 1; loop < argc; loop++) {
    sprintf(buf + strlen(buf), "%s ", argv[loop]);
  }
  strcat(buf, "\n");
  yap_report(buf);
}


x86 assembly (clang, -O0):
<yap_commandline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x1020(%rbp),%rax
mov    %rax,-0x1028(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x0,%al
call   1040 <basename@plt>
mov    -0x1028(%rbp),%rdi
mov    %eax,%edx
lea    0xe72(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11f4 <yap_commandline+0xa4>
lea    -0x1020(%rbp),%rax
mov    %rax,-0x1030(%rbp)
lea    -0x1020(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x1030(%rbp),%rdi
add    %rax,%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe2f(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119c <yap_commandline+0x4c>
lea    -0x1020(%rbp),%rdi
lea    0xe10(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x1020(%rbp),%rdi
mov    $0x0,%al
call   1050 <yap_report@plt>
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<yap_commandline>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1000,%rsp
mov    %rsi,%r12
mov    %edi,%ebp
mov    (%rsi),%rdi
xor    %eax,%eax
call   1040 <basename@plt>
lea    0xe9b(%rip),%rsi
mov    %rsp,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <sprintf@plt>
cmp    $0x2,%ebp
jl     11b3 <yap_commandline+0x73>
mov    %ebp,%ebp
mov    $0x1,%ebx
mov    %rsp,%r14
lea    0xe87(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    (%rsp,%rax,1),%rdi
mov    (%r12,%rbx,8),%rdx
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <sprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1190 <yap_commandline+0x50>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
movw   $0xa,(%rsp,%rax,1)
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <yap_report@plt>
add    $0x1000,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"COMMAND-LINE: %s \00"
@.str.1 = [4 x i8] c"%s \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @yap_commandline(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca [4096 x i8]
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%8 = load i8**, i8*** %4
%9 = getelementptr inbounds i8*, i8** %8, i64 0
%10 = load i8*, i8** %9
%11 = call i32 (i8*, ...) bitcast (i32 (...)* @basename to i32 (i8*, ...)*)(i8* %10)
%12 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %11)
store i32 1, i32* %5
br label %13
13: ; preds = %28, %2
%14 = load i32, i32* %5
%15 = load i32, i32* %3
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %31
17: ; preds = %13
%18 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%19 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%20 = call i64 @strlen(i8* %19)
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8**, i8*** %4
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = call i32 (i8*, i8*, ...) @sprintf(i8* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %17
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %13
31: ; preds = %13
%32 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%33 = call i8* @strcat(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%34 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%35 = call i32 (i8*, ...) bitcast (i32 (...)* @yap_report to i32 (i8*, ...)*)(i8* %34)
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"COMMAND-LINE: %s \00"
@.str.1 = [4 x i8] c"%s \00"
define void @yap_commandline(i32 %0, i8** nocapture %1) {
%3 = alloca [4096 x i8]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) bitcast (i32 (...)* @basename to i32 (i8*, ...)*)(i8* %5)
%7 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = icmp sgt i32 %0, 1
br i1 %8, label %9, label %20
9: ; preds = %2
%10 = zext i32 %0 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 1, %9 ], [ %18, %11 ]
%13 = call i64 @strlen(i8* %4)
%14 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 %13
%15 = getelementptr inbounds i8*, i8** %1, i64 %12
%16 = load i8*, i8** %15
%17 = call i32 (i8*, i8*, ...) @sprintf(i8* %14, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = add nuw nsw i64 %12, 1
%19 = icmp eq i64 %18, %10
br i1 %19, label %20, label %11
20: ; preds = %11, %2
%21 = call i64 @strlen(i8* %4)
%22 = getelementptr [4096 x i8], [4096 x i8]* %3, i64 0, i64 %21
%23 = bitcast i8* %22 to i16*
store i16 10, i16* %23
%24 = call i32 (i8*, ...) bitcast (i32 (...)* @yap_report to i32 (i8*, ...)*)(i8* %4)
ret void
}