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

/* Variables and functions */
uint64_t __ashldi3(uint64_t a, int b) {
  if (b <= 0) {
    return a;
  }
  if (b >= 64) {
    return 0;
  }
  uint32_t aLow = (uint32_t)a;
  uint32_t aHigh = (uint32_t)(a >> 32);
  if (b >= 32) {
    aHigh = (aLow << (b - 32));
    aLow = 0;
  } else {
    aHigh = (aHigh << b) + (aLow >> (32 - b));
    aLow = (aLow << b);
  }
  return ((uint64_t)aHigh << 32) + aLow;
}


x86 assembly (clang, -O0):
<__ashldi3>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jg     111f <__ashldi3+0x1f>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a3 <__ashldi3+0xa3>
cmpl   $0x40,-0xc(%rbp)
jl     1135 <__ashldi3+0x35>
movl   $0x0,-0x4(%rbp)
jmp    11a3 <__ashldi3+0xa3>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x20,-0xc(%rbp)
jl     116c <__ashldi3+0x6c>
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x20,%ecx
shl    %cl,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
jmp    1193 <__ashldi3+0x93>
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    %cl,%eax
mov    -0x10(%rbp),%edx
mov    $0x20,%ecx
sub    -0xc(%rbp),%ecx
sar    %cl,%edx
mov    %edx,%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    %cl,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x20,%ecx
shl    %cl,%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<__ashldi3>:
xor    %eax,%eax
test   %esi,%esi
cmovle %edi,%eax
ret

LLVM IR (-O0):
define i32 @__ashldi3(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%8 = load i32, i32* %5
%9 = icmp sle i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = load i32, i32* %4
store i32 %11, i32* %3
br label %44
12: ; preds = %2
%13 = load i32, i32* %5
%14 = icmp sge i32 %13, 64
br i1 %14, label %15, label %16
15: ; preds = %12
store i32 0, i32* %3
br label %44
16: ; preds = %12
%17 = load i32, i32* %4
store i32 %17, i32* %6
%18 = load i32, i32* %4
%19 = ashr i32 %18, 32
store i32 %19, i32* %7
%20 = load i32, i32* %5
%21 = icmp sge i32 %20, 32
br i1 %21, label %22, label %27
22: ; preds = %16
%23 = load i32, i32* %6
%24 = load i32, i32* %5
%25 = sub nsw i32 %24, 32
%26 = shl i32 %23, %25
store i32 %26, i32* %7
store i32 0, i32* %6
br label %39
27: ; preds = %16
%28 = load i32, i32* %7
%29 = load i32, i32* %5
%30 = shl i32 %28, %29
%31 = load i32, i32* %6
%32 = load i32, i32* %5
%33 = sub nsw i32 32, %32
%34 = ashr i32 %31, %33
%35 = add nsw i32 %30, %34
store i32 %35, i32* %7
%36 = load i32, i32* %6
%37 = load i32, i32* %5
%38 = shl i32 %36, %37
store i32 %38, i32* %6
br label %39
39: ; preds = %27, %22
%40 = load i32, i32* %7
%41 = shl i32 %40, 32
%42 = load i32, i32* %6
%43 = add nsw i32 %41, %42
store i32 %43, i32* %3
br label %44
44: ; preds = %39, %15, %10
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
define i32 @__ashldi3(i32 %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
%4 = select i1 %3, i32 0, i32 %0
ret i32 %4
}