#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int fwide(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
void check_orientation(FILE *stream) {
  int rc;
  rc = fwide(stream, 0);
  if (rc < 0) {
    printf("Stream has byte orientation.\n");
  } else if (rc > 0) {
    printf("Stream has wide orientation.\n");
  } else {
    printf("Stream has no orientation.\n");
  }
  return;
}


x86 assembly (clang, -O0):
<check_orientation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1040 <fwide@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1155 <check_orientation+0x35>
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
jmp    1181 <check_orientation+0x61>
cmpl   $0x0,-0xc(%rbp)
jle    1170 <check_orientation+0x50>
lea    0xeb8(%rip),%rdi
call   1030 <printf@plt>
jmp    117c <check_orientation+0x5c>
lea    0xec5(%rip),%rdi
call   1030 <printf@plt>
jmp    1181 <check_orientation+0x61>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_orientation>:
push   %rax
xor    %esi,%esi
call   1040 <fwide@plt>
test   %eax,%eax
lea    0xecf(%rip),%rax
lea    0xee3(%rip),%rcx
cmove  %rax,%rcx
lea    0xef5(%rip),%rdi
cmovns %rcx,%rdi
pop    %rax
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"Stream has byte orientation.\0A\00"
@.str.1 = [30 x i8] c"Stream has wide orientation.\0A\00"
@.str.2 = [28 x i8] c"Stream has no orientation.\0A\00"
define void @check_orientation(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = call i32 @fwide(i32* %4, i32 0)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %18
10: ; preds = %1
%11 = load i32, i32* %3
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
br label %17
15: ; preds = %10
%16 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %17
17: ; preds = %15, %13
br label %18
18: ; preds = %17, %8
ret void
}

LLVM IR (-O2):
@str = [27 x i8] c"Stream has no orientation.\00"
@str.3 = [29 x i8] c"Stream has wide orientation.\00"
@str.4 = [29 x i8] c"Stream has byte orientation.\00"
define void @check_orientation(i32* %0) {
%2 = tail call i32 @fwide(i32* %0, i32 0)
%3 = icmp slt i32 %2, 0
%4 = icmp eq i32 %2, 0
%5 = select i1 %4, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @str.3, i64 0, i64 0)
%6 = select i1 %3, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @str.4, i64 0, i64 0), i8* %5
%7 = tail call i32 @puts(i8* dereferenceable(1) %6)
ret void
}