#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*/ s;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int strlen_1(char const *);
int strlen_2(char const *);
void main() {
  const char *s = "hello\0";
  printf("sizeof %d\n", sizeof(s));
  printf("strlen_1 %d\n", strlen_1(s));
  printf("strlen_2 %d\n", strlen_2(s));
  const char *null = "\0";
  printf("strlen_1 %d\n", strlen_1(null));
  printf("strlen_2 %d\n", strlen_2(null));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    0xebf(%rip),%rdi
mov    $0x8,%esi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1050 <strlen_1@plt>
mov    %eax,%esi
lea    0xeae(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <strlen_2@plt>
mov    %eax,%esi
lea    0xea4(%rip),%rdi
call   1040 <printf@plt>
lea    0xe7e(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen_1@plt>
mov    %eax,%esi
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <strlen_2@plt>
mov    %eax,%esi
lea    0xe6b(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xecd(%rip),%rdi
mov    $0x8,%esi
call   1040 <printf@plt>
lea    0xeb3(%rip),%rbx
mov    %rbx,%rdi
call   1050 <strlen_1@plt>
lea    0xeb8(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <strlen_2@plt>
lea    0xeac(%rip),%r15
mov    %r15,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
lea    0xe81(%rip),%rbx
mov    %rbx,%rdi
call   1050 <strlen_1@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <strlen_2@plt>
mov    %r15,%rdi
mov    %eax,%esi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"hello\00\00"
@.str.1 = [11 x i8] c"sizeof %d\0A\00"
@.str.2 = [13 x i8] c"strlen_1 %d\0A\00"
@.str.3 = [13 x i8] c"strlen_2 %d\0A\00"
@.str.4 = [2 x i8] zeroinitializer
define void @main() {
%1 = alloca i8*
%2 = alloca i8*
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %1
%3 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 8)
%4 = load i8*, i8** %1
%5 = call i32 @strlen_1(i8* %4)
%6 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = load i8*, i8** %1
%8 = call i32 @strlen_2(i8* %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %8)
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %2
%10 = load i8*, i8** %2
%11 = call i32 @strlen_1(i8* %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = load i8*, i8** %2
%14 = call i32 @strlen_2(i8* %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %14)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"hello\00\00"
@.str.1 = [11 x i8] c"sizeof %d\0A\00"
@.str.2 = [13 x i8] c"strlen_1 %d\0A\00"
@.str.3 = [13 x i8] c"strlen_2 %d\0A\00"
@.str.4 = [2 x i8] zeroinitializer
define void @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 8)
%2 = tail call i32 @strlen_1(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %2)
%4 = tail call i32 @strlen_2(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %4)
%6 = tail call i32 @strlen_1(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%7 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = tail call i32 @strlen_2(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%9 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %8)
ret void
}