#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 k_strlen(char *);
int test_strlen_1() {
  char str1[] = "";
  char str2[] = "abcdefghij";
  char str3[] = "0XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  if (k_strlen(str1) != 0)
    return (1);
  if (k_strlen(str2) != 10)
    return (2);
  if (k_strlen(str3) != 50)
    return (3);
  return (0);
}


x86 assembly (clang, -O0):
<test_strlen_1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    -0x5(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1030 <memset@plt>
mov    0xeb1(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xeae(%rip),%ax
mov    %ax,-0x8(%rbp)
mov    0xea6(%rip),%al
mov    %al,-0x6(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe9e(%rip),%rsi
mov    $0x33,%edx
call   1050 <memcpy@plt>
lea    -0x5(%rbp),%rdi
call   1040 <k_strlen@plt>
cmp    $0x0,%eax
je     119a <test_strlen_1+0x6a>
movl   $0x1,-0x4(%rbp)
jmp    11dd <test_strlen_1+0xad>
lea    -0x10(%rbp),%rdi
call   1040 <k_strlen@plt>
cmp    $0xa,%eax
je     11b8 <test_strlen_1+0x88>
movl   $0x2,-0x4(%rbp)
jmp    11dd <test_strlen_1+0xad>
lea    -0x50(%rbp),%rdi
call   1040 <k_strlen@plt>
cmp    $0x32,%eax
je     11d6 <test_strlen_1+0xa6>
movl   $0x3,-0x4(%rbp)
jmp    11dd <test_strlen_1+0xad>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_strlen_1>:
sub    $0x58,%rsp
movb   $0x0,0xf(%rsp)
movabs $0x6867666564636261,%rax
66 67 68
mov    %rax,0x10(%rsp)
movl   $0x6a6968,0x17(%rsp)
movaps 0xef9(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xedd(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xec1(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movl   $0x585858,0x4f(%rsp)
lea    0xf(%rsp),%rdi
call   1030 <k_strlen@plt>
mov    %eax,%ecx
mov    $0x1,%eax
test   %ecx,%ecx
je     1176 <test_strlen_1+0x66>
add    $0x58,%rsp
ret
lea    0x10(%rsp),%rdi
call   1030 <k_strlen@plt>
mov    %eax,%ecx
mov    $0x2,%eax
cmp    $0xa,%ecx
jne    1171 <test_strlen_1+0x61>
lea    0x20(%rsp),%rdi
call   1030 <k_strlen@plt>
xor    %ecx,%ecx
cmp    $0x32,%eax
setne  %cl
lea    (%rcx,%rcx,2),%eax
add    $0x58,%rsp
ret

LLVM IR (-O0):
@__const.test_strlen_1.str2 = [11 x i8] c"abcdefghij\00"
@__const.test_strlen_1.str3 = [51 x i8] c"0XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\00"
define i32 @test_strlen_1() {
%1 = alloca i32
%2 = alloca [1 x i8]
%3 = alloca [11 x i8]
%4 = alloca [51 x i8]
%5 = bitcast [1 x i8]* %2 to i8*
%6 = bitcast [11 x i8]* %3 to i8*
%7 = bitcast [51 x i8]* %4 to i8*
%8 = getelementptr inbounds [1 x i8], [1 x i8]* %2, i64 0, i64 0
%9 = call i32 @k_strlen(i8* %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %0
store i32 1, i32* %1
br label %23
12: ; preds = %0
%13 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%14 = call i32 @k_strlen(i8* %13)
%15 = icmp ne i32 %14, 10
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 2, i32* %1
br label %23
17: ; preds = %12
%18 = getelementptr inbounds [51 x i8], [51 x i8]* %4, i64 0, i64 0
%19 = call i32 @k_strlen(i8* %18)
%20 = icmp ne i32 %19, 50
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 3, i32* %1
br label %23
22: ; preds = %17
store i32 0, i32* %1
br label %23
23: ; preds = %22, %21, %16, %11
%24 = load i32, i32* %1
ret i32 %24
}

LLVM IR (-O2):
@__const.test_strlen_1.str2 = [11 x i8] c"abcdefghij\00"
@__const.test_strlen_1.str3 = [51 x i8] c"0XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\00"
define i32 @test_strlen_1() {
%1 = alloca [1 x i8]
%2 = alloca [11 x i8]
%3 = alloca [51 x i8]
%4 = getelementptr inbounds [1 x i8], [1 x i8]* %1, i64 0, i64 0
store i8 0, i8* %4
%5 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [51 x i8], [51 x i8]* %3, i64 0, i64 0
%7 = call i32 @k_strlen(i8* %4)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %0
%10 = call i32 @k_strlen(i8* %5)
%11 = icmp eq i32 %10, 10
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = call i32 @k_strlen(i8* %6)
%14 = icmp eq i32 %13, 50
%15 = select i1 %14, i32 0, i32 3
br label %16
16: ; preds = %12, %9, %0
%17 = phi i32 [ 1, %0 ], [ 2, %9 ], [ %15, %12 ]
ret i32 %17
}