#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 /*<<< orphan*/ FILE;

/* Variables and functions */
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ writeError(int);
unsigned int robotConfigPcReadNextBitPart(FILE *filePointer,
                                          unsigned int bitIndex) {
  char c = fgetc(filePointer);
  if (c != '0' && c != '1') {
    writeError(0x6300);
    return 0;
  }
  if (c == '1') {
    return 1 << bitIndex;
  }
  return 0;
}


x86 assembly (clang, -O0):
<robotConfigPcReadNextBitPart>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x15(%rbp)
movsbl -0x15(%rbp),%eax
cmp    $0x30,%eax
je     116b <robotConfigPcReadNextBitPart+0x4b>
movsbl -0x15(%rbp),%eax
cmp    $0x31,%eax
je     116b <robotConfigPcReadNextBitPart+0x4b>
mov    $0x6300,%edi
call   1040 <writeError@plt>
movl   $0x0,-0x4(%rbp)
jmp    1191 <robotConfigPcReadNextBitPart+0x71>
movsbl -0x15(%rbp),%eax
cmp    $0x31,%eax
jne    118a <robotConfigPcReadNextBitPart+0x6a>
mov    -0x14(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x4(%rbp)
jmp    1191 <robotConfigPcReadNextBitPart+0x71>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<robotConfigPcReadNextBitPart>:
push   %rbx
mov    %esi,%ebx
call   1030 <fgetc@plt>
mov    %eax,%ecx
and    $0xfe,%cl
cmp    $0x30,%cl
jne    1144 <robotConfigPcReadNextBitPart+0x24>
mov    $0x1,%edx
mov    %ebx,%ecx
shl    %cl,%edx
xor    %ecx,%ecx
cmp    $0x31,%al
cmove  %edx,%ecx
jmp    1150 <robotConfigPcReadNextBitPart+0x30>
mov    $0x6300,%edi
call   1040 <writeError@plt>
xor    %ecx,%ecx
mov    %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @robotConfigPcReadNextBitPart(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8
store i32* %0, i32** %4
store i32 %1, i32* %5
%7 = load i32*, i32** %4
%8 = call signext i8 @fgetc(i32* %7)
store i8 %8, i8* %6
%9 = load i8, i8* %6
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 48
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load i8, i8* %6
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 49
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @writeError(i32 25344)
store i32 0, i32* %3
br label %26
18: ; preds = %12, %2
%19 = load i8, i8* %6
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 49
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i32, i32* %5
%24 = shl i32 1, %23
store i32 %24, i32* %3
br label %26
25: ; preds = %18
store i32 0, i32* %3
br label %26
26: ; preds = %25, %22, %16
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
define i32 @robotConfigPcReadNextBitPart(i32* nocapture %0, i32 %1) {
%3 = tail call signext i8 @fgetc(i32* %0)
%4 = and i8 %3, -2
%5 = icmp eq i8 %4, 48
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @writeError(i32 25344)
br label %12
8: ; preds = %2
%9 = icmp eq i8 %3, 49
%10 = shl nuw i32 1, %1
%11 = select i1 %9, i32 %10, i32 0
br label %12
12: ; preds = %8, %6
%13 = phi i32 [ 0, %6 ], [ %11, %8 ]
ret i32 %13
}