#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 */

/* Variables and functions */
unsigned int clearBits(int, int, unsigned int);
unsigned int putByteNumber(int byteNo, unsigned char byteValue,
                           unsigned int source) {
  if (byteNo < 0 || byteNo > 3) {
    return source;
  }
  int low = 8 * byteNo;
  int high = low + (8 - 1);
  source = clearBits(low, high, source);
  unsigned int newByteValue = byteValue << low;
  source = source | newByteValue;
  return source;
}


x86 assembly (clang, -O0):
<putByteNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %edi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1138 <putByteNumber+0x28>
cmpl   $0x3,-0x8(%rbp)
jle    1143 <putByteNumber+0x33>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1181 <putByteNumber+0x71>
mov    -0x8(%rbp),%eax
shl    $0x3,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x7,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <clearBits@plt>
mov    %eax,-0x10(%rbp)
movzbl -0x9(%rbp),%eax
mov    -0x14(%rbp),%ecx
shl    %cl,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putByteNumber>:
cmp    $0x3,%edi
ja     113c <putByteNumber+0x2c>
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
shl    $0x3,%ebp
lea    0x7(,%rdi,8),%esi
mov    %ebp,%edi
call   1030 <clearBits@plt>
movzbl %bl,%edx
mov    %ebp,%ecx
shl    %cl,%edx
or     %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
mov    %edx,%eax
ret

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

LLVM IR (-O2):
define i32 @putByteNumber(i32 %0, i8 zeroext %1, i32 %2) {
%4 = icmp ugt i32 %0, 3
br i1 %4, label %12, label %5
5: ; preds = %3
%6 = shl nuw nsw i32 %0, 3
%7 = or i32 %6, 7
%8 = tail call i32 @clearBits(i32 %6, i32 %7, i32 %2)
%9 = zext i8 %1 to i32
%10 = shl nuw i32 %9, %6
%11 = or i32 %8, %10
br label %12
12: ; preds = %3, %5
%13 = phi i32 [ %11, %5 ], [ %2, %3 ]
ret i32 %13
}