#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 *, ...);
char *strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(void) {
  char a[100] = "Happiness";
  char b[100] = "A penis";
  char *c;
  c = malloc(100);
  strcpy(c, "Come on...");
  printf("Control:\n");
  (printf("\t%s = [%s]\n", "a", (a)));
  (printf("\t%s = [%s]\n", "b", (b)));
  (printf("\t%s = [%s]\n", "c", (c)));
  printf("Test:\n");
  c = strcat(a, b);
  (printf("\t%s = [%s]\n", "a", (a)));
  (printf("\t%s = [%s]\n", "b", (b)));
  (printf("\t%s = [%s]\n", "c", (c)));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xe93(%rip),%rsi
mov    $0x64,%edx
call   1050 <memcpy@plt>
lea    -0xe0(%rbp),%rdi
lea    0xeeb(%rip),%rsi
mov    $0x64,%edx
call   1050 <memcpy@plt>
mov    $0x64,%edi
call   1060 <malloc@plt>
mov    %rax,-0xe8(%rbp)
mov    -0xe8(%rbp),%rdi
lea    0xf26(%rip),%rsi
call   1030 <strcpy@plt>
lea    0xf25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdx
lea    0xf1d(%rip),%rdi
lea    0xf22(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xe0(%rbp),%rdx
lea    0xf01(%rip),%rdi
lea    0xf08(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xe8(%rbp),%rdx
lea    0xee5(%rip),%rdi
lea    0xeee(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1070 <strcat@plt>
mov    %rax,-0xe8(%rbp)
lea    -0x70(%rbp),%rdx
lea    0xea7(%rip),%rdi
lea    0xeac(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xe0(%rbp),%rdx
lea    0xe8b(%rip),%rdi
lea    0xe92(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xe8(%rbp),%rdx
lea    0xe6f(%rip),%rdi
lea    0xe78(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
movaps 0xee8(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
movaps 0xec9(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xeaa(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xe8b(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xe6c(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xe4d(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movl   $0x0,0xd0(%rsp)
movaps 0xef6(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xeda(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xebe(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xea2(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe86(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe6a(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
mov    $0x64,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xeae(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
lea    0xebc(%rip),%rdi
call   1040 <puts@plt>
lea    0xe9e(%rip),%r12
lea    0xea3(%rip),%rsi
lea    0x70(%rsp),%r14
mov    %r12,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe8c(%rip),%r13
mov    %rsp,%rbp
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe74(%rip),%r15
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe68(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1070 <strcat@plt>
mov    %r12,%rdi
lea    0xe3f(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.a = [100 x i8] c"Happiness\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.b = [100 x i8] c"A penis\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [11 x i8] c"Come on...\00"
@.str.1 = [10 x i8] c"Control:\0A\00"
@.str.2 = [12 x i8] c"\09%s = [%s]\0A\00"
@.str.3 = [2 x i8] c"a\00"
@.str.4 = [2 x i8] c"b\00"
@.str.5 = [2 x i8] c"c\00"
@.str.6 = [7 x i8] c"Test:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca i8*
store i32 0, i32* %1
%5 = bitcast [100 x i8]* %2 to i8*
%6 = bitcast [100 x i8]* %3 to i8*
%7 = call i8* @malloc(i32 100)
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %4
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%20 = call i8* @strcat(i8* %18, i8* %19)
store i8* %20, i8** %4
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* %21)
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %23)
%25 = load i8*, i8** %4
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* %25)
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [100 x i8] c"Happiness\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.b = [100 x i8] c"A penis\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [11 x i8] c"Come on...\00"
@.str.2 = [12 x i8] c"\09%s = [%s]\0A\00"
@.str.3 = [2 x i8] c"a\00"
@.str.4 = [2 x i8] c"b\00"
@.str.5 = [2 x i8] c"c\00"
@str = [9 x i8] c"Control:\00"
@str.7 = [6 x i8] c"Test:\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = tail call dereferenceable_or_null(100) i8* @malloc(i32 100)
%6 = tail call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* %5)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.7, i64 0, i64 0))
%12 = call i8* @strcat(i8* %3, i8* %4)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* %3)
ret i32 0
}