#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 *, ...);
void print_r10_layout(int layout) {
  int near = layout & 255;
  int far = (layout >> 8) & 255;
  int offset = (layout & 0x10000);
  char *sep = "";
  if (near != 1) {
    printf("%s near=%d", sep, near);
    sep = ",";
  }
  if (far != 1)
    printf("%s %s=%d", sep, offset ? "offset" : "far", far);
  if (near * far == 1)
    printf("NO REDUNDANCY");
}


x86 assembly (clang, -O0):
<print_r10_layout>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
and    $0x10000,%eax
mov    %eax,-0x10(%rbp)
lea    0xec6(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     1174 <print_r10_layout+0x64>
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%edx
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9b(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x1,-0xc(%rbp)
je     11ab <print_r10_layout+0x9b>
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%ecx
lea    0xe91(%rip),%rdx
lea    0xe83(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
mov    -0xc(%rbp),%ecx
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
cmp    $0x1,%eax
jne    11c9 <print_r10_layout+0xb9>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_r10_layout>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
movzbl %bl,%r14d
movzbl %bh,%ebp
cmp    $0x1,%r14d
jne    1131 <print_r10_layout+0x21>
lea    0xee2(%rip),%rsi
cmp    $0x1,%ebp
jne    1155 <print_r10_layout+0x45>
jmp    117d <print_r10_layout+0x6d>
lea    0xec8(%rip),%rdi
lea    0xecd(%rip),%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xebb(%rip),%rsi
cmp    $0x1,%ebp
je     117d <print_r10_layout+0x6d>
test   $0x10000,%ebx
lea    0xebb(%rip),%rax
lea    0xead(%rip),%rdx
cmove  %rax,%rdx
lea    0xe99(%rip),%rdi
mov    %ebp,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
imul   %r14d,%ebp
cmp    $0x1,%ebp
jne    1198 <print_r10_layout+0x88>
lea    0xe94(%rip),%rdi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [11 x i8] c"%s near=%d\00"
@.str.2 = [2 x i8] c",\00"
@.str.3 = [9 x i8] c"%s %s=%d\00"
@.str.4 = [7 x i8] c"offset\00"
@.str.5 = [4 x i8] c"far\00"
@.str.6 = [14 x i8] c"NO REDUNDANCY\00"
define void @print_r10_layout(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i32 %0, i32* %2
%7 = load i32, i32* %2
%8 = and i32 %7, 255
store i32 %8, i32* %3
%9 = load i32, i32* %2
%10 = ashr i32 %9, 8
%11 = and i32 %10, 255
store i32 %11, i32* %4
%12 = load i32, i32* %2
%13 = and i32 %12, 65536
store i32 %13, i32* %5
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %6
%14 = load i32, i32* %3
%15 = icmp ne i32 %14, 1
br i1 %15, label %16, label %20
16: ; preds = %1
%17 = load i8*, i8** %6
%18 = load i32, i32* %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %17, i32 %18)
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8** %6
br label %20
20: ; preds = %16, %1
%21 = load i32, i32* %4
%22 = icmp ne i32 %21, 1
br i1 %22, label %23, label %31
23: ; preds = %20
%24 = load i8*, i8** %6
%25 = load i32, i32* %5
%26 = icmp ne i32 %25, 0
%27 = zext i1 %26 to i64
%28 = select i1 %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0)
%29 = load i32, i32* %4
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %24, i8* %28, i32 %29)
br label %31
31: ; preds = %23, %20
%32 = load i32, i32* %3
%33 = load i32, i32* %4
%34 = mul nsw i32 %32, %33
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %38
36: ; preds = %31
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
br label %38
38: ; preds = %36, %31
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [11 x i8] c"%s near=%d\00"
@.str.2 = [2 x i8] c",\00"
@.str.3 = [9 x i8] c"%s %s=%d\00"
@.str.4 = [7 x i8] c"offset\00"
@.str.5 = [4 x i8] c"far\00"
@.str.6 = [14 x i8] c"NO REDUNDANCY\00"
define void @print_r10_layout(i32 %0) {
%2 = and i32 %0, 255
%3 = lshr i32 %0, 8
%4 = and i32 %3, 255
%5 = and i32 %0, 65536
%6 = icmp eq i32 %2, 1
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i32 %2)
br label %9
9: ; preds = %7, %1
%10 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), %7 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %1 ]
%11 = icmp eq i32 %4, 1
br i1 %11, label %16, label %12
12: ; preds = %9
%13 = icmp eq i32 %5, 0
%14 = select i1 %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %10, i8* %14, i32 %4)
br label %16
16: ; preds = %12, %9
%17 = mul nuw nsw i32 %4, %2
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
br label %21
21: ; preds = %19, %16
ret void
}