#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 *);
int main() {
  char *a = "hello";
  char b[] = "hello";
  printf("a: \"%s\"\n", a);
  printf("b: \"%s\"\n", b);
  b[0] = 'b';
  printf("b: \"%s\"\n", b);
  a[0] = 'c';
  printf("a: \"%s\"\n", a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xed0(%rip),%eax
mov    %eax,-0x16(%rbp)
mov    0xeca(%rip),%ax
mov    %ax,-0x12(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xebd(%rip),%rdi
call   1030 <printf@plt>
lea    -0x16(%rbp),%rsi
lea    0xeb6(%rip),%rdi
call   1030 <printf@plt>
movb   $0x62,-0x16(%rbp)
lea    -0x16(%rbp),%rsi
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movb   $0x63,(%rax)
mov    -0x10(%rbp),%rsi
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movw   $0x6f,0x4(%rsp)
movl   $0x6c6c6568,(%rsp)
lea    0xed3(%rip),%r14
lea    0xed2(%rip),%r15
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
lea    0xec9(%rip),%rbx
mov    %rsp,%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <printf@plt>
movb   $0x62,(%rsp)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"hello\00"
@__const.main.b = [6 x i8] c"hello\00"
@.str.1 = [9 x i8] c"a: \22%s\22\0A\00"
@.str.2 = [9 x i8] c"b: \22%s\22\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [6 x i8]
store i32 0, i32* %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %2
%4 = bitcast [6 x i8]* %3 to i8*
%5 = load i8*, i8** %2
%6 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%8 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
store i8 98, i8* %9
%10 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%11 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = load i8*, i8** %2
%13 = getelementptr inbounds i8, i8* %12, i64 0
store i8 99, i8* %13
%14 = load i8*, i8** %2
%15 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %14)
ret i32 0
}

LLVM IR (-O2):
@__const.main.b = [6 x i8] c"hello\00"
@.str.1 = [9 x i8] c"a: \22%s\22\0A\00"
@.str.2 = [9 x i8] c"b: \22%s\22\0A\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @__const.main.b, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %2)
store i8 98, i8* %2
%5 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%6 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @__const.main.b, i64 0, i64 0))
ret i32 0
}