#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*/ _strncpy(char *, char *, int);
int /*<<< orphan*/ printf(char *, char *, char *);
int main() {
  char s1[] = "foolo";
  char s2[] = "Hello, world! haHa";
  printf("Before strncpy call\ns1: %s\ns2: %s\n", s1, s2);
  _strncpy(s1, s2, 3);
  printf("After  strncpy 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    0xf0d(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xf0a(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xf07(%rip),%ax
mov    %ax,-0x10(%rbp)
mov    0xeff(%rip),%al
mov    %al,-0xe(%rbp)
lea    -0x6(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
lea    -0x6(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x3,%edx
call   1040 <_strncpy@plt>
lea    -0x6(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    0xe8e(%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    $0x28,%rsp
movw   $0x6f,0xc(%rsp)
movl   $0x6c6f6f66,0x8(%rsp)
6c
movaps 0xf13(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x614861,0x1f(%rsp)
lea    0xeb5(%rip),%rdi
lea    0x8(%rsp),%rbx
lea    0x10(%rsp),%r14
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   1040 <_strncpy@plt>
lea    0xeac(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

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