int main() {
  int A = 5, B = 7, count_one, count_two;
  printf("The number of bytes written up to this point X%n is being stored in "
         "count_one, and the number of bytes up to here X%n is being stored in "
         "count_two.\n",
         &count_one, &count_two);
  printf("count_one: %d\n", count_one);
  printf("count_two: %d\n", count_two);
  printf("A is %d and is at %08x.  B is %x.\n", A, &A);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x5,-0x8(%rbp)
movl   $0x7,-0xc(%rbp)
lea    0xebc(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xf38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xf36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xf34(%rip),%rdi
lea    -0x8(%rbp),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movl   $0x5,0x14(%rsp)
lea    0xecd(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rsp),%esi
lea    0xf46(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xf43(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf44(%rip),%rdi
lea    0x14(%rsp),%rdx
mov    $0x5,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [149 x i8] c"The number of bytes written up to this point X%n is being stored in count_one, and the number of bytes up to here X%n is being stored in count_two.\0A\00"
@.str.1 = [15 x i8] c"count_one: %d\0A\00"
@.str.2 = [15 x i8] c"count_two: %d\0A\00"
@.str.3 = [35 x i8] c"A is %d and is at %08x. B is %x.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 5, i32* %2
store i32 7, i32* %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %5)
%7 = load i32, i32* %4
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %11, i32* %2)
unreachable
}

LLVM IR (-O2):
@.str = [149 x i8] c"The number of bytes written up to this point X%n is being stored in count_one, and the number of bytes up to here X%n is being stored in count_two.\0A\00"
@.str.1 = [15 x i8] c"count_one: %d\0A\00"
@.str.2 = [15 x i8] c"count_two: %d\0A\00"
@.str.3 = [35 x i8] c"A is %d and is at %08x. B is %x.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
store i32 5, i32* %1
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([149 x i8], [149 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%8 = load i32, i32* %2
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = load i32, i32* %3
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 5, i32* %1)
unreachable
}