#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 uint32_t;

/* Variables and functions */
uint32_t times256(uint32_t r) {
  int k;
  for (k = 0; k < 8; k++) {
    if (r & 0x80000000)
      r = (r << 1) ^ 0x1EDC6F41;
    else
      r = (r << 1);
  }
  return (r);
}


x86 assembly (clang, -O0):
<times256>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    1158 <times256+0x58>
mov    -0x4(%rbp),%eax
and    $0x80000000,%eax
cmp    $0x0,%eax
je     113c <times256+0x3c>
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
xor    $0x1edc6f41,%eax
mov    %eax,-0x4(%rbp)
jmp    1145 <times256+0x45>
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    114a <times256+0x4a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    110e <times256+0xe>
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<times256>:
lea    (%rdi,%rdi,1),%eax
mov    %eax,%ecx
xor    $0x1edc6f41,%ecx
test   %edi,%edi
cmovns %eax,%ecx
lea    (%rcx,%rcx,1),%eax
mov    %eax,%edx
xor    $0x1edc6f41,%edx
test   %ecx,%ecx
cmovns %eax,%edx
lea    (%rdx,%rdx,1),%eax
mov    %eax,%ecx
xor    $0x1edc6f41,%ecx
test   %edx,%edx
cmovns %eax,%ecx
lea    (%rcx,%rcx,1),%eax
mov    %eax,%edx
xor    $0x1edc6f41,%edx
test   %ecx,%ecx
cmovns %eax,%edx
lea    (%rdx,%rdx,1),%eax
mov    %eax,%ecx
xor    $0x1edc6f41,%ecx
test   %edx,%edx
cmovns %eax,%ecx
lea    (%rcx,%rcx,1),%eax
mov    %eax,%edx
xor    $0x1edc6f41,%edx
test   %ecx,%ecx
cmovns %eax,%edx
lea    (%rdx,%rdx,1),%eax
mov    %eax,%ecx
xor    $0x1edc6f41,%ecx
test   %edx,%edx
cmovns %eax,%ecx
lea    (%rcx,%rcx,1),%edx
mov    %edx,%eax
xor    $0x1edc6f41,%eax
test   %ecx,%ecx
cmovns %edx,%eax
ret

LLVM IR (-O0):
define i32 @times256(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %19, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 8
br i1 %6, label %7, label %22
7: ; preds = %4
%8 = load i32, i32* %2
%9 = and i32 %8, -2147483648
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %7
%12 = load i32, i32* %2
%13 = shl i32 %12, 1
%14 = xor i32 %13, 517762881
store i32 %14, i32* %2
br label %18
15: ; preds = %7
%16 = load i32, i32* %2
%17 = shl i32 %16, 1
store i32 %17, i32* %2
br label %18
18: ; preds = %15, %11
br label %19
19: ; preds = %18
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %4
22: ; preds = %4
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
define i32 @times256(i32 %0) {
%2 = icmp sgt i32 %0, -1
%3 = shl i32 %0, 1
%4 = xor i32 %3, 517762881
%5 = select i1 %2, i32 %3, i32 %4
%6 = icmp sgt i32 %5, -1
%7 = shl i32 %5, 1
%8 = xor i32 %7, 517762881
%9 = select i1 %6, i32 %7, i32 %8
%10 = icmp sgt i32 %9, -1
%11 = shl i32 %9, 1
%12 = xor i32 %11, 517762881
%13 = select i1 %10, i32 %11, i32 %12
%14 = icmp sgt i32 %13, -1
%15 = shl i32 %13, 1
%16 = xor i32 %15, 517762881
%17 = select i1 %14, i32 %15, i32 %16
%18 = icmp sgt i32 %17, -1
%19 = shl i32 %17, 1
%20 = xor i32 %19, 517762881
%21 = select i1 %18, i32 %19, i32 %20
%22 = icmp sgt i32 %21, -1
%23 = shl i32 %21, 1
%24 = xor i32 %23, 517762881
%25 = select i1 %22, i32 %23, i32 %24
%26 = icmp sgt i32 %25, -1
%27 = shl i32 %25, 1
%28 = xor i32 %27, 517762881
%29 = select i1 %26, i32 %27, i32 %28
%30 = icmp sgt i32 %29, -1
%31 = shl i32 %29, 1
%32 = xor i32 %31, 517762881
%33 = select i1 %30, i32 %31, i32 %32
ret i32 %33
}