#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 *);
char *strncat(char *, char *, int);
int main(void) {
  char s1[20] = "Happy ";
  char s2[] = "New Year ";
  char s3[40] = "";
  printf("s1 = %s\ns2 = %s\n", s1, s2);
  printf("strcat( s1, s2 ) = %s\n", strcat(s1, s2));
  printf("strncat( s3, s1, 6 ) = %s\n", strncat(s3, s1, 6));
  printf("strcat( s3, s1 ) = %s\n", strcat(s3, s1));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xea5(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xe9f(%rip),%rax
mov    %rax,-0x2a(%rbp)
mov    0xe9c(%rip),%ax
mov    %ax,-0x22(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
lea    -0x20(%rbp),%rsi
lea    -0x2a(%rbp),%rdx
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    -0x2a(%rbp),%rsi
call   1060 <strcat@plt>
mov    %rax,%rsi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x60(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x6,%edx
call   1050 <strncat@plt>
mov    %rax,%rsi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x60(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <strcat@plt>
mov    %rax,%rsi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x58,%rsp
movaps 0xec2(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x20(%rsp)
movabs $0x726165592077654e,%rax
65 61 72
mov    %rax,(%rsp)
movw   $0x20,0x8(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movq   $0x0,0x50(%rsp)
lea    0xea1(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rsp,%r14
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcat@plt>
lea    0xe8b(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x30(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1040 <strncat@plt>
lea    0xe7c(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strcat@plt>
lea    0xe7b(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.s1 = [20 x i8] c"Happy \00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.s2 = [10 x i8] c"New Year \00"
@.str = [17 x i8] c"s1 = %s\0As2 = %s\0A\00"
@.str.1 = [23 x i8] c"strcat( s1, s2 ) = %s\0A\00"
@.str.2 = [27 x i8] c"strncat( s3, s1, 6 ) = %s\0A\00"
@.str.3 = [23 x i8] c"strcat( s3, s1 ) = %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca [10 x i8]
%4 = alloca [40 x i8]
store i32 0, i32* %1
%5 = bitcast [20 x i8]* %2 to i8*
%6 = bitcast [10 x i8]* %3 to i8*
%7 = bitcast [40 x i8]* %4 to i8*
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%10 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %9)
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%13 = call i8* @strcat(i8* %11, i8* %12)
%14 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%17 = call i8* @strncat(i8* %15, i8* %16, i32 6)
%18 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%21 = call i8* @strcat(i8* %19, i8* %20)
%22 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %21)
ret i32 0
}

LLVM IR (-O2):
@__const.main.s1 = [20 x i8] c"Happy \00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.s2 = [10 x i8] c"New Year \00"
@.str = [17 x i8] c"s1 = %s\0As2 = %s\0A\00"
@.str.1 = [23 x i8] c"strcat( s1, s2 ) = %s\0A\00"
@.str.2 = [27 x i8] c"strncat( s3, s1, 6 ) = %s\0A\00"
@.str.3 = [23 x i8] c"strcat( s3, s1 ) = %s\0A\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [10 x i8]
%3 = alloca [40 x i8]
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%7 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %4, i8* %5)
%8 = call i8* @strcat(i8* %4, i8* %5)
%9 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%10 = call i8* @strncat(i8* %6, i8* %4, i32 6)
%11 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = call i8* @strcat(i8* %6, i8* %4)
%13 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %6)
ret i32 0
}