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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
void shift_left(void *payload, uint8_t bit_size, uint32_t shift_len) {
  assert(shift_len <= bit_size);
  assert(bit_size == 8 || bit_size == 16 || bit_size == 32);
  switch (bit_size) {
  case 8:
    *((uint8_t *)payload) = *((uint8_t *)payload) << shift_len;
    break;
  case 16:
    *((uint16_t *)payload) = *((uint16_t *)payload) << shift_len;
    break;
  case 32:
    *((uint32_t *)payload) = *((uint32_t *)payload) << shift_len;
    break;
  }
}


x86 assembly (clang, -O0):
<shift_left>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    $0x1,%al
cmpl   $0x8,-0xc(%rbp)
mov    %al,-0x11(%rbp)
je     115d <shift_left+0x4d>
mov    $0x1,%al
cmpl   $0x10,-0xc(%rbp)
mov    %al,-0x11(%rbp)
je     115d <shift_left+0x4d>
cmpl   $0x20,-0xc(%rbp)
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
movzbl %al,%edi
and    $0x1,%edi
call   1030 <assert@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x8,%eax
je     11a1 <shift_left+0x91>
jmp    117f <shift_left+0x6f>
mov    -0x18(%rbp),%eax
sub    $0x10,%eax
je     11b9 <shift_left+0xa9>
jmp    1190 <shift_left+0x80>
mov    -0x18(%rbp),%eax
sub    $0x20,%eax
je     11d1 <shift_left+0xc1>
jmp    11e4 <shift_left+0xd4>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    -0x10(%rbp),%ecx
shl    %cl,%eax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
jmp    11e4 <shift_left+0xd4>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    -0x10(%rbp),%ecx
shl    %cl,%eax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
jmp    11e4 <shift_left+0xd4>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    -0x10(%rbp),%ecx
shl    %cl,%eax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shift_left>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebx
mov    %esi,%ebp
mov    %rdi,%r14
xor    %edi,%edi
cmp    %esi,%edx
setle  %dil
call   1030 <assert@plt>
mov    $0x1,%edi
cmp    $0x8,%ebp
je     1140 <shift_left+0x30>
cmp    $0x10,%ebp
je     1140 <shift_left+0x30>
xor    %edi,%edi
cmp    $0x20,%ebp
sete   %dil
call   1030 <assert@plt>
cmp    $0x20,%ebp
ja     1161 <shift_left+0x51>
mov    %ebp,%eax
movabs $0x100010100,%rcx
bt     %rax,%rcx
jae    1161 <shift_left+0x51>
mov    %ebx,%ecx
shll   %cl,(%r14)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @shift_left(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %6
%8 = load i32, i32* %5
%9 = icmp sle i32 %7, %8
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load i32, i32* %5
%13 = icmp eq i32 %12, 8
br i1 %13, label %20, label %14
14: ; preds = %3
%15 = load i32, i32* %5
%16 = icmp eq i32 %15, 16
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load i32, i32* %5
%19 = icmp eq i32 %18, 32
br label %20
20: ; preds = %17, %14, %3
%21 = phi i1 [ true, %14 ], [ true, %3 ], [ %19, %17 ]
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = load i32, i32* %5
switch i32 %24, label %49 [
i32 8, label %25
i32 16, label %33
i32 32, label %41
]
25: ; preds = %20
%26 = load i8*, i8** %4
%27 = bitcast i8* %26 to i32*
%28 = load i32, i32* %27
%29 = load i32, i32* %6
%30 = shl i32 %28, %29
%31 = load i8*, i8** %4
%32 = bitcast i8* %31 to i32*
store i32 %30, i32* %32
br label %49
33: ; preds = %20
%34 = load i8*, i8** %4
%35 = bitcast i8* %34 to i32*
%36 = load i32, i32* %35
%37 = load i32, i32* %6
%38 = shl i32 %36, %37
%39 = load i8*, i8** %4
%40 = bitcast i8* %39 to i32*
store i32 %38, i32* %40
br label %49
41: ; preds = %20
%42 = load i8*, i8** %4
%43 = bitcast i8* %42 to i32*
%44 = load i32, i32* %43
%45 = load i32, i32* %6
%46 = shl i32 %44, %45
%47 = load i8*, i8** %4
%48 = bitcast i8* %47 to i32*
store i32 %46, i32* %48
br label %49
49: ; preds = %20, %41, %33, %25
ret void
}

LLVM IR (-O2):
define void @shift_left(i8* nocapture %0, i32 %1, i32 %2) {
%4 = icmp sle i32 %2, %1
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
switch i32 %1, label %7 [
i32 16, label %10
i32 8, label %10
]
7: ; preds = %3
%8 = icmp eq i32 %1, 32
%9 = zext i1 %8 to i32
br label %10
10: ; preds = %3, %3, %7
%11 = phi i32 [ 1, %3 ], [ %9, %7 ], [ 1, %3 ]
%12 = tail call i32 @assert(i32 %11)
switch i32 %1, label %17 [
i32 8, label %13
i32 16, label %13
i32 32, label %13
]
13: ; preds = %10, %10, %10
%14 = bitcast i8* %0 to i32*
%15 = load i32, i32* %14
%16 = shl i32 %15, %2
store i32 %16, i32* %14
br label %17
17: ; preds = %13, %10
ret void
}