#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*/ p(int, char);
int b(int c) {
  int q;
  int r;
  q = c & 7;
  q = (1 + 7 * q - q * q) / 3;
  c &= 15;
  r = (3 - c) * (c - 12);
  if (r < 0)
    r = 0;
  p(!q + 4 + r / 6, ' ');
  return q;
}


x86 assembly (clang, -O0):
<b>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x7,%eax
mov    %eax,-0x8(%rbp)
imul   $0x7,-0x8(%rbp),%eax
add    $0x1,%eax
mov    -0x8(%rbp),%ecx
imul   -0x8(%rbp),%ecx
sub    %ecx,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0xf,%eax
mov    %eax,-0x4(%rbp)
mov    $0x3,%eax
sub    -0x4(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0xc,%ecx
imul   %ecx,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    116d <b+0x5d>
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
add    $0x4,%edi
mov    -0xc(%rbp),%eax
mov    $0x6,%ecx
cltd
idiv   %ecx
add    %eax,%edi
mov    $0x20,%esi
call   1030 <p@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<b>:
push   %rbx
mov    %edi,%ecx
and    $0x7,%ecx
mov    %ecx,%eax
xor    $0x7,%eax
imul   %ecx,%eax
lea    0x1(%rax),%ecx
movzbl %cl,%ecx
imul   $0xab,%ecx,%ebx
shr    $0x9,%ebx
and    $0xf,%edi
mov    $0x3,%ecx
sub    %edi,%ecx
add    $0xfffffff4,%edi
imul   %ecx,%edi
xor    %ecx,%ecx
test   %edi,%edi
cmovg  %edi,%ecx
movzbl %cl,%ecx
imul   $0xab,%ecx,%edi
shr    $0xa,%edi
cmp    $0x2,%eax
adc    $0x0,%edi
add    $0x4,%edi
mov    $0x20,%esi
call   1030 <p@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @b(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = and i32 %5, 7
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = mul nsw i32 7, %7
%9 = add nsw i32 1, %8
%10 = load i32, i32* %3
%11 = load i32, i32* %3
%12 = mul nsw i32 %10, %11
%13 = sub nsw i32 %9, %12
%14 = sdiv i32 %13, 3
store i32 %14, i32* %3
%15 = load i32, i32* %2
%16 = and i32 %15, 15
store i32 %16, i32* %2
%17 = load i32, i32* %2
%18 = sub nsw i32 3, %17
%19 = load i32, i32* %2
%20 = sub nsw i32 %19, 12
%21 = mul nsw i32 %18, %20
store i32 %21, i32* %4
%22 = load i32, i32* %4
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %1
store i32 0, i32* %4
br label %25
25: ; preds = %24, %1
%26 = load i32, i32* %3
%27 = icmp ne i32 %26, 0
%28 = xor i1 %27, true
%29 = zext i1 %28 to i32
%30 = add nsw i32 %29, 4
%31 = load i32, i32* %4
%32 = sdiv i32 %31, 6
%33 = add nsw i32 %30, %32
%34 = call i32 @p(i32 %33, i8 signext 32)
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
define i32 @b(i32 %0) {
%2 = and i32 %0, 7
%3 = xor i32 %2, 7
%4 = mul nuw nsw i32 %3, %2
%5 = trunc i32 %4 to i8
%6 = add nuw nsw i8 %5, 1
%7 = udiv i8 %6, 3
%8 = zext i8 %7 to i32
%9 = and i32 %0, 15
%10 = sub nsw i32 3, %9
%11 = add nsw i32 %9, -12
%12 = mul nsw i32 %10, %11
%13 = icmp sgt i32 %12, 0
%14 = select i1 %13, i32 %12, i32 0
%15 = icmp ult i32 %4, 2
%16 = select i1 %15, i32 5, i32 4
%17 = trunc i32 %14 to i8
%18 = udiv i8 %17, 6
%19 = zext i8 %18 to i32
%20 = add nuw nsw i32 %16, %19
%21 = tail call i32 @p(i32 %20, i8 signext 32)
ret i32 %8
}