#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *, char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main() {
  char str1[] = "emile-pascal";
  char *str;
  str = (char *)malloc(6 * sizeof(char));
  strcpy(str, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
  strncpy(str, "pascal", 3);
  printf("%s %s\n", str, str1);
  str[2] = '0';
  str[4] = '\0';
  printf("%d %c %s \n", '0', '0', str);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xeb1(%rip),%rax
mov    %rax,-0xd(%rbp)
mov    0xeaf(%rip),%eax
mov    %eax,-0x5(%rbp)
mov    0xeaa(%rip),%al
mov    %al,-0x1(%rbp)
mov    $0x6,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe8f(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rdi
lea    0xe78(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rsi
lea    -0xd(%rbp),%rdx
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
movb   $0x30,0x2(%rax)
mov    -0x18(%rbp),%rax
movb   $0x0,0x4(%rax)
mov    -0x18(%rbp),%rcx
lea    0xe6d(%rip),%rdi
mov    $0x30,%edx
mov    %rdx,%rsi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movabs $0x6c61637361702d,%rax
mov    %rax,0x5(%rsp)
movabs $0x61702d656c696d65,%rax
2d 70 61
mov    %rax,(%rsp)
mov    $0x6,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe97(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
lea    0xe81(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1030 <strncpy@plt>
lea    0xe96(%rip),%rdi
mov    %rsp,%rdx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
movb   $0x30,0x2(%rbx)
movb   $0x0,0x4(%rbx)
lea    0xe81(%rip),%rdi
mov    $0x30,%esi
mov    $0x30,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.str1 = [13 x i8] c"emile-pascal\00"
@.str = [34 x i8] c"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\00"
@.str.1 = [7 x i8] c"pascal\00"
@.str.2 = [7 x i8] c"%s %s\0A\00"
@.str.3 = [11 x i8] c"%d %c %s \0A\00"
define i32 @main() {
%1 = alloca [13 x i8]
%2 = alloca i8*
%3 = bitcast [13 x i8]* %1 to i8*
%4 = call i64 @malloc(i32 6)
%5 = inttoptr i64 %4 to i8*
store i8* %5, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%8 = load i8*, i8** %2
%9 = call i32 @strncpy(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 3)
%10 = load i8*, i8** %2
%11 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 0
%12 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %10, i8* %11)
%13 = load i8*, i8** %2
%14 = getelementptr inbounds i8, i8* %13, i64 2
store i8 48, i8* %14
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i64 4
store i8 0, i8* %16
%17 = load i8*, i8** %2
%18 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* inttoptr (i64 48 to i8*), i8* inttoptr (i64 48 to i8*), i8* %17)
ret i32 0
}

LLVM IR (-O2):
@__const.main.str1 = [13 x i8] c"emile-pascal\00"
@.str = [34 x i8] c"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\00"
@.str.1 = [7 x i8] c"pascal\00"
@.str.2 = [7 x i8] c"%s %s\0A\00"
@.str.3 = [11 x i8] c"%d %c %s \0A\00"
define i32 @main() {
%1 = alloca [13 x i8]
%2 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 0
%3 = tail call i64 @malloc(i32 6)
%4 = inttoptr i64 %3 to i8*
%5 = tail call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @strncpy(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 3)
%7 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %4, i8* %2)
%8 = getelementptr inbounds i8, i8* %4, i64 2
store i8 48, i8* %8
%9 = getelementptr inbounds i8, i8* %4, i64 4
store i8 0, i8* %9
%10 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* inttoptr (i64 48 to i8*), i8* inttoptr (i64 48 to i8*), i8* %4)
ret i32 0
}