#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 strlen(char *);
int test_strlen(void) {
  printf("\tstrlen");
  if (strlen("abcdefg") != 7)
    return 1;
  if (strlen("") != 0)
    return 1;
  if (strlen("abc") != 3)
    return 1;
  printf("\tpassed.\n");
  return 0;
}


x86 assembly (clang, -O0):
<test_strlen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
call   1030 <strlen@plt>
cmp    $0x7,%eax
je     1155 <test_strlen+0x35>
movl   $0x1,-0x4(%rbp)
jmp    11aa <test_strlen+0x8a>
lea    0xec1(%rip),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
je     1176 <test_strlen+0x56>
movl   $0x1,-0x4(%rbp)
jmp    11aa <test_strlen+0x8a>
lea    0xe93(%rip),%rdi
call   1030 <strlen@plt>
cmp    $0x3,%eax
je     1197 <test_strlen+0x77>
movl   $0x1,-0x4(%rbp)
jmp    11aa <test_strlen+0x8a>
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_strlen>:
push   %rbx
lea    0xec8(%rip),%rdi
call   1050 <printf@plt>
lea    0xec4(%rip),%rdi
call   1040 <strlen@plt>
mov    $0x1,%ebx
cmp    $0x7,%eax
jne    1182 <test_strlen+0x52>
lea    0xec2(%rip),%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jne    1182 <test_strlen+0x52>
lea    0xea6(%rip),%rdi
call   1040 <strlen@plt>
cmp    $0x3,%eax
jne    1182 <test_strlen+0x52>
lea    0xe99(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"\09strlen\00"
@.str.1 = [8 x i8] c"abcdefg\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [4 x i8] c"abc\00"
@.str.4 = [10 x i8] c"\09passed.\0A\00"
define i32 @test_strlen() {
%1 = alloca i32
%2 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp ne i32 %3, 7
br i1 %4, label %5, label %6
5: ; preds = %0
store i32 1, i32* %1
br label %16
6: ; preds = %0
%7 = call i32 @strlen(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %6
store i32 1, i32* %1
br label %16
10: ; preds = %6
%11 = call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%12 = icmp ne i32 %11, 3
br i1 %12, label %13, label %14
13: ; preds = %10
store i32 1, i32* %1
br label %16
14: ; preds = %10
%15 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %16
16: ; preds = %14, %13, %9, %5
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
@.str = [8 x i8] c"\09strlen\00"
@.str.1 = [8 x i8] c"abcdefg\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [4 x i8] c"abc\00"
@str = [9 x i8] c"\09passed.\00"
define i32 @test_strlen() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32 %2, 7
br i1 %3, label %4, label %12
4: ; preds = %0
%5 = tail call i32 @strlen(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %4
%8 = tail call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%9 = icmp eq i32 %8, 3
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %7, %4, %0, %10
%13 = phi i32 [ 0, %10 ], [ 1, %0 ], [ 1, %4 ], [ 1, %7 ]
ret i32 %13
}