#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*/ error(int, int /*<<< orphan*/, char *, char *, int);
int next_bit(int (*)());
int power_of_two(int);
int receive(int(next_byte(void)), int category) {
  int bit;
  int value = 0;
  if (category == 0)
    return 0;
  while ((bit = next_bit(next_byte)) != -1) {
    value += (bit * power_of_two(category - 1));
    category--;
    if (category <= 0)
      break;
  }
  if (bit == -1)
    error(1, 0, "%s.%d: Unexpected EOF.",
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/kobolt/polaroid-320/refs/heads/master/"
          "jpeg.c",
          90);
  return value;
}


x86 assembly (clang, -O0):
<receive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    115c <receive+0x2c>
movl   $0x0,-0x4(%rbp)
jmp    11e2 <receive+0xb2>
jmp    1161 <receive+0x31>
mov    -0x10(%rbp),%rdi
call   1030 <next_bit@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
je     11b2 <receive+0x82>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
sub    $0x1,%edi
call   1040 <power_of_two@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
imul   %ecx,%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     11ad <receive+0x7d>
jmp    11b2 <receive+0x82>
jmp    1161 <receive+0x31>
cmpl   $0xffffffff,-0x18(%rbp)
jne    11dc <receive+0xac>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xe36(%rip),%rdx
lea    0xe46(%rip),%rcx
mov    $0x5a,%r8d
call   1050 <error@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<receive>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
je     1177 <receive+0x47>
mov    %esi,%ebx
mov    %rdi,%r14
add    $0x1,%ebx
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <next_bit@plt>
cmp    $0xffffffff,%eax
je     117c <receive+0x4c>
mov    %eax,%ebp
lea    -0x2(%rbx),%edi
call   1040 <power_of_two@plt>
imul   %ebp,%eax
add    %eax,%r15d
add    $0xffffffff,%ebx
cmp    $0x2,%ebx
jge    1150 <receive+0x20>
jmp    119c <receive+0x6c>
xor    %r15d,%r15d
jmp    119c <receive+0x6c>
lea    0xe7d(%rip),%rdx
lea    0xe8d(%rip),%rcx
mov    $0x1,%edi
xor    %esi,%esi
mov    $0x5a,%r8d
call   1050 <error@plt>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"%s.%d: Unexpected EOF.\00"
@.str.1 = [135 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/kobolt/polaroid-320/refs/heads/master/jpeg.c\00"
define i32 @receive(i32 ()* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32 ()*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 ()* %0, i32 ()** %4
store i32 %1, i32* %5
store i32 0, i32* %7
%8 = load i32, i32* %5
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 0, i32* %3
br label %38
11: ; preds = %2
br label %12
12: ; preds = %30, %11
%13 = load i32 ()*, i32 ()** %4
%14 = bitcast i32 ()* %13 to i32 (...)*
%15 = call i32 @next_bit(i32 (...)* %14)
store i32 %15, i32* %6
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %31
17: ; preds = %12
%18 = load i32, i32* %6
%19 = load i32, i32* %5
%20 = sub nsw i32 %19, 1
%21 = call i32 @power_of_two(i32 %20)
%22 = mul nsw i32 %18, %21
%23 = load i32, i32* %7
%24 = add nsw i32 %23, %22
store i32 %24, i32* %7
%25 = load i32, i32* %5
%26 = add nsw i32 %25, -1
store i32 %26, i32* %5
%27 = load i32, i32* %5
%28 = icmp sle i32 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %17
br label %31
30: ; preds = %17
br label %12
31: ; preds = %29, %12
%32 = load i32, i32* %6
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call i32 @error(i32 1, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 90)
br label %36
36: ; preds = %34, %31
%37 = load i32, i32* %7
store i32 %37, i32* %3
br label %38
38: ; preds = %36, %10
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [23 x i8] c"%s.%d: Unexpected EOF.\00"
@.str.1 = [135 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/kobolt/polaroid-320/refs/heads/master/jpeg.c\00"
define i32 @receive(i32 ()* %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %19, label %4
4: ; preds = %2
%5 = bitcast i32 ()* %0 to i32 (...)*
br label %6
6: ; preds = %4, %11
%7 = phi i32 [ %12, %11 ], [ %1, %4 ]
%8 = phi i32 [ %15, %11 ], [ 0, %4 ]
%9 = tail call i32 @next_bit(i32 (...)* %5)
%10 = icmp eq i32 %9, -1
br i1 %10, label %17, label %11
11: ; preds = %6
%12 = add nsw i32 %7, -1
%13 = tail call i32 @power_of_two(i32 %12)
%14 = mul nsw i32 %13, %9
%15 = add nsw i32 %14, %8
%16 = icmp slt i32 %7, 2
br i1 %16, label %19, label %6
17: ; preds = %6
%18 = tail call i32 @error(i32 1, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 90)
br label %19
19: ; preds = %11, %17, %2
%20 = phi i32 [ 0, %2 ], [ %8, %17 ], [ %15, %11 ]
ret i32 %20
}