#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 INT_MIN;
int threeforths(int x) {
  int is_neg = x & INT_MIN;
  int f = x & ~0x3;
  int l = x & 0x3;
  int fd4 = f >> 2;
  int fd4m3 = (fd4 << 1) + fd4;
  int lm3 = (l << 1) + l;
  int bias = (1 << 2) - 1;
  (is_neg && (lm3 += bias));
  int lm3d4 = lm3 >> 2;
  return fd4m3 + lm3d4;
}


x86 assembly (clang, -O0):
<threeforths>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2ed7(%rip),%rcx
and    (%rcx),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0xfffffffc,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
and    $0x3,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x2,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
shl    $0x1,%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x3,-0x20(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x25(%rbp)
je     1171 <threeforths+0x71>
mov    -0x20(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
mov    -0x1c(%rbp),%eax
sar    $0x2,%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%eax
add    -0x24(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<threeforths>:
mov    0x2ee1(%rip),%rax
mov    %edi,%ecx
and    $0x3,%ecx
test   %edi,(%rax)
lea    (%rcx,%rcx,2),%edx
lea    0x3(%rcx,%rcx,2),%eax
cmove  %edx,%eax
sar    $0x2,%edi
lea    (%rdi,%rdi,2),%ecx
shr    $0x2,%eax
add    %ecx,%eax
ret

LLVM IR (-O0):
@INT_MIN = global i32 0
define i32 @threeforths(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %2
%11 = load i32, i32* %2
%12 = load i32, i32* @INT_MIN
%13 = and i32 %11, %12
store i32 %13, i32* %3
%14 = load i32, i32* %2
%15 = and i32 %14, -4
store i32 %15, i32* %4
%16 = load i32, i32* %2
%17 = and i32 %16, 3
store i32 %17, i32* %5
%18 = load i32, i32* %4
%19 = ashr i32 %18, 2
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = shl i32 %20, 1
%22 = load i32, i32* %6
%23 = add nsw i32 %21, %22
store i32 %23, i32* %7
%24 = load i32, i32* %5
%25 = shl i32 %24, 1
%26 = load i32, i32* %5
%27 = add nsw i32 %25, %26
store i32 %27, i32* %8
store i32 3, i32* %9
%28 = load i32, i32* %3
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %1
%31 = load i32, i32* %9
%32 = load i32, i32* %8
%33 = add nsw i32 %32, %31
store i32 %33, i32* %8
%34 = icmp ne i32 %33, 0
br label %35
35: ; preds = %30, %1
%36 = phi i1 [ false, %1 ], [ %34, %30 ]
%37 = zext i1 %36 to i32
%38 = load i32, i32* %8
%39 = ashr i32 %38, 2
store i32 %39, i32* %10
%40 = load i32, i32* %7
%41 = load i32, i32* %10
%42 = add nsw i32 %40, %41
ret i32 %42
}

LLVM IR (-O2):
@INT_MIN = global i32 0
define i32 @threeforths(i32 %0) {
%2 = load i32, i32* @INT_MIN
%3 = and i32 %2, %0
%4 = and i32 %0, 3
%5 = mul nuw nsw i32 %4, 3
%6 = icmp eq i32 %3, 0
%7 = add nuw nsw i32 %5, 3
%8 = select i1 %6, i32 %5, i32 %7
%9 = ashr i32 %0, 2
%10 = mul nsw i32 %9, 3
%11 = lshr i32 %8, 2
%12 = add nsw i32 %11, %10
ret i32 %12
}