#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
uint32_t generate(int x) {
  assert(x >= 0);
  assert(x < 16);
  uint32_t result = 0;
  for (int i = 0; i < 4; i++) {
    if (x & (1 << i))
      result |= 1 << (8 * i + 7);
  }
  return result;
}


x86 assembly (clang, -O0):
<generate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x10,-0x4(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    1198 <generate+0x88>
mov    -0x4(%rbp),%eax
mov    -0xc(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1185 <generate+0x75>
mov    -0xc(%rbp),%ecx
shl    $0x3,%ecx
add    $0x7,%ecx
mov    $0x1,%eax
shl    %cl,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    118a <generate+0x7a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114b <generate+0x3b>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate>:
push   %rbx
mov    %edi,%ebx
not    %edi
shr    $0x1f,%edi
call   1030 <assert@plt>
xor    %edi,%edi
cmp    $0x10,%ebx
setl   %dil
call   1030 <assert@plt>
mov    %ebx,%eax
shl    $0x7,%eax
movzbl %al,%eax
mov    %ebx,%ecx
and    $0x2,%ecx
shl    $0xe,%ecx
or     %eax,%ecx
mov    %ebx,%eax
and    $0x4,%eax
shl    $0x15,%eax
or     %ecx,%eax
and    $0xfffffff8,%ebx
shl    $0x1c,%ebx
or     %eax,%ebx
mov    %ebx,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @generate(i32 %0) {
%2 = xor i32 %0, -1
%3 = lshr i32 %2, 31
%4 = tail call i32 @assert(i32 %3)
%5 = icmp slt i32 %0, 16
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = shl i32 %0, 7
%9 = and i32 %8, 128
%10 = shl i32 %0, 14
%11 = and i32 %10, 32768
%12 = or i32 %11, %9
%13 = shl i32 %0, 21
%14 = and i32 %13, 8388608
%15 = or i32 %14, %12
%16 = shl i32 %0, 28
%17 = and i32 %16, -2147483648
%18 = or i32 %17, %15
ret i32 %18
}