void test_qualifiers(const int *cip, volatile int *vip, const char *ccp,
                     volatile char *vcp, const volatile int *cvip) {
  scanf("%d", cip);
  scanf("%n", cip);
  scanf("%s", ccp);
  scanf("%d", cvip);
  scanf("%d", vip);
  scanf("%n", vip);
  scanf("%c", vcp);
  typedef int *ip_t;
  typedef const int *cip_t;
  scanf("%d", (ip_t)0);
  scanf("%d", (cip_t)0);
}


x86 assembly (clang, -O0):
<test_qualifiers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <scanf@plt>
mov    -0x8(%rbp),%rsi
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <scanf@plt>
mov    -0x18(%rbp),%rsi
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <scanf@plt>
mov    -0x28(%rbp),%rsi
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <scanf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <scanf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <scanf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <scanf@plt>
lea    0xe4f(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x0,%al
call   1030 <scanf@plt>
lea    0xe3d(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x0,%al
call   1030 <scanf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_qualifiers>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r12
mov    %rcx,(%rsp)
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %rdi,%rbp
lea    0xece(%rip),%r15
mov    %r15,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1030 <scanf@plt>
lea    0xebd(%rip),%r14
mov    %r14,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1030 <scanf@plt>
lea    0xeac(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1030 <scanf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <scanf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <scanf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <scanf@plt>
lea    0xe77(%rip),%rdi
mov    (%rsp),%rsi
xor    %eax,%eax
call   1030 <scanf@plt>
mov    %r15,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <scanf@plt>
mov    %r15,%rdi
xor    %esi,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <scanf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%n\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [3 x i8] c"%c\00"
define void @test_qualifiers(i32* %0, i32* %1, i8* %2, i8* %3, i32* %4) {
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32*
store i32* %0, i32** %6
store i32* %1, i32** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i32* %4, i32** %10
%11 = load i32*, i32** %6
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %11)
%13 = load i32*, i32** %6
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %13)
%15 = load i8*, i8** %8
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = load i32*, i32** %10
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %17)
%19 = load i32*, i32** %7
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %19)
%21 = load i32*, i32** %7
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %21)
%23 = load i8*, i8** %9
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %23)
%25 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* null)
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* null)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%n\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [3 x i8] c"%c\00"
define void @test_qualifiers(i32* %0, i32* %1, i8* %2, i8* %3, i32* %4) {
%6 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %0)
%7 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %0)
%8 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%9 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%10 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%11 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%12 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%13 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* null)
%14 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* null)
ret void
}