#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*/ memcmp(char *, char *, int);
int /*<<< orphan*/ printf(char *, char *, char *, char *, char *, char *,
                          int /*<<< orphan*/, char *, int /*<<< orphan*/,
                          char *, int /*<<< orphan*/);
int main(void) {
  char s1[] = "ABCDEFG";
  char s2[] = "ABCDXYZ";
  printf("%s%s\n%s%s\n\n%s%2d\n%s%2d\n%s%2d\n", "s1 = ", s1, "s2 = ", s2,
         "memcmp( s1, s2, 4 ) = ", memcmp(s1, s2, 4),
         "memcmp( s1, s2, 7 ) = ", memcmp(s1, s2, 7),
         "memcmp( s2, s1, 7 ) = ", memcmp(s2, s1, 7));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x50,%rsp
movl   $0x0,-0x14(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x1c(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x24(%rbp)
lea    -0x1c(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x24(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x1c(%rbp),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x4,%edx
call   1040 <memcmp@plt>
mov    %eax,%r14d
lea    -0x1c(%rbp),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x7,%edx
call   1040 <memcmp@plt>
mov    %eax,-0x28(%rbp)
lea    -0x24(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x7,%edx
call   1040 <memcmp@plt>
mov    -0x38(%rbp),%rdx
mov    -0x30(%rbp),%r8
mov    -0x28(%rbp),%r11d
lea    0xe69(%rip),%rdi
lea    0xe80(%rip),%rsi
lea    0xe7f(%rip),%rcx
lea    0xe7e(%rip),%r9
lea    0xe8e(%rip),%rbx
lea    0xe9e(%rip),%r10
mov    %r14d,(%rsp)
mov    %rbx,0x8(%rsp)
mov    %r11d,0x10(%rsp)
mov    %r10,0x18(%rsp)
mov    %eax,0x20(%rsp)
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movabs $0x47464544434241,%rax
mov    %rax,0x10(%rsp)
movabs $0x5a595844434241,%rax
mov    %rax,0x8(%rsp)
lea    0x10(%rsp),%rbx
lea    0x8(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1040 <memcmp@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x7,%edx
call   1040 <memcmp@plt>
mov    %eax,%r12d
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x7,%edx
call   1040 <memcmp@plt>
sub    $0x8,%rsp
lea    0xec4(%rip),%r10
lea    0xea6(%rip),%r11
lea    0xe5e(%rip),%rdi
lea    0xe75(%rip),%rsi
lea    0xe74(%rip),%rcx
lea    0xe73(%rip),%r9
mov    %rbx,%rdx
mov    %r15,%r8
push   %rax
push   %r10
push   %r12
push   %r11
push   %r14
call   1030 <printf@plt>
add    $0x30,%rsp
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.s1 = [8 x i8] c"ABCDEFG\00"
@__const.main.s2 = [8 x i8] c"ABCDXYZ\00"
@.str = [30 x i8] c"%s%s\0A%s%s\0A\0A%s%2d\0A%s%2d\0A%s%2d\0A\00"
@.str.1 = [6 x i8] c"s1 = \00"
@.str.2 = [6 x i8] c"s2 = \00"
@.str.3 = [23 x i8] c"memcmp( s1, s2, 4 ) = \00"
@.str.4 = [23 x i8] c"memcmp( s1, s2, 7 ) = \00"
@.str.5 = [23 x i8] c"memcmp( s2, s1, 7 ) = \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x i8]
%3 = alloca [8 x i8]
store i32 0, i32* %1
%4 = bitcast [8 x i8]* %2 to i8*
%5 = bitcast [8 x i8]* %3 to i8*
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%10 = call i32 @memcmp(i8* %8, i8* %9, i32 4)
%11 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%12 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%13 = call i32 @memcmp(i8* %11, i8* %12, i32 7)
%14 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%16 = call i32 @memcmp(i8* %14, i8* %15, i32 7)
%17 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %7, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %10, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %13, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %16)
ret i32 0
}

LLVM IR (-O2):
@.str = [30 x i8] c"%s%s\0A%s%s\0A\0A%s%2d\0A%s%2d\0A%s%2d\0A\00"
@.str.1 = [6 x i8] c"s1 = \00"
@.str.2 = [6 x i8] c"s2 = \00"
@.str.3 = [23 x i8] c"memcmp( s1, s2, 4 ) = \00"
@.str.4 = [23 x i8] c"memcmp( s1, s2, 7 ) = \00"
@.str.5 = [23 x i8] c"memcmp( s2, s1, 7 ) = \00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = bitcast i64* %1 to i8*
store i64 20061986658402881, i64* %1
%4 = bitcast i64* %2 to i8*
store i64 25430983541211713, i64* %2
%5 = call i32 @memcmp(i8* %3, i8* %4, i32 4)
%6 = call i32 @memcmp(i8* %3, i8* %4, i32 7)
%7 = call i32 @memcmp(i8* %4, i8* %3, i32 7)
%8 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %4, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %5, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %6, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %7)
ret i32 0
}