#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__ strcmp(char *, char *);
int compare(int a, int b, char *ordem) {
  if (strcmp("-d", ordem) == 0) {
    return a < b;
  } else if (strcmp("-r", ordem) == 0) {
    return a > b;
  }
  return 0;
}


x86 assembly (clang, -O0):
<compare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xed3(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1152 <compare+0x42>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
setl   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    118e <compare+0x7e>
mov    -0x18(%rbp),%rsi
lea    0xea6(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1182 <compare+0x72>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    118e <compare+0x7e>
jmp    1187 <compare+0x77>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %esi,%r14d
mov    %edi,%ebp
lea    0xedd(%rip),%rdi
mov    %rdx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     114f <compare+0x3f>
lea    0xecc(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
sete   %cl
cmp    %r14d,%ebp
setg   %al
and    %cl,%al
jmp    1155 <compare+0x45>
cmp    %r14d,%ebp
setl   %al
movzbl %al,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-d\00"
@.str.1 = [3 x i8] c"-r\00"
define i32 @compare(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
%8 = load i8*, i8** %7
%9 = call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %3
%12 = load i32, i32* %5
%13 = load i32, i32* %6
%14 = icmp slt i32 %12, %13
%15 = zext i1 %14 to i32
store i32 %15, i32* %4
br label %27
16: ; preds = %3
%17 = load i8*, i8** %7
%18 = call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = load i32, i32* %5
%22 = load i32, i32* %6
%23 = icmp sgt i32 %21, %22
%24 = zext i1 %23 to i32
store i32 %24, i32* %4
br label %27
25: ; preds = %16
br label %26
26: ; preds = %25
store i32 0, i32* %4
br label %27
27: ; preds = %26, %20, %11
%28 = load i32, i32* %4
ret i32 %28
}

LLVM IR (-O2):
@.str = [3 x i8] c"-d\00"
@.str.1 = [3 x i8] c"-r\00"
define i32 @compare(i32 %0, i32 %1, i8* %2) {
%4 = tail call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = icmp slt i32 %0, %1
br label %13
8: ; preds = %3
%9 = tail call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%10 = icmp eq i64 %9, 0
%11 = icmp sgt i32 %0, %1
%12 = and i1 %11, %10
br label %13
13: ; preds = %8, %6
%14 = phi i1 [ %7, %6 ], [ %12, %8 ]
%15 = zext i1 %14 to i32
ret i32 %15
}