#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*/ delay(int);
unsigned char dip();
int /*<<< orphan*/ leds(unsigned char);
void main(void) {
  unsigned char left = 0xC0;
  unsigned char right = 0x07;
  unsigned char cnt = 0;
  while (1) {
    unsigned char dip_value = dip();
    if (dip_value == 0x44) {
      if (cnt < 6) {
        leds((0xC0 >> cnt) | (0x07 << cnt));
      } else {
        leds((0xC0 >> (6 * 2 - cnt)) | (0x07 << (6 * 2 - cnt)));
      }
      cnt++;
      if (cnt > 6 * 2)
        cnt = 0;
    } else {
      leds(~dip_value);
    }
    delay(100);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movb   $0xc0,-0x1(%rbp)
movb   $0x7,-0x2(%rbp)
movb   $0x0,-0x3(%rbp)
mov    $0x0,%al
call   1030 <dip@plt>
mov    %al,-0x4(%rbp)
movzbl -0x4(%rbp),%eax
cmp    $0x44,%eax
jne    11dd <main+0xad>
movzbl -0x3(%rbp),%eax
cmp    $0x6,%eax
jge    118f <main+0x5f>
movzbl -0x3(%rbp),%ecx
mov    $0xc0,%eax
sar    %cl,%eax
movzbl -0x3(%rbp),%ecx
mov    $0x7,%edx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
movzbl %al,%edi
call   1050 <leds@plt>
jmp    11bf <main+0x8f>
movzbl -0x3(%rbp),%eax
mov    $0xc,%ecx
sub    %eax,%ecx
mov    $0xc0,%eax
sar    %cl,%eax
movzbl -0x3(%rbp),%edx
mov    $0xc,%ecx
sub    %edx,%ecx
mov    $0x7,%edx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
movzbl %al,%edi
call   1050 <leds@plt>
mov    -0x3(%rbp),%al
add    $0x1,%al
mov    %al,-0x3(%rbp)
movzbl -0x3(%rbp),%eax
cmp    $0xc,%eax
jle    11d8 <main+0xa8>
movb   $0x0,-0x3(%rbp)
jmp    11ec <main+0xbc>
movzbl -0x4(%rbp),%eax
xor    $0xffffffff,%eax
movzbl %al,%edi
call   1050 <leds@plt>
mov    $0x64,%edi
call   1040 <delay@plt>
jmp    1144 <main+0x14>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    1154 <main+0x24>
nopl   0x0(%rax)
not    %al
movzbl %al,%edi
call   1050 <leds@plt>
mov    $0x64,%edi
call   1040 <delay@plt>
xor    %eax,%eax
call   1030 <dip@plt>
cmp    $0x44,%al
jne    1140 <main+0x10>
mov    $0xc,%al
sub    %bpl,%al
cmp    $0x6,%bpl
movzbl %al,%ecx
movzbl %bpl,%ebp
cmovb  %ebp,%ecx
mov    $0xc0,%eax
shr    %cl,%eax
mov    $0x7,%edx
shl    %cl,%edx
or     %eax,%edx
movzbl %dl,%edi
call   1050 <leds@plt>
add    $0x1,%bpl
cmp    $0xd,%bpl
movzbl %bpl,%ebp
cmovae %ebx,%ebp
jmp    114a <main+0x1a>

LLVM IR (-O0):
define void @main() {
%1 = alloca i8
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8
store i8 -64, i8* %1
store i8 7, i8* %2
store i8 0, i8* %3
br label %5
5: ; preds = %0, %50
%6 = call zeroext i8 (...) @dip()
store i8 %6, i8* %4
%7 = load i8, i8* %4
%8 = zext i8 %7 to i32
%9 = icmp eq i32 %8, 68
br i1 %9, label %10, label %44
10: ; preds = %5
%11 = load i8, i8* %3
%12 = zext i8 %11 to i32
%13 = icmp slt i32 %12, 6
br i1 %13, label %14, label %24
14: ; preds = %10
%15 = load i8, i8* %3
%16 = zext i8 %15 to i32
%17 = ashr i32 192, %16
%18 = load i8, i8* %3
%19 = zext i8 %18 to i32
%20 = shl i32 7, %19
%21 = or i32 %17, %20
%22 = trunc i32 %21 to i8
%23 = call i32 @leds(i8 zeroext %22)
br label %36
24: ; preds = %10
%25 = load i8, i8* %3
%26 = zext i8 %25 to i32
%27 = sub nsw i32 12, %26
%28 = ashr i32 192, %27
%29 = load i8, i8* %3
%30 = zext i8 %29 to i32
%31 = sub nsw i32 12, %30
%32 = shl i32 7, %31
%33 = or i32 %28, %32
%34 = trunc i32 %33 to i8
%35 = call i32 @leds(i8 zeroext %34)
br label %36
36: ; preds = %24, %14
%37 = load i8, i8* %3
%38 = add i8 %37, 1
store i8 %38, i8* %3
%39 = load i8, i8* %3
%40 = zext i8 %39 to i32
%41 = icmp sgt i32 %40, 12
br i1 %41, label %42, label %43
42: ; preds = %36
store i8 0, i8* %3
br label %43
43: ; preds = %42, %36
br label %50
44: ; preds = %5
%45 = load i8, i8* %4
%46 = zext i8 %45 to i32
%47 = xor i32 %46, -1
%48 = trunc i32 %47 to i8
%49 = call i32 @leds(i8 zeroext %48)
br label %50
50: ; preds = %44, %43
%51 = call i32 @delay(i32 100)
br label %5
}

LLVM IR (-O2):
define void @main() {
br label %1
1: ; preds = %21, %0
%2 = phi i8 [ 0, %0 ], [ %22, %21 ]
%3 = tail call zeroext i8 (...) @dip()
%4 = icmp eq i8 %3, 68
br i1 %4, label %5, label %18
5: ; preds = %1
%6 = zext i8 %2 to i32
%7 = icmp ult i8 %2, 6
%8 = sub nsw i32 12, %6
%9 = select i1 %7, i32 %6, i32 %8
%10 = lshr i32 192, %9
%11 = shl i32 7, %9
%12 = or i32 %10, %11
%13 = trunc i32 %12 to i8
%14 = tail call i32 @leds(i8 zeroext %13)
%15 = add i8 %2, 1
%16 = icmp ugt i8 %15, 12
%17 = select i1 %16, i8 0, i8 %15
br label %21
18: ; preds = %1
%19 = xor i8 %3, -1
%20 = tail call i32 @leds(i8 zeroext %19)
br label %21
21: ; preds = %18, %5
%22 = phi i8 [ %17, %5 ], [ %2, %18 ]
%23 = tail call i32 @delay(i32 100)
br label %1
}