#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*/ bzero(char *, int);
int /*<<< orphan*/ ft_bzero(char *, int);
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ print_mem(char *, int);
int /*<<< orphan*/ print_zero(char *, int);
int /*<<< orphan*/ printf(char *);
void test_bzero() {
  printf("-----------------------ft_bzero\n");
  char str1[20] = "1234567890";
  char str2[20] = "1234567890";
  bzero(str1, 5);
  ft_bzero(str2, 5);
  if (memcmp(str1, str2, 9) != 0) {
    printf(">>>>>>>FAIL<<<<<<<\n");
    printf("   bzero = \"");
    print_zero(str1, 20);
    printf("\"\n");
    print_mem(str1, 9);
    printf("ft_bzero = \"");
    print_zero(str2, 20);
    printf("\"\n");
    print_mem(str2, 9);
  } else
    printf(">>>>>SUCCESS<<<<<<\n");
}


x86 assembly (clang, -O0):
<test_bzero>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xe91(%rip),%rdi
call   1050 <printf@plt>
mov    0xef5(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xef2(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xef0(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xef6(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xef3(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xef1(%rip),%eax
mov    %eax,-0x30(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x5,%esi
call   1080 <bzero@plt>
lea    -0x40(%rbp),%rdi
mov    $0x5,%esi
call   1040 <ft_bzero@plt>
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x9,%edx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
je     1263 <test_bzero+0x103>
lea    0xe30(%rip),%rdi
call   1050 <printf@plt>
lea    0xe38(%rip),%rdi
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0x14,%esi
call   1030 <print_zero@plt>
lea    0xe2b(%rip),%rdi
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0x9,%esi
call   1070 <print_mem@plt>
lea    0xe14(%rip),%rdi
call   1050 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    $0x14,%esi
call   1030 <print_zero@plt>
lea    0xdf7(%rip),%rdi
call   1050 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    $0x9,%esi
call   1070 <print_mem@plt>
jmp    126f <test_bzero+0x10f>
lea    0xde8(%rip),%rdi
call   1050 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_bzero>:
push   %r14
push   %rbx
sub    $0x38,%rsp
lea    0xeb0(%rip),%rdi
call   1040 <puts@plt>
movaps 0xe76(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movl   $0x0,0x30(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
lea    0x20(%rsp),%r14
mov    %r14,%rdi
mov    $0x5,%esi
call   1090 <bzero@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1050 <ft_bzero@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x9,%edx
call   1070 <memcmp@plt>
test   %rax,%rax
je     1253 <test_bzero+0xe3>
lea    0xe80(%rip),%rdi
call   1040 <puts@plt>
lea    0xe27(%rip),%rdi
call   1060 <printf@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x14,%esi
call   1030 <print_zero@plt>
lea    0xe14(%rip),%r14
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
call   1080 <print_mem@plt>
lea    0xdfa(%rip),%rdi
call   1060 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x14,%esi
call   1030 <print_zero@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
call   1080 <print_mem@plt>
jmp    125f <test_bzero+0xef>
lea    0xdf4(%rip),%rdi
call   1040 <puts@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [33 x i8] c"-----------------------ft_bzero\0A\00"
@__const.test_bzero.str1 = [20 x i8] c"1234567890\00\00\00\00\00\00\00\00\00\00"
@__const.test_bzero.str2 = [20 x i8] c"1234567890\00\00\00\00\00\00\00\00\00\00"
@.str.1 = [20 x i8] c">>>>>>>FAIL<<<<<<<\0A\00"
@.str.2 = [13 x i8] c" bzero = \22\00"
@.str.3 = [3 x i8] c"\22\0A\00"
@.str.4 = [13 x i8] c"ft_bzero = \22\00"
@.str.5 = [20 x i8] c">>>>>SUCCESS<<<<<<\0A\00"
define void @test_bzero() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%4 = bitcast [20 x i8]* %1 to i8*
%5 = bitcast [20 x i8]* %2 to i8*
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%7 = call i32 @bzero(i8* %6, i32 5)
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%9 = call i32 @ft_bzero(i8* %8, i32 5)
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%12 = call i64 @memcmp(i8* %10, i8* %11, i32 9)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %28
14: ; preds = %0
%15 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%18 = call i32 @print_zero(i8* %17, i32 20)
%19 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%21 = call i32 @print_mem(i8* %20, i32 9)
%22 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%24 = call i32 @print_zero(i8* %23, i32 20)
%25 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%27 = call i32 @print_mem(i8* %26, i32 9)
br label %30
28: ; preds = %0
%29 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
br label %30
30: ; preds = %28, %14
ret void
}

LLVM IR (-O2):
@__const.test_bzero.str2 = [20 x i8] c"1234567890\00\00\00\00\00\00\00\00\00\00"
@.str.2 = [13 x i8] c" bzero = \22\00"
@.str.4 = [13 x i8] c"ft_bzero = \22\00"
@str = [32 x i8] c"-----------------------ft_bzero\00"
@str.6 = [19 x i8] c">>>>>SUCCESS<<<<<<\00"
@str.7 = [19 x i8] c">>>>>>>FAIL<<<<<<<\00"
@str.9 = [2 x i8] c"\22\00"
define void @test_bzero() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%6 = call i32 @bzero(i8* %4, i32 5)
%7 = call i32 @ft_bzero(i8* %5, i32 5)
%8 = call i64 @memcmp(i8* %4, i8* %5, i32 9)
%9 = icmp eq i64 %8, 0
br i1 %9, label %20, label %10
10: ; preds = %0
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.7, i64 0, i64 0))
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @print_zero(i8* %4, i32 20)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.9, i64 0, i64 0))
%15 = call i32 @print_mem(i8* %4, i32 9)
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 @print_zero(i8* %5, i32 20)
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.9, i64 0, i64 0))
%19 = call i32 @print_mem(i8* %5, i32 9)
br label %22
20: ; preds = %0
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.6, i64 0, i64 0))
br label %22
22: ; preds = %20, %10
ret void
}