#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 machine_is_le();
scalar_t__ strcmp(char const *, char *);
int reverse_byte_order(const char *s) {
  if (0 == strcmp(s, "be"))
    return machine_is_le();
  if (0 == strcmp(s, "le"))
    return !machine_is_le();
  return 0;
}


x86 assembly (clang, -O0):
<reverse_byte_order>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec9(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1159 <reverse_byte_order+0x39>
mov    $0x0,%al
call   1030 <machine_is_le@plt>
mov    %eax,-0x4(%rbp)
jmp    119a <reverse_byte_order+0x7a>
mov    -0x10(%rbp),%rdi
lea    0xe9f(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1193 <reverse_byte_order+0x73>
mov    $0x0,%al
call   1030 <machine_is_le@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    119a <reverse_byte_order+0x7a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse_byte_order>:
push   %rbx
mov    %rdi,%rbx
lea    0xed5(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1150 <reverse_byte_order+0x30>
lea    0xec7(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     1158 <reverse_byte_order+0x38>
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
jmp    1030 <machine_is_le@plt>
xor    %eax,%eax
call   1030 <machine_is_le@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"be\00"
@.str.1 = [3 x i8] c"le\00"
define i32 @reverse_byte_order(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 0, %5
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 (...) @machine_is_le()
store i32 %8, i32* %2
br label %19
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 0, %11
br i1 %12, label %13, label %18
13: ; preds = %9
%14 = call i32 (...) @machine_is_le()
%15 = icmp ne i32 %14, 0
%16 = xor i1 %15, true
%17 = zext i1 %16 to i32
store i32 %17, i32* %2
br label %19
18: ; preds = %9
store i32 0, i32* %2
br label %19
19: ; preds = %18, %13, %7
%20 = load i32, i32* %2
ret i32 %20
}

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