#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 *);
int /*<<< orphan*/ strncat(char *, char *, int);
int main() {
  char s1[] = "Hello";
  char s2[] = ", world! haHa";
  printf("Before strncat call\ns1: %s\ns2: %s\n", s1, s2);
  strncat(s1, s2, 7);
  printf("After  strncat call\ns1: %s\ns2: %s\n", s1, s2);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xed2(%rip),%eax
mov    %eax,-0x6(%rbp)
mov    0xecc(%rip),%ax
mov    %ax,-0x2(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x14(%rbp)
mov    0xec1(%rip),%eax
mov    %eax,-0xc(%rbp)
mov    0xebb(%rip),%ax
mov    %ax,-0x8(%rbp)
lea    -0x6(%rbp),%rsi
lea    -0x14(%rbp),%rdx
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
lea    -0x6(%rbp),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x7,%edx
call   1040 <strncat@plt>
lea    -0x6(%rbp),%rsi
lea    -0x14(%rbp),%rdx
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movw   $0x6f,0x4(%rsp)
movl   $0x6c6c6548,(%rsp)
movabs $0x61486168202164,%rax
mov    %rax,0xe(%rsp)
movabs $0x21646c726f77202c,%rax
6c 64 21
mov    %rax,0x8(%rsp)
lea    0xeba(%rip),%rdi
mov    %rsp,%rbx
lea    0x8(%rsp),%r14
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x7,%edx
call   1040 <strncat@plt>
lea    0xeb3(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.s1 = [6 x i8] c"Hello\00"
@__const.main.s2 = [14 x i8] c", world! haHa\00"
@.str = [35 x i8] c"Before strncat call\0As1: %s\0As2: %s\0A\00"
@.str.1 = [35 x i8] c"After strncat call\0As1: %s\0As2: %s\0A\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = alloca [14 x i8]
%3 = bitcast [6 x i8]* %1 to i8*
%4 = bitcast [14 x i8]* %2 to i8*
%5 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 0
%7 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %5, i8* %6)
%8 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%9 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 0
%10 = call i32 @strncat(i8* %8, i8* %9, i32 7)
%11 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%12 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 0
%13 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %11, i8* %12)
ret i32 0
}

LLVM IR (-O2):
@__const.main.s1 = [6 x i8] c"Hello\00"
@__const.main.s2 = [14 x i8] c", world! haHa\00"
@.str = [35 x i8] c"Before strncat call\0As1: %s\0As2: %s\0A\00"
@.str.1 = [35 x i8] c"After strncat call\0As1: %s\0As2: %s\0A\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = alloca [14 x i8]
%3 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 0
%5 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %4)
%6 = call i32 @strncat(i8* %3, i8* %4, i32 7)
%7 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %3, i8* %4)
ret i32 0
}