#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*/ printf(char *, char const *, char const *);
int strcmp(char const *, char const *);
void test_strcmp(const char *s1, const char *s2) {
  int res = strcmp(s1, s2);
  if (res == 0)
    printf("'%s' and '%s' are equal\n", s1, s2);
  else if (res < 0)
    printf("'%s' is before '%s'\n", s1, s2);
  else
    printf("'%s' is after '%s'\n", s1, s2);
}


x86 assembly (clang, -O0):
<test_strcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcmp@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1163 <test_strcmp+0x43>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
jmp    119f <test_strcmp+0x7f>
cmpl   $0x0,-0x14(%rbp)
jge    1186 <test_strcmp+0x66>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
jmp    119a <test_strcmp+0x7a>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
jmp    119f <test_strcmp+0x7f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_strcmp>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <strcmp@plt>
test   %eax,%eax
lea    0xee1(%rip),%rax
lea    0xeef(%rip),%rcx
cmovs  %rax,%rcx
lea    0xeb6(%rip),%rdi
cmovne %rcx,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"'%s' and '%s' are equal\0A\00"
@.str.1 = [21 x i8] c"'%s' is before '%s'\0A\00"
@.str.2 = [20 x i8] c"'%s' is after '%s'\0A\00"
define void @test_strcmp(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = load i8*, i8** %4
%8 = call i32 @strcmp(i8* %6, i8* %7)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = load i8*, i8** %4
%14 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %12, i8* %13)
br label %27
15: ; preds = %2
%16 = load i32, i32* %5
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i8*, i8** %3
%20 = load i8*, i8** %4
%21 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %19, i8* %20)
br label %26
22: ; preds = %15
%23 = load i8*, i8** %3
%24 = load i8*, i8** %4
%25 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %23, i8* %24)
br label %26
26: ; preds = %22, %18
br label %27
27: ; preds = %26, %11
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"'%s' and '%s' are equal\0A\00"
@.str.1 = [21 x i8] c"'%s' is before '%s'\0A\00"
@.str.2 = [20 x i8] c"'%s' is after '%s'\0A\00"
define void @test_strcmp(i8* %0, i8* %1) {
%3 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(1) %1)
%4 = icmp eq i32 %3, 0
%5 = icmp slt i32 %3, 0
%6 = select i1 %5, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0)
%7 = select i1 %4, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %6
%8 = tail call i32 @printf(i8* %7, i8* %0, i8* %1)
ret void
}