#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 mystrlen(unsigned char *);
int /*<<< orphan*/ printf(char *, ...);
void test0(void) {
  int length;
  unsigned char a[] = "a";
  unsigned char b[] = "abcd";
  unsigned char c[] = "";
  unsigned char d[] = "Four score and seven years ago our fathers brought "
                      "forth on this continent a new nation, conceived in "
                      "liberty and dedicated to the proposition that all men "
                      "are created equal.";
  printf("\nTest0 ======================================\n");
  length = mystrlen(a);
  printf("length of a is %i\n", length);
  length = mystrlen(b);
  printf("length of b is %i\n", length);
  length = mystrlen(c);
  printf("length of c is %i\n", length);
  length = mystrlen(d);
  printf("length of d is %i\n", length);
}


x86 assembly (clang, -O0):
<test0>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    0xeae(%rip),%ax
mov    %ax,-0x6(%rbp)
mov    0xea6(%rip),%eax
mov    %eax,-0xb(%rbp)
mov    0xea1(%rip),%al
mov    %al,-0x7(%rbp)
lea    -0xc(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <memset@plt>
lea    -0xc0(%rbp),%rdi
lea    0xf0a(%rip),%rsi
mov    $0xaf,%edx
call   1050 <memcpy@plt>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x6(%rbp),%rdi
call   1060 <mystrlen@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xb(%rbp),%rdi
call   1060 <mystrlen@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xc(%rbp),%rdi
call   1060 <mystrlen@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xc0(%rbp),%rdi
call   1060 <mystrlen@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test0>:
push   %rbx
sub    $0xc0,%rsp
movw   $0x61,0x6(%rsp)
movb   $0x0,0xc(%rsp)
movl   $0x64636261,0x8(%rsp)
64
movb   $0x0,0x5(%rsp)
lea    0xf18(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    $0xaf,%edx
mov    %rbx,%rdi
call   1050 <memcpy@plt>
lea    0xed0(%rip),%rdi
call   1030 <puts@plt>
lea    0x6(%rsp),%rdi
call   1060 <mystrlen@plt>
lea    0xe6e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rdi
call   1060 <mystrlen@plt>
lea    0xe67(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x5(%rsp),%rdi
call   1060 <mystrlen@plt>
lea    0xe60(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <mystrlen@plt>
lea    0xe5b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xc0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.test0.a = [2 x i8] c"a\00"
@__const.test0.b = [5 x i8] c"abcd\00"
@__const.test0.d = [175 x i8] c"Four score and seven years ago our fathers brought forth on this continent a new nation, conceived in liberty and dedicated to the proposition that all men are created equal.\00"
@.str = [47 x i8] c"\0ATest0 ======================================\0A\00"
@.str.1 = [19 x i8] c"length of a is %i\0A\00"
@.str.2 = [19 x i8] c"length of b is %i\0A\00"
@.str.3 = [19 x i8] c"length of c is %i\0A\00"
@.str.4 = [19 x i8] c"length of d is %i\0A\00"
define void @test0() {
%1 = alloca i32
%2 = alloca [2 x i8]
%3 = alloca [5 x i8]
%4 = alloca [1 x i8]
%5 = alloca [175 x i8]
%6 = bitcast [2 x i8]* %2 to i8*
%7 = bitcast [5 x i8]* %3 to i8*
%8 = bitcast [1 x i8]* %4 to i8*
%9 = bitcast [175 x i8]* %5 to i8*
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%12 = call i32 @mystrlen(i8* %11)
store i32 %12, i32* %1
%13 = load i32, i32* %1
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%16 = call i32 @mystrlen(i8* %15)
store i32 %16, i32* %1
%17 = load i32, i32* %1
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds [1 x i8], [1 x i8]* %4, i64 0, i64 0
%20 = call i32 @mystrlen(i8* %19)
store i32 %20, i32* %1
%21 = load i32, i32* %1
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [175 x i8], [175 x i8]* %5, i64 0, i64 0
%24 = call i32 @mystrlen(i8* %23)
store i32 %24, i32* %1
%25 = load i32, i32* %1
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %25)
ret void
}

LLVM IR (-O2):
@__const.test0.b = [5 x i8] c"abcd\00"
@__const.test0.d = [175 x i8] c"Four score and seven years ago our fathers brought forth on this continent a new nation, conceived in liberty and dedicated to the proposition that all men are created equal.\00"
@.str.1 = [19 x i8] c"length of a is %i\0A\00"
@.str.2 = [19 x i8] c"length of b is %i\0A\00"
@.str.3 = [19 x i8] c"length of c is %i\0A\00"
@.str.4 = [19 x i8] c"length of d is %i\0A\00"
@str = [46 x i8] c"\0ATest0 ======================================\00"
define void @test0() {
%1 = alloca i16
%2 = alloca [5 x i8]
%3 = alloca [1 x i8]
%4 = alloca [175 x i8]
%5 = bitcast i16* %1 to i8*
store i16 97, i16* %1
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [1 x i8], [1 x i8]* %3, i64 0, i64 0
store i8 0, i8* %7
%8 = getelementptr inbounds [175 x i8], [175 x i8]* %4, i64 0, i64 0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%10 = call i32 @mystrlen(i8* %5)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = call i32 @mystrlen(i8* %6)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = call i32 @mystrlen(i8* %7)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = call i32 @mystrlen(i8* %8)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %16)
ret void
}