#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 */
typedef int /*<<< orphan*/ src;
typedef int /*<<< orphan*/ dst;

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
char *strlen(char *);
size_t strxfrm(char *, char *, int);
int main(int argc, char *argv[]) {
  char dst[30];
  char dst2[130];
  memset(dst, 0, sizeof(dst));
  char src[] = "Put a transformation of SRC into no more than N bytes of DEST.";
  size_t len = strxfrm(dst, src, 15);
  printf("%lu\n", len);
  printf("%lu\n", strlen(src));
  printf("%lu\n", sizeof(src));
  printf("%s\n", dst);
  printf("%lu\n", strlen(dst));
  printf("%lu\n", sizeof(dst));
  len = strxfrm(dst2, src, 100);
  printf("%lu\n", len);
  printf("%lu\n", strlen(dst2));
  printf("%s\n", dst2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1050 <memset@plt>
lea    -0x100(%rbp),%rdi
lea    0xe79(%rip),%rsi
mov    $0x3f,%edx
call   1070 <memcpy@plt>
lea    -0x30(%rbp),%rdi
lea    -0x100(%rbp),%rsi
mov    $0xf,%edx
call   1060 <strxfrm@plt>
mov    %rax,-0x108(%rbp)
mov    -0x108(%rbp),%rsi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x100(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rsi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe59(%rip),%rdi
mov    $0x3f,%esi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rsi
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe1a(%rip),%rdi
mov    $0x1e,%esi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xc0(%rbp),%rdi
lea    -0x100(%rbp),%rsi
mov    $0x64,%edx
call   1060 <strxfrm@plt>
mov    %rax,-0x108(%rbp)
mov    -0x108(%rbp),%rsi
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xc0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rsi
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xc0(%rbp),%rsi
lea    0xdb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xf0,%rsp
lea    0x40(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1060 <memset@plt>
movups 0xeb8(%rip),%xmm0
movups %xmm0,0x2f(%rsp)
movaps 0xe9d(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe81(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe65(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%r14
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0xf,%edx
call   1070 <strxfrm@plt>
lea    0xe86(%rip),%rbx
mov    %rbx,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x3f,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1e,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x60(%rsp),%r15
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x64,%edx
call   1070 <strxfrm@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.src = [63 x i8] c"Put a transformation of SRC into no more than N bytes of DEST.\00"
@.str = [5 x i8] c"%lu\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [30 x i8]
%7 = alloca [130 x i8]
%8 = alloca [63 x i8]
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = getelementptr inbounds [30 x i8], [30 x i8]* %6, i64 0, i64 0
%11 = call i32 @memset(i8* %10, i32 0, i32 30)
%12 = bitcast [63 x i8]* %8 to i8*
%13 = getelementptr inbounds [30 x i8], [30 x i8]* %6, i64 0, i64 0
%14 = getelementptr inbounds [63 x i8], [63 x i8]* %8, i64 0, i64 0
%15 = call i64 @strxfrm(i8* %13, i8* %14, i32 15)
store i64 %15, i64* %9
%16 = load i64, i64* %9
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %16)
%18 = getelementptr inbounds [63 x i8], [63 x i8]* %8, i64 0, i64 0
%19 = call i8* @strlen(i8* %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 63)
%22 = getelementptr inbounds [30 x i8], [30 x i8]* %6, i64 0, i64 0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = getelementptr inbounds [30 x i8], [30 x i8]* %6, i64 0, i64 0
%25 = call i8* @strlen(i8* %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 30)
%28 = getelementptr inbounds [130 x i8], [130 x i8]* %7, i64 0, i64 0
%29 = getelementptr inbounds [63 x i8], [63 x i8]* %8, i64 0, i64 0
%30 = call i64 @strxfrm(i8* %28, i8* %29, i32 100)
store i64 %30, i64* %9
%31 = load i64, i64* %9
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %31)
%33 = getelementptr inbounds [130 x i8], [130 x i8]* %7, i64 0, i64 0
%34 = call i8* @strlen(i8* %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %34)
%36 = getelementptr inbounds [130 x i8], [130 x i8]* %7, i64 0, i64 0
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %36)
ret i32 0
}

LLVM IR (-O2):
@__const.main.src = [63 x i8] c"Put a transformation of SRC into no more than N bytes of DEST.\00"
@.str = [5 x i8] c"%lu\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [30 x i8]
%4 = alloca [130 x i8]
%5 = alloca [63 x i8]
%6 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [130 x i8], [130 x i8]* %4, i64 0, i64 0
%8 = call i32 @memset(i8* %6, i32 0, i32 30)
%9 = getelementptr inbounds [63 x i8], [63 x i8]* %5, i64 0, i64 0
%10 = call i64 @strxfrm(i8* %6, i8* %9, i32 15)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %10)
%12 = call i8* @strlen(i8* %9)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 63)
%15 = call i32 @puts(i8* %6)
%16 = call i8* @strlen(i8* %6)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 30)
%19 = call i64 @strxfrm(i8* %7, i8* %9, i32 100)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %19)
%21 = call i8* @strlen(i8* %7)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = call i32 @puts(i8* %7)
ret i32 0
}