#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*/ printf(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stringLength(char *);
int /*<<< orphan*/ strlen(char *);
int main(int ArgCount, char *ArgVals[]) {
  char *TestString = "Hello, World!\n";
  printf("Original: %lu\tCustom: %lu\n", strlen(TestString),
         stringLength(TestString));
  if (ArgCount >= 2) {
    printf("Original: %lu\tCustom: %lu\n", strlen(ArgVals[1]),
           stringLength(ArgVals[1]));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <stringLength@plt>
mov    -0x1c(%rbp),%esi
mov    %eax,%edx
lea    0xe9d(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x2,-0x8(%rbp)
jl     11af <main+0x7f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <stringLength@plt>
mov    -0x20(%rbp),%esi
mov    %eax,%edx
lea    0xe65(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%r15d
lea    0xebc(%rip),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <stringLength@plt>
lea    0xeb2(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1040 <printf@plt>
cmp    $0x2,%r15d
jl     1190 <main+0x60>
mov    0x8(%r14),%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    0x8(%r14),%rdi
call   1050 <stringLength@plt>
lea    0xe88(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Hello, World!\0A\00"
@.str.1 = [27 x i8] c"Original: %lu\09Custom: %lu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = load i8*, i8** %6
%8 = call i32 @strlen(i8* %7)
%9 = load i8*, i8** %6
%10 = call i32 @stringLength(i8* %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %10)
%12 = load i32, i32* %4
%13 = icmp sge i32 %12, 2
br i1 %13, label %14, label %24
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @strlen(i8* %17)
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @stringLength(i8* %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %22)
br label %24
24: ; preds = %14, %2
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"Hello, World!\0A\00"
@.str.1 = [27 x i8] c"Original: %lu\09Custom: %lu\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @stringLength(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %3, i32 %4)
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %14
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @strlen(i8* %9)
%11 = load i8*, i8** %8
%12 = tail call i32 @stringLength(i8* %11)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %12)
br label %14
14: ; preds = %7, %2
ret i32 0
}