void test() {
  printf("%s", (int)123);
  printf("abc%0f", "testing testing 123");
  printf("%u", (long)-12);
  printf("%p", 123);
  printf("%c\n", "x");
  printf("%c\n", 1.23);
  printf("%+.2d", (unsigned long long)123456);
  printf("%1d", (long double)1.23);
  printf("%0+s", (unsigned)31337);
  printf("%#p", (void *)0);
  printf("% +f", 1.23);
  printf("%0-f", 1.23);
  printf("%1$f:%2$.*3$f:%4$.*3$f\n", 1, 2, 3, 4);
  printf("%10.5d", 1l);
  printf("%.2c", 'a');
  printf("%0-f", 1.23);
  printf("%hhs", "foo");
  printf("%1$zp", (void *)0);
  unsigned long val = 42;
  printf("%X", val);
  typedef long unsigned int size_t;
  typedef long int intmax_t;
  typedef long unsigned int uintmax_t;
  typedef long int ptrdiff_t;
  printf("%f", (size_t)42);
  printf("%f", (intmax_t)42);
  printf("%f", (uintmax_t)42);
  printf("%f", (ptrdiff_t)42);
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xee9(%rip),%rdi
mov    $0x7b,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed9(%rip),%rdi
lea    0xed9(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
mov    $0xfffffffffffffff4,%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecd(%rip),%rdi
mov    $0x7b,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebd(%rip),%rdi
lea    0xeba(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea8(%rip),%rdi
movsd  0xe74(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe98(%rip),%rdi
mov    $0x1e240,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    %rsp,%rax
fldl   0xe51(%rip)
fstpt  (%rax)
lea    0xe80(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe76(%rip),%rdi
mov    $0x7a69,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe68(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5a(%rip),%rdi
movsd  0xe0d(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe49(%rip),%rdi
movsd  0xdf7(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe38(%rip),%rdi
mov    $0x1,%esi
mov    $0x2,%edx
mov    $0x3,%ecx
mov    $0x4,%r8d
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe2d(%rip),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe21(%rip),%rdi
mov    $0x61,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdea(%rip),%rdi
movsd  0xd98(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xdfd(%rip),%rdi
lea    0xdfb(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdf1(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x2a,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdce(%rip),%rdi
mov    $0x2a,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdbb(%rip),%rdi
mov    $0x2a,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xda8(%rip),%rdi
mov    $0x2a,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd95(%rip),%rdi
mov    $0x2a,%esi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbx
sub    $0x10,%rsp
lea    0xeec(%rip),%rdi
mov    $0x7b,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
lea    0xedc(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee2(%rip),%rdi
mov    $0xfffffffffffffff4,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
mov    $0x7b,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec0(%rip),%rbx
lea    0xebd(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movsd  0xe7b(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe9c(%rip),%rdi
mov    $0x1e240,%esi
xor    %eax,%eax
call   1030 <printf@plt>
fldl   0xe58(%rip)
fstpt  (%rsp)
lea    0xe86(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe7c(%rip),%rdi
mov    $0x7a69,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe6e(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe62(%rip),%rdi
movsd  0xe15(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe51(%rip),%rbx
mov    %rbx,%rdi
movsd  0xdfc(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe3d(%rip),%rdi
mov    $0x1,%esi
mov    $0x2,%edx
mov    $0x3,%ecx
mov    $0x4,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe32(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe26(%rip),%rdi
mov    $0x61,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
movsd  0xda1(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe06(%rip),%rdi
lea    0xe04(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xdfa(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xdf0(%rip),%rdi
mov    $0x2a,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xde0(%rip),%rbx
mov    $0x2a,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x2a,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x2a,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x2a,%esi
mov    %rbx,%rdi
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [7 x i8] c"abc%0f\00"
@.str.2 = [20 x i8] c"testing testing 123\00"
@.str.3 = [3 x i8] c"%u\00"
@.str.4 = [3 x i8] c"%p\00"
@.str.5 = [4 x i8] c"%c\0A\00"
@.str.6 = [2 x i8] c"x\00"
@.str.7 = [6 x i8] c"%+.2d\00"
@.str.8 = [4 x i8] c"%1d\00"
@.str.9 = [5 x i8] c"%0+s\00"
@.str.10 = [4 x i8] c"%#p\00"
@.str.11 = [5 x i8] c"% +f\00"
@.str.12 = [5 x i8] c"%0-f\00"
@.str.13 = [24 x i8] c"%1$f:%2$.*3$f:%4$.*3$f\0A\00"
@.str.14 = [7 x i8] c"%10.5d\00"
@.str.15 = [5 x i8] c"%.2c\00"
@.str.16 = [5 x i8] c"%hhs\00"
@.str.17 = [4 x i8] c"foo\00"
@.str.18 = [6 x i8] c"%1$zp\00"
@.str.19 = [3 x i8] c"%X\00"
@.str.20 = [3 x i8] c"%f\00"
define void @test() {
%1 = alloca i64
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 123)
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i64 -12)
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 123)
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), double 1.230000e+00)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i64 123456)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), x86_fp80 0xK3FFF9D70A3D70A3D7000)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 31337)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* null)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), double 1.230000e+00)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), double 1.230000e+00)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0), i32 1, i32 2, i32 3, i32 4)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0), i64 1)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0), i32 97)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), double 1.230000e+00)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.18, i64 0, i64 0), i8* null)
store i64 42, i64* %1
%20 = load i64, i64* %1
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.19, i64 0, i64 0), i64 %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0), i64 42)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0), i64 42)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0), i64 42)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0), i64 42)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [7 x i8] c"abc%0f\00"
@.str.2 = [20 x i8] c"testing testing 123\00"
@.str.3 = [3 x i8] c"%u\00"
@.str.4 = [3 x i8] c"%p\00"
@.str.5 = [4 x i8] c"%c\0A\00"
@.str.6 = [2 x i8] c"x\00"
@.str.7 = [6 x i8] c"%+.2d\00"
@.str.8 = [4 x i8] c"%1d\00"
@.str.9 = [5 x i8] c"%0+s\00"
@.str.10 = [4 x i8] c"%#p\00"
@.str.11 = [5 x i8] c"% +f\00"
@.str.12 = [5 x i8] c"%0-f\00"
@.str.13 = [24 x i8] c"%1$f:%2$.*3$f:%4$.*3$f\0A\00"
@.str.14 = [7 x i8] c"%10.5d\00"
@.str.15 = [5 x i8] c"%.2c\00"
@.str.16 = [5 x i8] c"%hhs\00"
@.str.17 = [4 x i8] c"foo\00"
@.str.18 = [6 x i8] c"%1$zp\00"
@.str.19 = [3 x i8] c"%X\00"
@.str.20 = [3 x i8] c"%f\00"
define void @test() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 123)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i64 -12)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 123)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), double 1.230000e+00)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i64 123456)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), x86_fp80 0xK3FFF9D70A3D70A3D7000)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 31337)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* null)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), double 1.230000e+00)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), double 1.230000e+00)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0), i32 1, i32 2, i32 3, i32 4)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0), i64 1)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0), i32 97)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), double 1.230000e+00)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i64 0, i64 0))
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.18, i64 0, i64 0), i8* null)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.19, i64 0, i64 0), i64 42)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0), i64 42)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0), i64 42)
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0), i64 42)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0), i64 42)
ret void
}