int mon_printf(fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12)
char *fmt;
int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12;
{
  int ret;
  monLock();
  ret = _printf(fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12);
  monUnlock();
  return (ret);
}


x86 assembly (clang, -O0):
<mon_printf>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x60,%rsp
mov    0x40(%rbp),%eax
mov    0x38(%rbp),%eax
mov    0x30(%rbp),%eax
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x28(%rbp)
mov    %esi,-0x2c(%rbp)
mov    %edx,-0x30(%rbp)
mov    %ecx,-0x34(%rbp)
mov    %r8d,-0x38(%rbp)
mov    %r9d,-0x3c(%rbp)
mov    $0x0,%al
call   1040 <monLock@plt>
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    -0x34(%rbp),%ecx
mov    -0x38(%rbp),%r8d
mov    -0x3c(%rbp),%r9d
mov    0x10(%rbp),%r12d
mov    0x18(%rbp),%r15d
mov    0x20(%rbp),%r14d
mov    0x28(%rbp),%ebx
mov    0x30(%rbp),%r11d
mov    0x38(%rbp),%r10d
mov    0x40(%rbp),%eax
mov    %r12d,(%rsp)
mov    %r15d,0x8(%rsp)
mov    %r14d,0x10(%rsp)
mov    %ebx,0x18(%rsp)
mov    %r11d,0x20(%rsp)
mov    %r10d,0x28(%rsp)
mov    %eax,0x30(%rsp)
mov    $0x0,%al
call   1030 <_printf@plt>
mov    %eax,-0x40(%rbp)
mov    $0x0,%al
call   1050 <monUnlock@plt>
mov    -0x40(%rbp),%eax
add    $0x60,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<mon_printf>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r14d
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %edx,%r13d
mov    %esi,%ebx
mov    %rdi,%rbp
xor    %eax,%eax
call   1040 <monLock@plt>
sub    $0x8,%rsp
mov    %rbp,%rdi
mov    %ebx,%esi
mov    %r13d,%edx
mov    %r12d,%ecx
mov    %r15d,%r8d
mov    %r14d,%r9d
xor    %eax,%eax
mov    0x78(%rsp),%ebp
push   %rbp
mov    0x78(%rsp),%ebp
push   %rbp
mov    0x78(%rsp),%ebp
push   %rbp
mov    0x78(%rsp),%ebp
push   %rbp
mov    0x78(%rsp),%ebp
push   %rbp
mov    0x78(%rsp),%ebp
push   %rbp
mov    0x78(%rsp),%ebp
push   %rbp
call   1030 <_printf@plt>
add    $0x40,%rsp
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <monUnlock@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @mon_printf(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10, i32 %11, i32 %12) {
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
store i8* %0, i8** %14
store i32 %1, i32* %15
store i32 %2, i32* %16
store i32 %3, i32* %17
store i32 %4, i32* %18
store i32 %5, i32* %19
store i32 %6, i32* %20
store i32 %7, i32* %21
store i32 %8, i32* %22
store i32 %9, i32* %23
store i32 %10, i32* %24
store i32 %11, i32* %25
store i32 %12, i32* %26
%28 = call i32 (...) @monLock()
%29 = load i8*, i8** %14
%30 = load i32, i32* %15
%31 = load i32, i32* %16
%32 = load i32, i32* %17
%33 = load i32, i32* %18
%34 = load i32, i32* %19
%35 = load i32, i32* %20
%36 = load i32, i32* %21
%37 = load i32, i32* %22
%38 = load i32, i32* %23
%39 = load i32, i32* %24
%40 = load i32, i32* %25
%41 = load i32, i32* %26
%42 = call i32 (i8*, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @_printf to i32 (i8*, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ...)*)(i8* %29, i32 %30, i32 %31, i32 %32, i32 %33, i32 %34, i32 %35, i32 %36, i32 %37, i32 %38, i32 %39, i32 %40, i32 %41)
store i32 %42, i32* %27
%43 = call i32 (...) @monUnlock()
%44 = load i32, i32* %27
ret i32 %44
}

LLVM IR (-O2):
define i32 @mon_printf(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10, i32 %11, i32 %12) {
%14 = tail call i32 (...) @monLock()
%15 = tail call i32 (i8*, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @_printf to i32 (i8*, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ...)*)(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10, i32 %11, i32 %12)
%16 = tail call i32 (...) @monUnlock()
ret i32 %15
}