#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 /*<<< orphan*/ printf(char *, char *);
char *strcat(char *, char *);
int main() {
  char a[30] = "string(1)";
  char b[] = "string(2)";
  printf("before strcat() : %s\n", a);
  printf("after strcat() : %s\n", strcat(a, b));
  printf("after strcat() : %s\n", a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec2(%rip),%eax
mov    %eax,-0x18(%rbp)
mov    0xebc(%rip),%ax
mov    %ax,-0x14(%rbp)
mov    0xeb3(%rip),%rax
mov    %rax,-0x3a(%rbp)
mov    0xeb0(%rip),%ax
mov    %ax,-0x32(%rbp)
lea    -0x30(%rbp),%rsi
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
lea    -0x3a(%rbp),%rsi
call   1040 <strcat@plt>
mov    %rax,%rsi
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
movups 0xee0(%rip),%xmm0
movups %xmm0,0x1e(%rsp)
movaps 0xec6(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0x3228676e69727473,%rax
67 28 32
mov    %rax,(%rsp)
movw   $0x29,0x8(%rsp)
lea    0xecd(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <strcat@plt>
lea    0xec4(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.a = [30 x i8] c"string(1)\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.b = [10 x i8] c"string(2)\00"
@.str = [22 x i8] c"before strcat() : %s\0A\00"
@.str.1 = [21 x i8] c"after strcat() : %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [30 x i8]
%3 = alloca [10 x i8]
store i32 0, i32* %1
%4 = bitcast [30 x i8]* %2 to i8*
%5 = bitcast [10 x i8]* %3 to i8*
%6 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%7 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%10 = call i8* @strcat(i8* %8, i8* %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%13 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %12)
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [30 x i8] c"string(1)\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.b = [10 x i8] c"string(2)\00"
@.str = [22 x i8] c"before strcat() : %s\0A\00"
@.str.1 = [21 x i8] c"after strcat() : %s\0A\00"
define i32 @main() {
%1 = alloca [30 x i8]
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%5 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %3)
%6 = call i8* @strcat(i8* %3, i8* %4)
%7 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%8 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %3)
ret i32 0
}