#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, char *const);
int main(void) {
  char str1[] = "abcd";
  *(str1 + 2) = 'a';
  printf("%s\n", str1);
  char *pstr1 = str1;
  *(pstr1 + 2) = 'b';
  printf("%s\n", pstr1);
  char *const cpstr1 = str1;
  *(cpstr1 + 2) = 'c';
  printf("%s\n", cpstr1);
  char *pstr2 = "abcd";
  *(pstr2 + 2) = 'd';
  printf("%s", pstr2);
  char *const cpstr2 = "abcd";
  *(cpstr2 + 2) = 'e';
  printf("%s\n", cpstr2);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xedb(%rip),%eax
mov    %eax,-0x9(%rbp)
mov    0xed6(%rip),%al
mov    %al,-0x5(%rbp)
movb   $0x61,-0x7(%rbp)
lea    -0x9(%rbp),%rsi
lea    0xec5(%rip),%rdi
call   1030 <printf@plt>
lea    -0x9(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x62,0x2(%rax)
mov    -0x18(%rbp),%rsi
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
lea    -0x9(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x63,0x2(%rax)
mov    -0x20(%rbp),%rsi
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
lea    0xe74(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movb   $0x64,0x2(%rax)
mov    -0x28(%rbp),%rsi
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
lea    0xe51(%rip),%rax
mov    %rax,-0x30(%rbp)
movb   $0x65,0xe48(%rip)
lea    0xe44(%rip),%rdi
lea    0xe38(%rip),%rsi
call   1030 <printf@plt>
mov    0x2e0c(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x64636261,0x8(%rsp)
64
movb   $0x0,0xc(%rsp)
lea    0xed7(%rip),%r14
movb   $0x61,0xa(%rsp)
lea    0xec7(%rip),%r15
lea    0x8(%rsp),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
movb   $0x62,0xa(%rsp)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
movb   $0x63,0xa(%rsp)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0xe99(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.str1 = [5 x i8] c"abcd\00"
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [5 x i8] c"abcd\00"
@.str.2 = [3 x i8] c"%s\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i8]
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i32 0, i32* %1
%7 = bitcast [5 x i8]* %2 to i8*
%8 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds i8, i8* %8, i64 2
store i8 97, i8* %9
%10 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
store i8* %12, i8** %3
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i64 2
store i8 98, i8* %14
%15 = load i8*, i8** %3
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
store i8* %17, i8** %4
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i64 2
store i8 99, i8* %19
%20 = load i8*, i8** %4
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %20)
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %5
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i64 2
store i8 100, i8* %23
%24 = load i8*, i8** %5
%25 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %24)
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %6
store i8 101, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i64 2)
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0))
%27 = load i32, i32* @EXIT_SUCCESS
ret i32 %27
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [5 x i8] c"abcd\00"
@.str.2 = [3 x i8] c"%s\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [5 x i8]
%2 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%3 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 2
store i8 97, i8* %3
%4 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
store i8 98, i8* %3
%5 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
store i8 99, i8* %3
%6 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
%7 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%9 = load i32, i32* @EXIT_SUCCESS
ret i32 %9
}