void dumpMsg(int *msg, int n) {
  int i;
  char mesg[1024];
  sprintf(mesg, "From %d, (", netd_getMyID());
  for (i = 0; i < n - 1; i++)
    sprintf(mesg + strlen(mesg), "%d, ", msg[i]);
  sprintf(mesg + strlen(mesg), "%d)\n", msg[n - 1]);
  printf(mesg);
}


x86 assembly (clang, -O0):
<dumpMsg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x418(%rbp)
mov    $0x0,%al
call   1050 <netd_getMyID@plt>
mov    -0x418(%rbp),%rdi
mov    %eax,%edx
lea    0xe89(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11e1 <dumpMsg+0xa1>
lea    -0x410(%rbp),%rax
mov    %rax,-0x420(%rbp)
lea    -0x410(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x420(%rbp),%rdi
add    %rax,%rdi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe3f(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1185 <dumpMsg+0x45>
lea    -0x410(%rbp),%rax
mov    %rax,-0x428(%rbp)
lea    -0x410(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x428(%rbp),%rdi
add    %rax,%rdi
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
lea    0xdf4(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x410(%rbp),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dumpMsg>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %esi,%r14d
mov    %rdi,%r13
xor    %eax,%eax
call   1050 <netd_getMyID@plt>
lea    0xe9b(%rip),%rsi
mov    %rsp,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <sprintf@plt>
lea    -0x1(%r14),%r12d
cmp    $0x2,%r14d
jl     11b4 <dumpMsg+0x74>
mov    %r12d,%ebp
mov    %rsp,%r14
lea    0xe83(%rip),%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    (%rsp,%rax,1),%rdi
mov    0x0(%r13,%rbx,4),%edx
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <sprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1190 <dumpMsg+0x50>
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    (%rsp,%rax,1),%rdi
movslq %r12d,%rax
mov    0x0(%r13,%rax,4),%edx
lea    0xe3e(%rip),%rsi
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"From %d, (\00"
@.str.1 = [5 x i8] c"%d, \00"
@.str.2 = [5 x i8] c"%d)\0A\00"
define void @dumpMsg(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [1024 x i8]
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%8 = call i32 (...) @netd_getMyID()
%9 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %8)
store i32 0, i32* %5
br label %10
10: ; preds = %26, %2
%11 = load i32, i32* %5
%12 = load i32, i32* %4
%13 = sub nsw i32 %12, 1
%14 = icmp slt i32 %11, %13
br i1 %14, label %15, label %29
15: ; preds = %10
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%18 = call i64 @strlen(i8* %17)
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i32*, i32** %3
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
%24 = load i32, i32* %23
%25 = call i32 (i8*, i8*, ...) @sprintf(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %15
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %10
29: ; preds = %10
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%32 = call i64 @strlen(i8* %31)
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i32*, i32** %3
%35 = load i32, i32* %4
%36 = sub nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %34, i64 %37
%39 = load i32, i32* %38
%40 = call i32 (i8*, i8*, ...) @sprintf(i8* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %39)
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%42 = call i32 (i8*, ...) @printf(i8* %41)
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"From %d, (\00"
@.str.1 = [5 x i8] c"%d, \00"
@.str.2 = [5 x i8] c"%d)\0A\00"
define void @dumpMsg(i32* nocapture %0, i32 %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = tail call i32 (...) @netd_getMyID()
%6 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = add i32 %1, -1
%8 = icmp sgt i32 %1, 1
br i1 %8, label %9, label %20
9: ; preds = %2
%10 = zext i32 %7 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %18, %11 ]
%13 = call i64 @strlen(i8* %4)
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %13
%15 = getelementptr inbounds i32, i32* %0, i64 %12
%16 = load i32, i32* %15
%17 = call i32 (i8*, i8*, ...) @sprintf(i8* %14, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %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 inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %21
%23 = sext i32 %7 to i64
%24 = getelementptr inbounds i32, i32* %0, i64 %23
%25 = load i32, i32* %24
%26 = call i32 (i8*, i8*, ...) @sprintf(i8* %22, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = call i32 (i8*, ...) @printf(i8* %4)
ret void
}