#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*/ mystrncpy(char *, char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ test(char *);
main() {
  printf("hello world\n");
  char *src = "test";
  char dest[10];
  mystrncpy(src, dest, 0, 4);
  printf("%s", dest);
  char d = '0';
  printf("\n%d\n", d);
  d = '9';
  printf("\n%d\n", d);
  test("int thing[]");
  test("char thing()");
  test("int (*next)()");
  test("char* const *(*next)(char more)");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x12(%rbp),%rsi
xor    %edx,%edx
mov    $0x4,%ecx
call   1040 <mystrncpy@plt>
lea    -0x12(%rbp),%rsi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0x30,-0x13(%rbp)
movsbl -0x13(%rbp),%esi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0x39,-0x13(%rbp)
movsbl -0x13(%rbp),%esi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe70(%rip),%rdi
call   1050 <test@plt>
lea    0xe70(%rip),%rdi
call   1050 <test@plt>
lea    0xe71(%rip),%rdi
call   1050 <test@plt>
lea    0xe73(%rip),%rdi
call   1050 <test@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xf08(%rip),%rdi
call   1030 <puts@plt>
lea    0xea8(%rip),%rdi
lea    0x6(%rsp),%rbx
mov    %rbx,%rsi
xor    %edx,%edx
mov    $0x4,%ecx
call   1050 <mystrncpy@plt>
lea    0xe92(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe84(%rip),%rbx
mov    %rbx,%rdi
mov    $0x30,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x39,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe64(%rip),%rdi
call   1060 <test@plt>
lea    0xe64(%rip),%rdi
call   1060 <test@plt>
lea    0xe65(%rip),%rdi
call   1060 <test@plt>
lea    0xe67(%rip),%rdi
call   1060 <test@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"hello world\0A\00"
@.str.1 = [5 x i8] c"test\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [5 x i8] c"\0A%d\0A\00"
@.str.4 = [12 x i8] c"int thing[]\00"
@.str.5 = [13 x i8] c"char thing()\00"
@.str.6 = [14 x i8] c"int (*next)()\00"
@.str.7 = [32 x i8] c"char* const *(*next)(char more)\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca [10 x i8]
%3 = alloca i8
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %1
%5 = load i8*, i8** %1
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%7 = call i32 @mystrncpy(i8* %5, i8* %6, i32 0, i32 4)
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %8)
store i8 48, i8* %3
%10 = load i8, i8* %3
%11 = sext i8 %10 to i32
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %11)
store i8 57, i8* %3
%13 = load i8, i8* %3
%14 = sext i8 %13 to i32
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = call i32 @test(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 @test(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%18 = call i32 @test(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%19 = call i32 @test(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"test\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [5 x i8] c"\0A%d\0A\00"
@.str.4 = [12 x i8] c"int thing[]\00"
@.str.5 = [13 x i8] c"char thing()\00"
@.str.6 = [14 x i8] c"int (*next)()\00"
@.str.7 = [32 x i8] c"char* const *(*next)(char more)\00"
@str = [12 x i8] c"hello world\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%4 = call i32 @mystrncpy(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %3, i32 0, i32 4)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 48)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 57)
%8 = call i32 @test(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @test(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%10 = call i32 @test(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%11 = call i32 @test(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}