#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 */
int /*<<< orphan*/ printf(char *, unsigned char, unsigned char, unsigned char,
                          unsigned char);
int main(void) {
  unsigned char gb = 0xdf;
  unsigned char mask = 0x01;
  unsigned char lc = 0;
  unsigned char nb = 0;
  while (lc < 8) {
    nb = (nb << lc) | ((gb & mask) >> lc);
    lc++;
    mask = mask << 1;
    printf("gb 0x%x lc %d mask 0x%x nb 0x%x\n", gb, lc, mask, nb);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0xdf,-0x5(%rbp)
movb   $0x1,-0x6(%rbp)
movb   $0x0,-0x7(%rbp)
movb   $0x0,-0x8(%rbp)
movzbl -0x7(%rbp),%eax
cmp    $0x8,%eax
jge    1197 <main+0x87>
movzbl -0x8(%rbp),%eax
movzbl -0x7(%rbp),%ecx
shl    %cl,%eax
movzbl -0x5(%rbp),%edx
movzbl -0x6(%rbp),%ecx
and    %ecx,%edx
movzbl -0x7(%rbp),%ecx
sar    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    %al,-0x8(%rbp)
mov    -0x7(%rbp),%al
add    $0x1,%al
mov    %al,-0x7(%rbp)
movzbl -0x6(%rbp),%eax
shl    $0x1,%eax
mov    %al,-0x6(%rbp)
mov    -0x5(%rbp),%dl
mov    -0x7(%rbp),%cl
mov    -0x6(%rbp),%al
lea    0xe81(%rip),%rdi
movzbl %dl,%esi
movzbl %cl,%edx
movzbl %al,%ecx
movzbl -0x8(%rbp),%r8d
call   1030 <printf@plt>
jmp    112f <main+0x1f>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xee8(%rip),%rbx
mov    %rbx,%rdi
mov    $0xdf,%esi
mov    $0x1,%edx
mov    $0x2,%ecx
mov    $0x1,%r8d
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xdf,%esi
mov    $0x2,%edx
mov    $0x4,%ecx
mov    $0x3,%r8d
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xdf,%esi
mov    $0x3,%edx
mov    $0x8,%ecx
mov    $0xd,%r8d
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xdf,%esi
mov    $0x4,%edx
mov    $0x10,%ecx
mov    $0x69,%r8d
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xdf,%esi
mov    $0x5,%edx
mov    $0x20,%ecx
mov    $0x91,%r8d
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xdf,%esi
mov    $0x6,%edx
mov    $0x40,%ecx
mov    $0x20,%r8d
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xdf,%esi
mov    $0x7,%edx
mov    $0x80,%ecx
mov    $0x1,%r8d
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xdf,%esi
mov    $0x8,%edx
xor    %ecx,%ecx
mov    $0x81,%r8d
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"gb 0x%x lc %d mask 0x%x nb 0x%x\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
store i32 0, i32* %1
store i8 -33, i8* %2
store i8 1, i8* %3
store i8 0, i8* %4
store i8 0, i8* %5
br label %6
6: ; preds = %10, %0
%7 = load i8, i8* %4
%8 = zext i8 %7 to i32
%9 = icmp slt i32 %8, 8
br i1 %9, label %10, label %37
10: ; preds = %6
%11 = load i8, i8* %5
%12 = zext i8 %11 to i32
%13 = load i8, i8* %4
%14 = zext i8 %13 to i32
%15 = shl i32 %12, %14
%16 = load i8, i8* %2
%17 = zext i8 %16 to i32
%18 = load i8, i8* %3
%19 = zext i8 %18 to i32
%20 = and i32 %17, %19
%21 = load i8, i8* %4
%22 = zext i8 %21 to i32
%23 = ashr i32 %20, %22
%24 = or i32 %15, %23
%25 = trunc i32 %24 to i8
store i8 %25, i8* %5
%26 = load i8, i8* %4
%27 = add i8 %26, 1
store i8 %27, i8* %4
%28 = load i8, i8* %3
%29 = zext i8 %28 to i32
%30 = shl i32 %29, 1
%31 = trunc i32 %30 to i8
store i8 %31, i8* %3
%32 = load i8, i8* %2
%33 = load i8, i8* %4
%34 = load i8, i8* %3
%35 = load i8, i8* %5
%36 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8 zeroext %32, i8 zeroext %33, i8 zeroext %34, i8 zeroext %35)
br label %6
37: ; preds = %6
%38 = load i32, i32* %1
ret i32 %38
}

LLVM IR (-O2):
@.str = [33 x i8] c"gb 0x%x lc %d mask 0x%x nb 0x%x\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8 zeroext -33, i8 zeroext 1, i8 zeroext 2, i8 zeroext 1)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8 zeroext -33, i8 zeroext 2, i8 zeroext 4, i8 zeroext 3)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8 zeroext -33, i8 zeroext 3, i8 zeroext 8, i8 zeroext 13)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8 zeroext -33, i8 zeroext 4, i8 zeroext 16, i8 zeroext 105)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8 zeroext -33, i8 zeroext 5, i8 zeroext 32, i8 zeroext -111)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8 zeroext -33, i8 zeroext 6, i8 zeroext 64, i8 zeroext 32)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8 zeroext -33, i8 zeroext 7, i8 zeroext -128, i8 zeroext 1)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8 zeroext -33, i8 zeroext 8, i8 zeroext 0, i8 zeroext -127)
ret i32 0
}