#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);
    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    11a0 <__ashldi3+0xa0>
cmpl   $0x40,-0xc(%rbp)
jl     1135 <__ashldi3+0x35>
movl   $0x0,-0x4(%rbp)
jmp    11a0 <__ashldi3+0xa0>
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     1169 <__ashldi3+0x69>
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    %cl,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
jmp    1190 <__ashldi3+0x90>
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 %43
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 %43
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 %26
22: ; preds = %16
%23 = load i32, i32* %6
%24 = load i32, i32* %5
%25 = shl i32 %23, %24
store i32 %25, i32* %7
store i32 0, i32* %6
br label %38
26: ; preds = %16
%27 = load i32, i32* %7
%28 = load i32, i32* %5
%29 = shl i32 %27, %28
%30 = load i32, i32* %6
%31 = load i32, i32* %5
%32 = sub nsw i32 32, %31
%33 = ashr i32 %30, %32
%34 = add nsw i32 %29, %33
store i32 %34, i32* %7
%35 = load i32, i32* %6
%36 = load i32, i32* %5
%37 = shl i32 %35, %36
store i32 %37, i32* %6
br label %38
38: ; preds = %26, %22
%39 = load i32, i32* %7
%40 = shl i32 %39, 32
%41 = load i32, i32* %6
%42 = add nsw i32 %40, %41
store i32 %42, i32* %3
br label %43
43: ; preds = %38, %15, %10
%44 = load i32, i32* %3
ret i32 %44
}

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
}