#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(char *);
int /*<<< orphan*/ printf(char *, int);
void test1() {
  int l = mystrlen("Hello world");
  printf("mystrlen(\"Hello world\")=%d\n", l);
  l = mystrlen("CS240 Programming in C");
  printf("mystrlen(\"CS240 Programming in C\")=%d\n", l);
  l = mystrlen("");
  printf("mystrlen(\"\")=%d\n", l);
}


x86 assembly (clang, -O0):
<test1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1040 <mystrlen@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xecb(%rip),%rdi
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
call   1040 <mystrlen@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xee0(%rip),%rdi
call   1030 <printf@plt>
lea    0xf0b(%rip),%rdi
call   1040 <mystrlen@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xee9(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test1>:
push   %rax
lea    0xed8(%rip),%rdi
call   1040 <mystrlen@plt>
lea    0xed8(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xee6(%rip),%rdi
call   1040 <mystrlen@plt>
lea    0xef1(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xf1a(%rip),%rdi
call   1040 <mystrlen@plt>
lea    0xefe(%rip),%rdi
mov    %eax,%esi
pop    %rax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"Hello world\00"
@.str.1 = [28 x i8] c"mystrlen(\22Hello world\22)=%d\0A\00"
@.str.2 = [23 x i8] c"CS240 Programming in C\00"
@.str.3 = [39 x i8] c"mystrlen(\22CS240 Programming in C\22)=%d\0A\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [17 x i8] c"mystrlen(\22\22)=%d\0A\00"
define void @test1() {
%1 = alloca i32
%2 = call i32 @mystrlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 %2, i32* %1
%3 = load i32, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = call i32 @mystrlen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
store i32 %5, i32* %1
%6 = load i32, i32* %1
%7 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %6)
%8 = call i32 @mystrlen(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0))
store i32 %8, i32* %1
%9 = load i32, i32* %1
%10 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %9)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"Hello world\00"
@.str.1 = [28 x i8] c"mystrlen(\22Hello world\22)=%d\0A\00"
@.str.2 = [23 x i8] c"CS240 Programming in C\00"
@.str.3 = [39 x i8] c"mystrlen(\22CS240 Programming in C\22)=%d\0A\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [17 x i8] c"mystrlen(\22\22)=%d\0A\00"
define void @test1() {
%1 = tail call i32 @mystrlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %1)
%3 = tail call i32 @mystrlen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %3)
%5 = tail call i32 @mystrlen(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0))
%6 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %5)
ret void
}