#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 signalVoltage();
int /*<<< orphan*/ waitBitTime();
int /*<<< orphan*/ waitOneAndHalfBitTime();
unsigned char recieveCommand(int min) {
  unsigned char i, val;
  int v;
  val = 0;
  waitOneAndHalfBitTime();
  for (i = 0; i < 3; i++) {
    v = signalVoltage();
    val |= (v > min) ? (0x01 << i) : 0x00;
    waitBitTime();
  }
  waitOneAndHalfBitTime();
  return val;
}


x86 assembly (clang, -O0):
<recieveCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movb   $0x0,-0x6(%rbp)
mov    $0x0,%al
call   1030 <waitOneAndHalfBitTime@plt>
movb   $0x0,-0x5(%rbp)
movzbl -0x5(%rbp),%eax
cmp    $0x3,%eax
jge    11aa <recieveCommand+0x7a>
mov    $0x0,%al
call   1040 <signalVoltage@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jle    1180 <recieveCommand+0x50>
movzbl -0x5(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x10(%rbp)
jmp    118a <recieveCommand+0x5a>
xor    %eax,%eax
mov    %eax,-0x10(%rbp)
jmp    118a <recieveCommand+0x5a>
mov    -0x10(%rbp),%ecx
movzbl -0x6(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x6(%rbp)
mov    $0x0,%al
call   1050 <waitBitTime@plt>
mov    -0x5(%rbp),%al
add    $0x1,%al
mov    %al,-0x5(%rbp)
jmp    114a <recieveCommand+0x1a>
mov    $0x0,%al
call   1030 <waitOneAndHalfBitTime@plt>
movzbl -0x6(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recieveCommand>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1030 <waitOneAndHalfBitTime@plt>
xor    %eax,%eax
call   1040 <signalVoltage@plt>
cmp    %ebx,%eax
setg   %bpl
xor    %eax,%eax
call   1050 <waitBitTime@plt>
xor    %eax,%eax
call   1040 <signalVoltage@plt>
cmp    %ebx,%eax
setg   %r14b
add    %r14b,%r14b
or     %bpl,%r14b
xor    %eax,%eax
call   1050 <waitBitTime@plt>
xor    %eax,%eax
call   1040 <signalVoltage@plt>
cmp    %ebx,%eax
setg   %bl
shl    $0x2,%bl
or     %r14b,%bl
xor    %eax,%eax
call   1050 <waitBitTime@plt>
xor    %eax,%eax
call   1030 <waitOneAndHalfBitTime@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define zeroext i8 @recieveCommand(i32 %0) {
%2 = tail call i32 (...) @waitOneAndHalfBitTime()
%3 = tail call i32 (...) @signalVoltage()
%4 = icmp sgt i32 %3, %0
%5 = zext i1 %4 to i8
%6 = tail call i32 (...) @waitBitTime()
%7 = tail call i32 (...) @signalVoltage()
%8 = icmp sgt i32 %7, %0
%9 = select i1 %8, i8 2, i8 0
%10 = or i8 %9, %5
%11 = tail call i32 (...) @waitBitTime()
%12 = tail call i32 (...) @signalVoltage()
%13 = icmp sgt i32 %12, %0
%14 = select i1 %13, i8 4, i8 0
%15 = or i8 %14, %10
%16 = tail call i32 (...) @waitBitTime()
%17 = tail call i32 (...) @waitOneAndHalfBitTime()
ret i8 %15
}