#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 uint8_t;
typedef int uint32_t;

/* Variables and functions */
uint32_t compute_mask(uint8_t n) {
  uint32_t mask;
  uint8_t i;
  mask = 0;
  for (i = 0; i < n; i++) {
    mask |= (0x80000000 >> i);
  }
  return mask;
}


x86 assembly (clang, -O0):
<compute_mask>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    113f <compute_mask+0x3f>
mov    -0xc(%rbp),%ecx
mov    $0x80000000,%eax
shr    %cl,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1115 <compute_mask+0x15>
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_mask>:
test   %edi,%edi
jle    13b1 <compute_mask+0x2b1>
xor    %ecx,%ecx
mov    $0x0,%eax
cmp    $0x8,%edi
jb     13a0 <compute_mask+0x2a0>
mov    %edi,%ecx
and    $0xfffffff8,%ecx
lea    -0x8(%rcx),%edx
mov    %edx,%eax
shr    $0x3,%eax
add    $0x1,%eax
test   %edx,%edx
je     13b4 <compute_mask+0x2b4>
mov    %eax,%edx
and    $0xfffffffe,%edx
xorps  %xmm0,%xmm0
movdqa 0xec0(%rip),%xmm6
movdqa 0xec7(%rip),%xmm8
movdqa 0xece(%rip),%xmm12
movdqa 0xed5(%rip),%xmm9
movdqa 0xedc(%rip),%xmm10
movdqa 0xee3(%rip),%xmm11
xorps  %xmm2,%xmm2
movdqa %xmm6,%xmm1
paddd  %xmm8,%xmm1
pshuflw $0xfe,%xmm6,%xmm3
movdqa %xmm12,%xmm5
psrld  %xmm3,%xmm5
pshuflw $0x54,%xmm6,%xmm3
movdqa %xmm12,%xmm4
psrld  %xmm3,%xmm4
punpcklqdq %xmm5,%xmm4
pshufd $0xee,%xmm6,%xmm3
pshuflw $0xfe,%xmm3,%xmm5
movdqa %xmm12,%xmm7
psrld  %xmm5,%xmm7
pshuflw $0x54,%xmm3,%xmm3
movdqa %xmm12,%xmm5
psrld  %xmm3,%xmm5
punpckhqdq %xmm7,%xmm5
shufps $0xcc,%xmm5,%xmm4
orps   %xmm0,%xmm4
pshuflw $0xfe,%xmm1,%xmm0
movdqa %xmm12,%xmm5
psrld  %xmm0,%xmm5
pshuflw $0x54,%xmm1,%xmm0
movdqa %xmm12,%xmm3
psrld  %xmm0,%xmm3
punpcklqdq %xmm5,%xmm3
pshufd $0xee,%xmm1,%xmm0
pshuflw $0xfe,%xmm0,%xmm1
movdqa %xmm12,%xmm5
psrld  %xmm1,%xmm5
pshuflw $0x54,%xmm0,%xmm0
movdqa %xmm12,%xmm1
psrld  %xmm0,%xmm1
punpckhqdq %xmm5,%xmm1
shufps $0xcc,%xmm1,%xmm3
orps   %xmm2,%xmm3
movdqa %xmm6,%xmm1
paddd  %xmm9,%xmm1
movdqa %xmm6,%xmm5
paddd  %xmm10,%xmm5
pshuflw $0xfe,%xmm1,%xmm0
movdqa %xmm12,%xmm2
psrld  %xmm0,%xmm2
pshuflw $0x54,%xmm1,%xmm7
movdqa %xmm12,%xmm0
psrld  %xmm7,%xmm0
punpcklqdq %xmm2,%xmm0
pshufd $0xee,%xmm1,%xmm1
pshuflw $0xfe,%xmm1,%xmm2
movdqa %xmm12,%xmm7
psrld  %xmm2,%xmm7
pshuflw $0x54,%xmm1,%xmm1
movdqa %xmm12,%xmm2
psrld  %xmm1,%xmm2
punpckhqdq %xmm7,%xmm2
shufps $0xcc,%xmm2,%xmm0
orps   %xmm4,%xmm0
pshuflw $0xfe,%xmm5,%xmm1
movdqa %xmm12,%xmm4
psrld  %xmm1,%xmm4
pshuflw $0x54,%xmm5,%xmm1
movdqa %xmm12,%xmm2
psrld  %xmm1,%xmm2
punpcklqdq %xmm4,%xmm2
pshufd $0xee,%xmm5,%xmm1
pshuflw $0xfe,%xmm1,%xmm4
movdqa %xmm12,%xmm5
psrld  %xmm4,%xmm5
pshuflw $0x54,%xmm1,%xmm1
movdqa %xmm12,%xmm4
psrld  %xmm1,%xmm4
punpckhqdq %xmm5,%xmm4
shufps $0xcc,%xmm4,%xmm2
orps   %xmm3,%xmm2
paddd  %xmm11,%xmm6
add    $0xfffffffe,%edx
jne    1170 <compute_mask+0x70>
test   $0x1,%al
je     1375 <compute_mask+0x275>
movdqa 0xd37(%rip),%xmm4
pshuflw $0xfe,%xmm6,%xmm1
movdqa 0xd3a(%rip),%xmm3
movdqa %xmm3,%xmm5
psrld  %xmm1,%xmm5
paddd  %xmm6,%xmm4
pshuflw $0x54,%xmm6,%xmm1
movdqa %xmm3,%xmm7
psrld  %xmm1,%xmm7
pshufd $0xee,%xmm6,%xmm1
pshuflw $0xfe,%xmm1,%xmm8
movdqa %xmm3,%xmm6
psrld  %xmm8,%xmm6
punpcklqdq %xmm5,%xmm7
pshuflw $0x54,%xmm1,%xmm1
movdqa %xmm3,%xmm5
psrld  %xmm1,%xmm5
punpckhqdq %xmm6,%xmm5
pshuflw $0xfe,%xmm4,%xmm1
movdqa %xmm3,%xmm6
psrld  %xmm1,%xmm6
shufps $0xcc,%xmm5,%xmm7
pshuflw $0x54,%xmm4,%xmm1
movdqa %xmm3,%xmm5
psrld  %xmm1,%xmm5
pshufd $0xee,%xmm4,%xmm1
pshuflw $0xfe,%xmm1,%xmm8
movdqa %xmm3,%xmm4
psrld  %xmm8,%xmm4
orps   %xmm7,%xmm0
pshuflw $0x54,%xmm1,%xmm1
psrld  %xmm1,%xmm3
punpcklqdq %xmm6,%xmm5
punpckhqdq %xmm4,%xmm3
shufps $0xcc,%xmm3,%xmm5
orps   %xmm5,%xmm2
orps   %xmm2,%xmm0
pshufd $0xee,%xmm0,%xmm1
por    %xmm0,%xmm1
pshufd $0x55,%xmm1,%xmm0
por    %xmm1,%xmm0
movd   %xmm0,%eax
cmp    %edi,%ecx
je     13b0 <compute_mask+0x2b0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x80000000,%edx
shr    %cl,%edx
or     %edx,%eax
add    $0x1,%ecx
cmp    %ecx,%edi
jne    13a0 <compute_mask+0x2a0>
ret
xor    %eax,%eax
ret
xorps  %xmm0,%xmm0
movdqa 0xc41(%rip),%xmm6
xorps  %xmm2,%xmm2
test   $0x1,%al
jne    12d1 <compute_mask+0x1d1>
jmp    1375 <compute_mask+0x275>

LLVM IR (-O0):
define i32 @compute_mask(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %14, %1
%6 = load i32, i32* %4
%7 = load i32, i32* %2
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %17
9: ; preds = %5
%10 = load i32, i32* %4
%11 = lshr i32 -2147483648, %10
%12 = load i32, i32* %3
%13 = or i32 %12, %11
store i32 %13, i32* %3
br label %14
14: ; preds = %9
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
store i32 %16, i32* %4
br label %5
17: ; preds = %5
%18 = load i32, i32* %3
ret i32 %18
}

LLVM IR (-O2):
define i32 @compute_mask(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %3, label %62
3: ; preds = %1
%4 = icmp ult i32 %0, 8
br i1 %4, label %52, label %5
5: ; preds = %3
%6 = and i32 %0, -8
%7 = add i32 %6, -8
%8 = lshr exact i32 %7, 3
%9 = add nuw nsw i32 %8, 1
%10 = and i32 %9, 1
%11 = icmp eq i32 %7, 0
br i1 %11, label %33, label %12
12: ; preds = %5
%13 = and i32 %9, 1073741822
br label %14
14: ; preds = %14, %12
%15 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %12 ], [ %30, %14 ]
%16 = phi <4 x i32> [ zeroinitializer, %12 ], [ %28, %14 ]
%17 = phi <4 x i32> [ zeroinitializer, %12 ], [ %29, %14 ]
%18 = phi i32 [ 0, %12 ], [ %31, %14 ]
%19 = add <4 x i32> %15, <i32 4, i32 4, i32 4, i32 4>
%20 = lshr <4 x i32> <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>, %15
%21 = lshr <4 x i32> <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>, %19
%22 = or <4 x i32> %20, %16
%23 = or <4 x i32> %21, %17
%24 = add <4 x i32> %15, <i32 8, i32 8, i32 8, i32 8>
%25 = add <4 x i32> %15, <i32 12, i32 12, i32 12, i32 12>
%26 = lshr <4 x i32> <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>, %24
%27 = lshr <4 x i32> <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>, %25
%28 = or <4 x i32> %26, %22
%29 = or <4 x i32> %27, %23
%30 = add <4 x i32> %15, <i32 16, i32 16, i32 16, i32 16>
%31 = add i32 %18, 2
%32 = icmp eq i32 %31, %13
br i1 %32, label %33, label %14
33: ; preds = %14, %5
%34 = phi <4 x i32> [ undef, %5 ], [ %28, %14 ]
%35 = phi <4 x i32> [ undef, %5 ], [ %29, %14 ]
%36 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %5 ], [ %30, %14 ]
%37 = phi <4 x i32> [ zeroinitializer, %5 ], [ %28, %14 ]
%38 = phi <4 x i32> [ zeroinitializer, %5 ], [ %29, %14 ]
%39 = icmp eq i32 %10, 0
br i1 %39, label %46, label %40
40: ; preds = %33
%41 = add <4 x i32> %36, <i32 4, i32 4, i32 4, i32 4>
%42 = lshr <4 x i32> <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>, %36
%43 = lshr <4 x i32> <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>, %41
%44 = or <4 x i32> %42, %37
%45 = or <4 x i32> %43, %38
br label %46
46: ; preds = %33, %40
%47 = phi <4 x i32> [ %34, %33 ], [ %44, %40 ]
%48 = phi <4 x i32> [ %35, %33 ], [ %45, %40 ]
%49 = or <4 x i32> %48, %47
%50 = call i32 @llvm.vector.reduce.or.v4i32(<4 x i32> %49)
%51 = icmp eq i32 %6, %0
br i1 %51, label %62, label %52
52: ; preds = %3, %46
%53 = phi i32 [ 0, %3 ], [ %6, %46 ]
%54 = phi i32 [ 0, %3 ], [ %50, %46 ]
br label %55
55: ; preds = %52, %55
%56 = phi i32 [ %60, %55 ], [ %53, %52 ]
%57 = phi i32 [ %59, %55 ], [ %54, %52 ]
%58 = lshr i32 -2147483648, %56
%59 = or i32 %58, %57
%60 = add nuw nsw i32 %56, 1
%61 = icmp eq i32 %60, %0
br i1 %61, label %62, label %55
62: ; preds = %55, %46, %1
%63 = phi i32 [ 0, %1 ], [ %50, %46 ], [ %59, %55 ]
ret i32 %63
}