#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*/ free_two(char *);
char *malloc_two(unsigned int const);
int /*<<< orphan*/ printf(char *, char *);
int strlen(char const *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
int main(void) {
  const char *title = "The Unix Programming Environment";
  const unsigned int size = strlen(title);
  char *ptr;
  ptr = malloc_two(size);
  strncpy(ptr, title, strlen(title) + 1);
  printf("%s\n", ptr);
  free_two(ptr);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <malloc_two@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
add    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rsi
lea    0xe69(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1070 <free_two@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
call   1060 <malloc_two@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strncpy@plt>
lea    0xe97(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1070 <free_two@plt>
mov    0x2e3f(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [33 x i8] c"The Unix Programming Environment\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = call i8* @malloc_two(i32 %7)
store i8* %8, i8** %4
%9 = load i8*, i8** %4
%10 = load i8*, i8** %2
%11 = load i8*, i8** %2
%12 = call i32 @strlen(i8* %11)
%13 = add nsw i32 %12, 1
%14 = call i32 @strncpy(i8* %9, i8* %10, i32 %13)
%15 = load i8*, i8** %4
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = load i8*, i8** %4
%18 = call i32 @free_two(i8* %17)
%19 = load i32, i32* @EXIT_SUCCESS
ret i32 %19
}

LLVM IR (-O2):
@.str = [33 x i8] c"The Unix Programming Environment\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i32 @strlen(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%2 = tail call i8* @malloc_two(i32 %1)
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%4 = add nsw i32 %3, 1
%5 = tail call i32 @strncpy(i8* %2, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%7 = tail call i32 @free_two(i8* %2)
%8 = load i32, i32* @EXIT_SUCCESS
ret i32 %8
}