#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 get_length(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void test8() {
  char wort[10] = "";
  strcpy(wort, "12345\n");
  printf("%i\n", get_length(wort));
  char wort2[6] = "";
  strncpy(wort2, wort, 5);
  printf("%i\n", get_length(wort2));
}


x86 assembly (clang, -O0):
<test8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0xa(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <memset@plt>
lea    -0xa(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0xa(%rbp),%rdi
call   1070 <get_length@plt>
mov    %eax,%esi
lea    0xe7d(%rip),%rdi
call   1050 <printf@plt>
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x6,%edx
call   1060 <memset@plt>
lea    -0x10(%rbp),%rdi
lea    -0xa(%rbp),%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
lea    -0x10(%rbp),%rdi
call   1070 <get_length@plt>
mov    %eax,%esi
lea    0xe44(%rip),%rdi
call   1050 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test8>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movw   $0x0,0x18(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xea0(%rip),%rsi
lea    0x10(%rsp),%r15
mov    %r15,%rdi
call   1040 <strcpy@plt>
mov    %r15,%rdi
call   1060 <get_length@plt>
lea    0xe8b(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
movw   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
call   1060 <get_length@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"12345\0A\00"
@.str.1 = [4 x i8] c"%i\0A\00"
define void @test8() {
%1 = alloca [10 x i8]
%2 = alloca [6 x i8]
%3 = bitcast [10 x i8]* %1 to i8*
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%5 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%7 = call i32 @get_length(i8* %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = bitcast [6 x i8]* %2 to i8*
%10 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%12 = call i32 @strncpy(i8* %10, i8* %11, i32 5)
%13 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%14 = call i32 @get_length(i8* %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"12345\0A\00"
@.str.1 = [4 x i8] c"%i\0A\00"
define void @test8() {
%1 = alloca [10 x i8]
%2 = alloca [6 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%4 = call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @get_length(i8* %3)
%6 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%8 = call i32 @strncpy(i8* %7, i8* %3, i32 5)
%9 = call i32 @get_length(i8* %7)
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %9)
ret void
}