#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 *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strncat(char *, char *, int);
int main() {
  char firstName[20] = "John ";
  char firstName2[20] = "John ";
  char *lastName = "Doe";
  char *lastName2 = "Doe";
  strcat(firstName, lastName);
  printf("%s\n", firstName);
  strncat(firstName2, lastName2, 1);
  printf("%s\n", firstName2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb5(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xebb(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xeb8(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xeb6(%rip),%eax
mov    %eax,-0x30(%rbp)
lea    0xeb0(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    0xea5(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1050 <strcat@plt>
lea    -0x20(%rbp),%rsi
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    $0x1,%edx
call   1040 <strncat@plt>
lea    -0x40(%rbp),%rsi
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
movaps 0xec0(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movl   $0x0,0x30(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
lea    0xeb4(%rip),%r14
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcat@plt>
lea    0xea1(%rip),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1040 <strncat@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.firstName = [20 x i8] c"John \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.firstName2 = [20 x i8] c"John \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [4 x i8] c"Doe\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca [20 x i8]
%4 = alloca i8*
%5 = alloca i8*
store i32 0, i32* %1
%6 = bitcast [20 x i8]* %2 to i8*
%7 = bitcast [20 x i8]* %3 to i8*
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %4
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %5
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%9 = load i8*, i8** %4
%10 = call i32 @strcat(i8* %8, i8* %9)
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%14 = load i8*, i8** %5
%15 = call i32 @strncat(i8* %13, i8* %14, i32 1)
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %16)
ret i32 0
}

LLVM IR (-O2):
@__const.main.firstName2 = [20 x i8] c"John \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [4 x i8] c"Doe\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = call i32 @strcat(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = call i32 @strncat(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 1)
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
ret i32 0
}