#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*/ memclr(char *, int);
int /*<<< orphan*/ printf(char *);
int test_memclr(void) {
  char value0[10] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
  printf("\tmemclr");
  memclr(value0, 5);
  if (value0[0] != 0)
    return 1;
  if (value0[4] != 0)
    return 1;
  if (value0[5] != 1)
    return 1;
  printf("\tpassed.\n");
  return 0;
}


x86 assembly (clang, -O0):
<test_memclr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0xe(%rbp)
mov    0xece(%rip),%ax
mov    %ax,-0x6(%rbp)
lea    0xec5(%rip),%rdi
call   1040 <printf@plt>
lea    -0xe(%rbp),%rdi
mov    $0x5,%esi
call   1030 <memclr@plt>
movsbl -0xe(%rbp),%eax
cmp    $0x0,%eax
je     1171 <test_memclr+0x51>
movl   $0x1,-0x4(%rbp)
jmp    11b6 <test_memclr+0x96>
movsbl -0xa(%rbp),%eax
cmp    $0x0,%eax
je     118a <test_memclr+0x6a>
movl   $0x1,-0x4(%rbp)
jmp    11b6 <test_memclr+0x96>
movsbl -0x9(%rbp),%eax
cmp    $0x1,%eax
je     11a3 <test_memclr+0x83>
movl   $0x1,-0x4(%rbp)
jmp    11b6 <test_memclr+0x96>
lea    0xe68(%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_memclr>:
sub    $0x18,%rsp
movabs $0x101010101010101,%rax
01 01 01
mov    %rax,0x8(%rsp)
movw   $0x101,0x10(%rsp)
lea    0xeaf(%rip),%rdi
call   1050 <printf@plt>
lea    0x8(%rsp),%rdi
mov    $0x5,%esi
call   1040 <memclr@plt>
cmpb   $0x0,0x8(%rsp)
mov    $0x1,%eax
jne    118d <test_memclr+0x5d>
cmpb   $0x0,0xc(%rsp)
jne    118d <test_memclr+0x5d>
cmpb   $0x1,0xd(%rsp)
jne    118d <test_memclr+0x5d>
lea    0xe82(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.test_memclr.value0 = [10 x i8] c"\01\01\01\01\01\01\01\01\01\01"
@.str = [8 x i8] c"\09memclr\00"
@.str.1 = [10 x i8] c"\09passed.\0A\00"
define i32 @test_memclr() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = bitcast [10 x i8]* %2 to i8*
%4 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%6 = call i32 @memclr(i8* %5, i32 5)
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %0
store i32 1, i32* %1
br label %26
12: ; preds = %0
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 4
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %12
store i32 1, i32* %1
br label %26
18: ; preds = %12
%19 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 5
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 1
br i1 %22, label %23, label %24
23: ; preds = %18
store i32 1, i32* %1
br label %26
24: ; preds = %18
%25 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %26
26: ; preds = %24, %23, %17, %11
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
@.str = [8 x i8] c"\09memclr\00"
@str = [9 x i8] c"\09passed.\00"
define i32 @test_memclr() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @memclr(i8* %2, i32 5)
%5 = load i8, i8* %2
%6 = icmp eq i8 %5, 0
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 4
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
%10 = select i1 %6, i1 %9, i1 false
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 5
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 1
%14 = select i1 %10, i1 %13, i1 false
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %17
17: ; preds = %0, %15
%18 = phi i32 [ 0, %15 ], [ 1, %0 ]
ret i32 %18
}