#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;
  if (memcmp(value0, value1, 10) == 0)
    return 1;
  printf("\tpassed.\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    11c3 <test_memcmp+0xa3>
lea    -0xe(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
jne    11b0 <test_memcmp+0x90>
movl   $0x1,-0x4(%rbp)
jmp    11c3 <test_memcmp+0xa3>
lea    0xe65(%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    0xeb7(%rip),%rdi
call   1040 <printf@plt>
lea    0x10(%rsp),%rdi
mov    %rsp,%rsi
mov    $0x9,%edx
call   1050 <memcmp@plt>
mov    $0x1,%ebx
test   %rax,%rax
jne    11a3 <test_memcmp+0x73>
lea    0x10(%rsp),%rdi
mov    %rsp,%rsi
mov    $0xa,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     11a3 <test_memcmp+0x73>
lea    0xe80(%rip),%rdi
call   1030 <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 = [10 x i8] c"\09passed.\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 %20
12: ; preds = %0
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%15 = call i64 @memcmp(i8* %13, i8* %14, i32 10)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %12
store i32 1, i32* %1
br label %20
18: ; preds = %12
%19 = 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 %20
20: ; preds = %18, %17, %11
%21 = load i32, i32* %1
ret i32 %21
}

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"\09passed.\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 %13
8: ; preds = %0
%9 = call i64 @memcmp(i8* %3, i8* %4, i32 10)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %13
13: ; preds = %8, %0, %11
%14 = phi i32 [ 0, %11 ], [ 1, %0 ], [ 1, %8 ]
ret i32 %14
}