main() {
  void strncpy(char *, char *, int n);
  void strncat(char *, char *, int n);
  int strncmp(char *, char *, int n);
  char s[] = "TEST";
  char *t = "DESU";
  char u[] = "TEST";
  char *v = "DESU";
  char w[] = "DEST";
  char *x = "DESU";
  strncpy(s, t, 3);
  printf("%s\n", s);
  strncat(u, v, 3);
  printf("%s\n", u);
  printf("%d\n", strncmp(w, x, 2));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xeb2(%rip),%eax
mov    %eax,-0x5(%rbp)
mov    0xead(%rip),%al
mov    %al,-0x1(%rbp)
lea    0xea4(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xe95(%rip),%eax
mov    %eax,-0x15(%rbp)
mov    0xe90(%rip),%al
mov    %al,-0x11(%rbp)
lea    0xe87(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe82(%rip),%eax
mov    %eax,-0x25(%rbp)
mov    0xe7d(%rip),%al
mov    %al,-0x21(%rbp)
lea    0xe6a(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    -0x5(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
lea    -0x5(%rbp),%rsi
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x15(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x3,%edx
call   1060 <strncat@plt>
lea    -0x15(%rbp),%rsi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x25(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
mov    %eax,%esi
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movb   $0x0,0x14(%rsp)
movl   $0x54534554,0x10(%rsp)
54
movb   $0x0,0xc(%rsp)
movl   $0x54534554,0x8(%rsp)
54
movb   $0x0,0x4(%rsp)
movl   $0x54534544,(%rsp)
lea    0xe7c(%rip),%r14
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
call   1050 <puts@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   1070 <strncat@plt>
mov    %rbx,%rdi
call   1050 <puts@plt>
mov    %rsp,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
lea    0xe3a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.s = [5 x i8] c"TEST\00"
@.str = [5 x i8] c"DESU\00"
@__const.main.u = [5 x i8] c"TEST\00"
@__const.main.w = [5 x i8] c"DEST\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [5 x i8]
%2 = alloca i8*
%3 = alloca [5 x i8]
%4 = alloca i8*
%5 = alloca [5 x i8]
%6 = alloca i8*
%7 = bitcast [5 x i8]* %1 to i8*
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %2
%8 = bitcast [5 x i8]* %3 to i8*
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %4
%9 = bitcast [5 x i8]* %5 to i8*
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %6
%10 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%11 = load i8*, i8** %2
%12 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%15 = load i8*, i8** %4
%16 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%19 = load i8*, i8** %6
%20 = call i32 @strncmp(i8* %18, i8* %19, i32 2)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"DESU\00"
@__const.main.u = [5 x i8] c"TEST\00"
@__const.main.w = [5 x i8] c"DEST\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [5 x i8]
%2 = alloca [5 x i8]
%3 = alloca [5 x i8]
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%7 = call i32 @puts(i8* %4)
%8 = call i32 @puts(i8* %5)
%9 = call i32 @strncmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 2)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %9)
ret i32 0
}