#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*/ assert(int);
scalar_t__ string_compare(char *, char *);
void test_string_compare(void) {
  char test1[] = "Apple";
  char test2[] = "Orange";
  char test3[] = "Apple";
  assert(string_compare(test1, test2) < 0);
  assert(string_compare(test2, test1) > 0);
  assert(string_compare(test1, test3) == 0);
}


x86 assembly (clang, -O0):
<test_string_compare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xed2(%rip),%eax
mov    %eax,-0x6(%rbp)
mov    0xecc(%rip),%ax
mov    %ax,-0x2(%rbp)
mov    0xec4(%rip),%eax
mov    %eax,-0xd(%rbp)
mov    0xebe(%rip),%ax
mov    %ax,-0x9(%rbp)
mov    0xeb6(%rip),%al
mov    %al,-0x7(%rbp)
mov    0xea1(%rip),%eax
mov    %eax,-0x13(%rbp)
mov    0xe9b(%rip),%ax
mov    %ax,-0xf(%rbp)
lea    -0x6(%rbp),%rdi
lea    -0xd(%rbp),%rsi
call   1030 <string_compare@plt>
cmp    $0x0,%rax
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    -0xd(%rbp),%rdi
lea    -0x6(%rbp),%rsi
call   1030 <string_compare@plt>
cmp    $0x0,%rax
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    -0x6(%rbp),%rdi
lea    -0x13(%rbp),%rsi
call   1030 <string_compare@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_string_compare>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movw   $0x65,0xc(%rsp)
movl   $0x6c707041,0x8(%rsp)
6c
movl   $0x65676e,0x13(%rsp)
movl   $0x6e61724f,0x10(%rsp)
6e
movw   $0x65,0x4(%rsp)
movl   $0x6c707041,(%rsp)
lea    0x8(%rsp),%r14
lea    0x10(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <string_compare@plt>
shr    $0x3f,%rax
mov    %eax,%edi
call   1040 <assert@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <string_compare@plt>
xor    %edi,%edi
test   %rax,%rax
setg   %dil
call   1040 <assert@plt>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <string_compare@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.test_string_compare.test1 = [6 x i8] c"Apple\00"
@__const.test_string_compare.test2 = [7 x i8] c"Orange\00"
@__const.test_string_compare.test3 = [6 x i8] c"Apple\00"
define void @test_string_compare() {
%1 = alloca [6 x i8]
%2 = alloca [7 x i8]
%3 = alloca [6 x i8]
%4 = bitcast [6 x i8]* %1 to i8*
%5 = bitcast [7 x i8]* %2 to i8*
%6 = bitcast [6 x i8]* %3 to i8*
%7 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%8 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%9 = call i64 @string_compare(i8* %7, i8* %8)
%10 = icmp slt i64 %9, 0
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%14 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%15 = call i64 @string_compare(i8* %13, i8* %14)
%16 = icmp sgt i64 %15, 0
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%20 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%21 = call i64 @string_compare(i8* %19, i8* %20)
%22 = icmp eq i64 %21, 0
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
ret void
}

LLVM IR (-O2):
@__const.test_string_compare.test2 = [7 x i8] c"Orange\00"
@__const.test_string_compare.test3 = [6 x i8] c"Apple\00"
define void @test_string_compare() {
%1 = alloca [6 x i8]
%2 = alloca [7 x i8]
%3 = alloca [6 x i8]
%4 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%7 = call i64 @string_compare(i8* %4, i8* %5)
%8 = lshr i64 %7, 63
%9 = trunc i64 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = call i64 @string_compare(i8* %5, i8* %4)
%12 = icmp sgt i64 %11, 0
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = call i64 @string_compare(i8* %4, i8* %6)
%16 = icmp eq i64 %15, 0
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
ret void
}