#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char const);
void test_const_1(void) {
  const char a = 'a', b = 'b';
  char c = 'c';
  const char *p_a = &a;
  printf("*p_a"
         " = %c\n",
         (*p_a));
  p_a = &b;
  printf("*p_a"
         " = %c\n",
         (*p_a));
  p_a = &c;
  printf("*p_a"
         " = %c\n",
         (*p_a));
  printf("*p_a"
         " = %c\n",
         (*p_a));
}


x86 assembly (clang, -O0):
<test_const_1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movb   $0x61,-0x1(%rbp)
movb   $0x62,-0x2(%rbp)
movb   $0x63,-0x3(%rbp)
lea    -0x1(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
lea    0xec9(%rip),%rdi
movsbl (%rax),%esi
call   1030 <printf@plt>
lea    -0x2(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
lea    0xeae(%rip),%rdi
movsbl (%rax),%esi
call   1030 <printf@plt>
lea    -0x3(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
lea    0xe93(%rip),%rdi
movsbl (%rax),%esi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
lea    0xe80(%rip),%rdi
movsbl (%rax),%esi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_const_1>:
push   %rbx
lea    0xee8(%rip),%rbx
mov    %rbx,%rdi
mov    $0x61,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x62,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x63,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x63,%esi
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"*p_a = %c\0A\00"
define void @test_const_1() {
%1 = alloca i8
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8*
store i8 97, i8* %1
store i8 98, i8* %2
store i8 99, i8* %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = load i8, i8* %5
%7 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext %6)
store i8* %2, i8** %4
%8 = load i8*, i8** %4
%9 = load i8, i8* %8
%10 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext %9)
store i8* %3, i8** %4
%11 = load i8*, i8** %4
%12 = load i8, i8* %11
%13 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext %12)
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
%16 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext %15)
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"*p_a = %c\0A\00"
define void @test_const_1() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext 97)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext 98)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext 99)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext 99)
ret void
}