#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 memcmp(char *, char *, int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ printf(char *);
int main() {
  char str1[15];
  char str2[15];
  int ret;
  memcpy(str1, "abcdef", 6);
  memcpy(str2, "ABCDEF", 6);
  ret = memcmp(str1, str2, 5);
  if (ret > 0)
    printf("str1 is less than str2");
  else if (ret < 0)
    printf("str2 is less than str1");
  else
    printf("str1 is equal to str2");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x13(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x6,%edx
call   1050 <memcpy@plt>
lea    -0x22(%rbp),%rdi
lea    0xea8(%rip),%rsi
mov    $0x6,%edx
call   1050 <memcpy@plt>
lea    -0x13(%rbp),%rdi
lea    -0x22(%rbp),%rsi
mov    $0x5,%edx
call   1040 <memcmp@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jle    1199 <main+0x69>
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
jmp    11c5 <main+0x95>
cmpl   $0x0,-0x28(%rbp)
jge    11b4 <main+0x84>
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
jmp    11c0 <main+0x90>
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
jmp    11c5 <main+0x95>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xec2(%rip),%rsi
lea    0x19(%rsp),%r14
mov    %r14,%rdi
mov    $0x6,%edx
call   1050 <memcpy@plt>
lea    0xeb0(%rip),%rsi
lea    0xa(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x6,%edx
call   1050 <memcpy@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x5,%edx
call   1040 <memcmp@plt>
test   %eax,%eax
lea    0xea3(%rip),%rax
lea    0xeb3(%rip),%rcx
cmovs  %rax,%rcx
lea    0xe7a(%rip),%rdi
cmovle %rcx,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"abcdef\00"
@.str.1 = [7 x i8] c"ABCDEF\00"
@.str.2 = [23 x i8] c"str1 is less than str2\00"
@.str.3 = [23 x i8] c"str2 is less than str1\00"
@.str.4 = [22 x i8] c"str1 is equal to str2\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [15 x i8]
%3 = alloca [15 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%6 = call i32 @memcpy(i8* %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%7 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%8 = call i32 @memcpy(i8* %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%9 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%10 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%11 = call i32 @memcmp(i8* %9, i8* %10, i32 5)
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %24
16: ; preds = %0
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %23
21: ; preds = %16
%22 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %23
23: ; preds = %21, %19
br label %24
24: ; preds = %23, %14
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"abcdef\00"
@.str.1 = [7 x i8] c"ABCDEF\00"
@.str.2 = [23 x i8] c"str1 is less than str2\00"
@.str.3 = [23 x i8] c"str2 is less than str1\00"
@.str.4 = [22 x i8] c"str1 is equal to str2\00"
define i32 @main() {
%1 = alloca [15 x i8]
%2 = alloca [15 x i8]
%3 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%5 = call i32 @memcpy(i8* %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%6 = call i32 @memcpy(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%7 = call i32 @memcmp(i8* %3, i8* %4, i32 5)
%8 = icmp sgt i32 %7, 0
%9 = icmp slt i32 %7, 0
%10 = select i1 %9, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0)
%11 = select i1 %8, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %10
%12 = call i32 @printf(i8* dereferenceable(1) %11)
ret i32 0
}