#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 */
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
void main(int argc, char **argv) {
  char s[10];
  s[0] = 'a';
  *(s + 1) = '0';
  s[2] = 'c';
  s[3] = 0;
  char *s1 = malloc(15);
  strcpy(s1, "abcdefg0123");
  int code0 = '0';
  printf("\ns=%s , s1=%s, code0=%0x %d %c\n", s, s1, code0, code0, code0);
  s1[5] = 0;
  printf("\ns=%s , s1=%s, code0=%0x %ld %c\n", s, s1, '1', s, code0);
  printf("&s1=%ld s1=%s, code0=%0x %ld %c\n", s1, s1 + 6, '1', s, code0);
  s1 = s;
  printf("s1=%s s=%s");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x61,-0x1a(%rbp)
movb   $0x30,-0x19(%rbp)
movb   $0x63,-0x18(%rbp)
movb   $0x0,-0x17(%rbp)
mov    $0xf,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x30,-0x2c(%rbp)
lea    -0x1a(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
movb   $0x0,0x5(%rax)
lea    -0x1a(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    -0x1a(%rbp),%r8
mov    -0x2c(%rbp),%r9d
lea    0xe78(%rip),%rdi
mov    $0x31,%ecx
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rsi
mov    -0x28(%rbp),%rdx
add    $0x6,%rdx
lea    -0x1a(%rbp),%r8
mov    -0x2c(%rbp),%r9d
lea    0xe72(%rip),%rdi
mov    $0x31,%ecx
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1a(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movl   $0x633061,0xe(%rsp)
mov    $0xf,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xead(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
lea    0xeaa(%rip),%rdi
lea    0xe(%rsp),%r14
mov    %r14,%rsi
mov    %rbx,%rdx
mov    $0x30,%ecx
mov    $0x30,%r8d
mov    $0x30,%r9d
xor    %eax,%eax
call   1040 <printf@plt>
movb   $0x0,0x5(%rbx)
lea    0xe9c(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    $0x31,%ecx
mov    %r14,%r8
mov    $0x30,%r9d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x6(%rbx),%rdx
lea    0xe97(%rip),%rdi
mov    %rbx,%rsi
mov    $0x31,%ecx
mov    %r14,%r8
mov    $0x30,%r9d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe99(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"abcdefg0123\00"
@.str.1 = [32 x i8] c"\0As=%s , s1=%s, code0=%0x %d %c\0A\00"
@.str.2 = [33 x i8] c"\0As=%s , s1=%s, code0=%0x %ld %c\0A\00"
@.str.3 = [33 x i8] c"&s1=%ld s1=%s, code0=%0x %ld %c\0A\00"
@.str.4 = [11 x i8] c"s1=%s s=%s\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [10 x i8]
%6 = alloca i8*
%7 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
store i8 97, i8* %8
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds i8, i8* %9, i64 1
store i8 48, i8* %10
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 2
store i8 99, i8* %11
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 3
store i8 0, i8* %12
%13 = call i8* @malloc(i32 15)
store i8* %13, i8** %6
%14 = load i8*, i8** %6
%15 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 48, i32* %7
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%17 = load i8*, i8** %6
%18 = load i32, i32* %7
%19 = load i32, i32* %7
%20 = load i32, i32* %7
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %16, i8* %17, i32 %18, i32 %19, i32 %20)
%22 = load i8*, i8** %6
%23 = getelementptr inbounds i8, i8* %22, i64 5
store i8 0, i8* %23
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%25 = load i8*, i8** %6
%26 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%27 = load i32, i32* %7
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %24, i8* %25, i32 49, i8* %26, i32 %27)
%29 = load i8*, i8** %6
%30 = load i8*, i8** %6
%31 = getelementptr inbounds i8, i8* %30, i64 6
%32 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%33 = load i32, i32* %7
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %29, i8* %31, i32 49, i8* %32, i32 %33)
%35 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
store i8* %35, i8** %6
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"abcdefg0123\00"
@.str.1 = [32 x i8] c"\0As=%s , s1=%s, code0=%0x %d %c\0A\00"
@.str.2 = [33 x i8] c"\0As=%s , s1=%s, code0=%0x %ld %c\0A\00"
@.str.3 = [33 x i8] c"&s1=%ld s1=%s, code0=%0x %ld %c\0A\00"
@.str.4 = [11 x i8] c"s1=%s s=%s\00"
define void @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [10 x i8]
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
store i8 97, i8* %4
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 1
store i8 48, i8* %5
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 2
store i8 99, i8* %6
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 3
store i8 0, i8* %7
%8 = tail call dereferenceable_or_null(15) i8* @malloc(i32 15)
%9 = tail call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %4, i8* %8, i32 48, i32 48, i32 48)
%11 = getelementptr inbounds i8, i8* %8, i64 5
store i8 0, i8* %11
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %4, i8* %8, i32 49, i8* %4, i32 48)
%13 = getelementptr inbounds i8, i8* %8, i64 6
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %8, i8* %13, i32 49, i8* %4, i32 48)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
ret void
}