#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*/ assert(int);
int bin2int(char *);
void test_bin2int() {
  assert(bin2int("00000000") == 0);
  assert(bin2int("01111111") == 127);
  assert(bin2int("01111110") == 126);
  assert(bin2int("00000010") == 2);
  assert(bin2int("00000001") == 1);
  assert(bin2int("00000000") == 0);
  assert(bin2int("11111111") == -1);
  assert(bin2int("11111110") == -2);
  assert(bin2int("10000010") == -126);
  assert(bin2int("10000001") == -127);
  assert(bin2int("10000000") == -128);
  assert(bin2int("11111111111111111111111111111111") == -1);
  assert(bin2int("11111111111111111111111111110100") == -12);
}


x86 assembly (clang, -O0):
<test_bin2int>:
push   %rbp
mov    %rsp,%rbp
lea    0xed5(%rip),%rdi
call   1040 <bin2int@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xec2(%rip),%rdi
call   1040 <bin2int@plt>
cmp    $0x7f,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xeaf(%rip),%rdi
call   1040 <bin2int@plt>
cmp    $0x7e,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xe9c(%rip),%rdi
call   1040 <bin2int@plt>
cmp    $0x2,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xe89(%rip),%rdi
call   1040 <bin2int@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xe49(%rip),%rdi
call   1040 <bin2int@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xe96(%rip),%rdi
call   1040 <bin2int@plt>
cmp    $0xffffffff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xe3e(%rip),%rdi
call   1040 <bin2int@plt>
cmp    $0xfffffffe,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xe2b(%rip),%rdi
call   1040 <bin2int@plt>
cmp    $0xffffff82,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xe18(%rip),%rdi
call   1040 <bin2int@plt>
cmp    $0xffffff81,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xe05(%rip),%rdi
call   1040 <bin2int@plt>
cmp    $0xffffff80,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xdf2(%rip),%rdi
call   1040 <bin2int@plt>
cmp    $0xffffffff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xdf7(%rip),%rdi
call   1040 <bin2int@plt>
cmp    $0xfffffff4,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_bin2int>:
push   %rbx
lea    0xed8(%rip),%rbx
mov    %rbx,%rdi
call   1040 <bin2int@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
lea    0xec5(%rip),%rdi
call   1040 <bin2int@plt>
xor    %edi,%edi
cmp    $0x7f,%eax
sete   %dil
call   1030 <assert@plt>
lea    0xeb4(%rip),%rdi
call   1040 <bin2int@plt>
xor    %edi,%edi
cmp    $0x7e,%eax
sete   %dil
call   1030 <assert@plt>
lea    0xea3(%rip),%rdi
call   1040 <bin2int@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1030 <assert@plt>
lea    0xe92(%rip),%rdi
call   1040 <bin2int@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1030 <assert@plt>
mov    %rbx,%rdi
call   1040 <bin2int@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
lea    0xea8(%rip),%rdi
call   1040 <bin2int@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1030 <assert@plt>
lea    0xe52(%rip),%rdi
call   1040 <bin2int@plt>
xor    %edi,%edi
cmp    $0xfffffffe,%eax
sete   %dil
call   1030 <assert@plt>
lea    0xe41(%rip),%rdi
call   1040 <bin2int@plt>
xor    %edi,%edi
cmp    $0xffffff82,%eax
sete   %dil
call   1030 <assert@plt>
lea    0xe30(%rip),%rdi
call   1040 <bin2int@plt>
xor    %edi,%edi
cmp    $0xffffff81,%eax
sete   %dil
call   1030 <assert@plt>
lea    0xe1f(%rip),%rdi
call   1040 <bin2int@plt>
xor    %edi,%edi
cmp    $0xffffff80,%eax
sete   %dil
call   1030 <assert@plt>
lea    0xe0e(%rip),%rdi
call   1040 <bin2int@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1030 <assert@plt>
lea    0xe15(%rip),%rdi
call   1040 <bin2int@plt>
xor    %edi,%edi
cmp    $0xfffffff4,%eax
sete   %dil
pop    %rbx
jmp    1030 <assert@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"00000000\00"
@.str.1 = [9 x i8] c"01111111\00"
@.str.2 = [9 x i8] c"01111110\00"
@.str.3 = [9 x i8] c"00000010\00"
@.str.4 = [9 x i8] c"00000001\00"
@.str.5 = [9 x i8] c"11111111\00"
@.str.6 = [9 x i8] c"11111110\00"
@.str.7 = [9 x i8] c"10000010\00"
@.str.8 = [9 x i8] c"10000001\00"
@.str.9 = [9 x i8] c"10000000\00"
@.str.10 = [33 x i8] c"11111111111111111111111111111111\00"
@.str.11 = [33 x i8] c"11111111111111111111111111110100\00"
define void @test_bin2int() {
%1 = call i32 @bin2int(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32 %1, 0
%3 = zext i1 %2 to i32
%4 = call i32 @assert(i32 %3)
%5 = call i32 @bin2int(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32 %5, 127
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = call i32 @bin2int(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i32 %9, 126
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = call i32 @bin2int(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i32 %13, 2
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = call i32 @bin2int(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%18 = icmp eq i32 %17, 1
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = call i32 @bin2int(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%22 = icmp eq i32 %21, 0
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = call i32 @bin2int(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%26 = icmp eq i32 %25, -1
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = call i32 @bin2int(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%30 = icmp eq i32 %29, -2
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
%33 = call i32 @bin2int(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%34 = icmp eq i32 %33, -126
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = call i32 @bin2int(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%38 = icmp eq i32 %37, -127
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
%41 = call i32 @bin2int(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
%42 = icmp eq i32 %41, -128
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = call i32 @bin2int(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0))
%46 = icmp eq i32 %45, -1
%47 = zext i1 %46 to i32
%48 = call i32 @assert(i32 %47)
%49 = call i32 @bin2int(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0))
%50 = icmp eq i32 %49, -12
%51 = zext i1 %50 to i32
%52 = call i32 @assert(i32 %51)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"00000000\00"
@.str.1 = [9 x i8] c"01111111\00"
@.str.2 = [9 x i8] c"01111110\00"
@.str.3 = [9 x i8] c"00000010\00"
@.str.4 = [9 x i8] c"00000001\00"
@.str.5 = [9 x i8] c"11111111\00"
@.str.6 = [9 x i8] c"11111110\00"
@.str.7 = [9 x i8] c"10000010\00"
@.str.8 = [9 x i8] c"10000001\00"
@.str.9 = [9 x i8] c"10000000\00"
@.str.10 = [33 x i8] c"11111111111111111111111111111111\00"
@.str.11 = [33 x i8] c"11111111111111111111111111110100\00"
define void @test_bin2int() {
%1 = tail call i32 @bin2int(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32 %1, 0
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = tail call i32 @bin2int(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32 %5, 127
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = tail call i32 @bin2int(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i32 %9, 126
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = tail call i32 @bin2int(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i32 %13, 2
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
%17 = tail call i32 @bin2int(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%18 = icmp eq i32 %17, 1
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
%21 = tail call i32 @bin2int(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%22 = icmp eq i32 %21, 0
%23 = zext i1 %22 to i32
%24 = tail call i32 @assert(i32 %23)
%25 = tail call i32 @bin2int(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%26 = icmp eq i32 %25, -1
%27 = zext i1 %26 to i32
%28 = tail call i32 @assert(i32 %27)
%29 = tail call i32 @bin2int(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%30 = icmp eq i32 %29, -2
%31 = zext i1 %30 to i32
%32 = tail call i32 @assert(i32 %31)
%33 = tail call i32 @bin2int(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%34 = icmp eq i32 %33, -126
%35 = zext i1 %34 to i32
%36 = tail call i32 @assert(i32 %35)
%37 = tail call i32 @bin2int(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%38 = icmp eq i32 %37, -127
%39 = zext i1 %38 to i32
%40 = tail call i32 @assert(i32 %39)
%41 = tail call i32 @bin2int(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
%42 = icmp eq i32 %41, -128
%43 = zext i1 %42 to i32
%44 = tail call i32 @assert(i32 %43)
%45 = tail call i32 @bin2int(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0))
%46 = icmp eq i32 %45, -1
%47 = zext i1 %46 to i32
%48 = tail call i32 @assert(i32 %47)
%49 = tail call i32 @bin2int(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0))
%50 = icmp eq i32 %49, -12
%51 = zext i1 %50 to i32
%52 = tail call i32 @assert(i32 %51)
ret void
}