#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__ memcmp(char *, char *, int);
int /*<<< orphan*/ printf(char *);
int test_memcmp(void) {
  char value0[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
  char value1[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 11};
  printf("\tmemcmp");
  if (memcmp(value0, value1, 9) != 0)
    return 1;
  else
    printf(".");
  if (memcmp(value0, value1, 10) == 0)
    return 1;
  else
    printf(".");
  printf(" passed.\n");
  return 0;
}


x86 assembly (clang, -O0):
<test_memcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0xe(%rbp)
mov    0xece(%rip),%ax
mov    %ax,-0x6(%rbp)
mov    0xec5(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec2(%rip),%ax
mov    %ax,-0x10(%rbp)
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
lea    -0xe(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x9,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     1188 <test_memcmp+0x68>
movl   $0x1,-0x4(%rbp)
jmp    11db <test_memcmp+0xbb>
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
lea    -0xe(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
jne    11bc <test_memcmp+0x9c>
movl   $0x1,-0x4(%rbp)
jmp    11db <test_memcmp+0xbb>
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_memcmp>:
push   %rbx
sub    $0x20,%rsp
movabs $0x807060504030201,%rax
06 07 08
mov    %rax,0x10(%rsp)
movw   $0xa09,0x18(%rsp)
mov    %rax,(%rsp)
movw   $0xb09,0x8(%rsp)
lea    0xea7(%rip),%rdi
call   1050 <printf@plt>
lea    0x10(%rsp),%rdi
mov    %rsp,%rsi
mov    $0x9,%edx
call   1060 <memcmp@plt>
mov    $0x1,%ebx
test   %rax,%rax
jne    11c7 <test_memcmp+0x87>
mov    $0x2e,%edi
call   1030 <putchar@plt>
lea    0x10(%rsp),%rdi
mov    %rsp,%rsi
mov    $0xa,%edx
call   1060 <memcmp@plt>
test   %rax,%rax
je     11c7 <test_memcmp+0x87>
mov    $0x2e,%edi
call   1030 <putchar@plt>
lea    0xe5c(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@__const.test_memcmp.value0 = [10 x i8] c"\01\02\03\04\05\06\07\08\09\0A"
@__const.test_memcmp.value1 = [10 x i8] c"\01\02\03\04\05\06\07\08\09\0B"
@.str = [8 x i8] c"\09memcmp\00"
@str = [9 x i8] c" passed.\00"
define i32 @test_memcmp() {
%1 = alloca [10 x i8]
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%6 = call i64 @memcmp(i8* %3, i8* %4, i32 9)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %0
%9 = call i32 @putchar(i32 46)
%10 = call i64 @memcmp(i8* %3, i8* %4, i32 10)
%11 = icmp eq i64 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %8
%13 = call i32 @putchar(i32 46)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %15
15: ; preds = %8, %0, %12
%16 = phi i32 [ 0, %12 ], [ 1, %0 ], [ 1, %8 ]
ret i32 %16
}