#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 */
scalar_t__ ft_memset(char *, char, int);
scalar_t__ memcmp(char *, char *, int);
scalar_t__ memset(char *, char, int);
int /*<<< orphan*/ printf(char *, ...);
void test_memset() {
  printf("-----------------------ft_memset\n");
  char b1[3840] = "";
  char b2[3840] = "";
  memset(b1, 'B', 3840 - 1);
  memset(b2, 'B', 3840 - 1);
  memset(b1, 'A', 3);
  ft_memset(b2, 'A', 3);
  if (memcmp(b1, b2, 3840) != 0) {
    printf(">>>>>FAIL<<<<<\n");
    printf("   memset = \"%s\"\n", (char *)memset(b1, 'A', 3));
    printf("ft_memset = \"%s\"\n", (char *)ft_memset(b2, 'A', 3));
  } else
    printf(">>>>>SUCCESS<<<<<<\n");
}


x86 assembly (clang, -O0):
<test_memset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1e00,%rsp
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xf00(%rbp),%rdi
xor    %esi,%esi
mov    $0xf00,%edx
call   1040 <memset@plt>
lea    -0x1e00(%rbp),%rdi
xor    %esi,%esi
mov    $0xf00,%edx
call   1040 <memset@plt>
lea    -0xf00(%rbp),%rdi
mov    $0x42,%esi
mov    $0xeff,%edx
call   1040 <memset@plt>
lea    -0x1e00(%rbp),%rdi
mov    $0x42,%esi
mov    $0xeff,%edx
call   1040 <memset@plt>
lea    -0xf00(%rbp),%rdi
mov    $0x41,%esi
mov    $0x3,%edx
call   1040 <memset@plt>
lea    -0x1e00(%rbp),%rdi
mov    $0x41,%esi
mov    $0x3,%edx
call   1050 <ft_memset@plt>
lea    -0xf00(%rbp),%rdi
lea    -0x1e00(%rbp),%rsi
mov    $0xf00,%edx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
je     125a <test_memset+0x11a>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xf00(%rbp),%rdi
mov    $0x41,%esi
mov    $0x3,%edx
call   1040 <memset@plt>
mov    %rax,%rsi
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x1e00(%rbp),%rdi
mov    $0x41,%esi
mov    $0x3,%edx
call   1050 <ft_memset@plt>
mov    %rax,%rsi
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1268 <test_memset+0x128>
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x1e00,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_memset>:
push   %r14
push   %rbx
sub    $0x1e08,%rsp
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
lea    0xf00(%rsp),%r14
mov    $0xf00,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %rsp,%rbx
mov    $0xf00,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %r14,%rdi
mov    $0x42,%esi
mov    $0xeff,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
mov    $0x42,%esi
mov    $0xeff,%edx
call   1050 <memset@plt>
mov    %r14,%rdi
mov    $0x41,%esi
mov    $0x3,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
mov    $0x41,%esi
mov    $0x3,%edx
call   1060 <ft_memset@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0xf00,%edx
call   1070 <memcmp@plt>
test   %rax,%rax
je     1245 <test_memset+0xf5>
lea    0xe65(%rip),%rdi
call   1030 <puts@plt>
lea    0xf00(%rsp),%rdi
mov    $0x41,%esi
mov    $0x3,%edx
call   1050 <memset@plt>
lea    0xdea(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rdi
mov    $0x41,%esi
mov    $0x3,%edx
call   1060 <ft_memset@plt>
lea    0xdd9(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1251 <test_memset+0x101>
lea    0xdf9(%rip),%rdi
call   1030 <puts@plt>
add    $0x1e08,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [34 x i8] c"-----------------------ft_memset\0A\00"
@.str.1 = [16 x i8] c">>>>>FAIL<<<<<\0A\00"
@.str.2 = [18 x i8] c" memset = \22%s\22\0A\00"
@.str.3 = [18 x i8] c"ft_memset = \22%s\22\0A\00"
@.str.4 = [20 x i8] c">>>>>SUCCESS<<<<<<\0A\00"
define void @test_memset() {
%1 = alloca [3840 x i8]
%2 = alloca [3840 x i8]
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%4 = bitcast [3840 x i8]* %1 to i8*
%5 = bitcast [3840 x i8]* %2 to i8*
%6 = getelementptr inbounds [3840 x i8], [3840 x i8]* %1, i64 0, i64 0
%7 = call i64 @memset(i8* %6, i8 signext 66, i32 3839)
%8 = getelementptr inbounds [3840 x i8], [3840 x i8]* %2, i64 0, i64 0
%9 = call i64 @memset(i8* %8, i8 signext 66, i32 3839)
%10 = getelementptr inbounds [3840 x i8], [3840 x i8]* %1, i64 0, i64 0
%11 = call i64 @memset(i8* %10, i8 signext 65, i32 3)
%12 = getelementptr inbounds [3840 x i8], [3840 x i8]* %2, i64 0, i64 0
%13 = call i64 @ft_memset(i8* %12, i8 signext 65, i32 3)
%14 = getelementptr inbounds [3840 x i8], [3840 x i8]* %1, i64 0, i64 0
%15 = getelementptr inbounds [3840 x i8], [3840 x i8]* %2, i64 0, i64 0
%16 = call i64 @memcmp(i8* %14, i8* %15, i32 3840)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%20 = getelementptr inbounds [3840 x i8], [3840 x i8]* %1, i64 0, i64 0
%21 = call i64 @memset(i8* %20, i8 signext 65, i32 3)
%22 = inttoptr i64 %21 to i8*
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = getelementptr inbounds [3840 x i8], [3840 x i8]* %2, i64 0, i64 0
%25 = call i64 @ft_memset(i8* %24, i8 signext 65, i32 3)
%26 = inttoptr i64 %25 to i8*
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %26)
br label %30
28: ; preds = %0
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %30
30: ; preds = %28, %18
ret void
}

LLVM IR (-O2):
@.str.2 = [18 x i8] c" memset = \22%s\22\0A\00"
@.str.3 = [18 x i8] c"ft_memset = \22%s\22\0A\00"
@str = [33 x i8] c"-----------------------ft_memset\00"
@str.5 = [19 x i8] c">>>>>SUCCESS<<<<<<\00"
@str.6 = [15 x i8] c">>>>>FAIL<<<<<\00"
define void @test_memset() {
%1 = alloca [3840 x i8]
%2 = alloca [3840 x i8]
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%4 = getelementptr inbounds [3840 x i8], [3840 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [3840 x i8], [3840 x i8]* %2, i64 0, i64 0
%6 = call i64 @memset(i8* %4, i8 signext 66, i32 3839)
%7 = call i64 @memset(i8* %5, i8 signext 66, i32 3839)
%8 = call i64 @memset(i8* %4, i8 signext 65, i32 3)
%9 = call i64 @ft_memset(i8* %5, i8 signext 65, i32 3)
%10 = call i64 @memcmp(i8* %4, i8* %5, i32 3840)
%11 = icmp eq i64 %10, 0
br i1 %11, label %20, label %12
12: ; preds = %0
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.6, i64 0, i64 0))
%14 = call i64 @memset(i8* %4, i8 signext 65, i32 3)
%15 = inttoptr i64 %14 to i8*
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = call i64 @ft_memset(i8* %5, i8 signext 65, i32 3)
%18 = inttoptr i64 %17 to i8*
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %18)
br label %22
20: ; preds = %0
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.5, i64 0, i64 0))
br label %22
22: ; preds = %20, %12
ret void
}