#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, char);
long ntohl(long);
int parse_picture_size(char *buffer, size_t buffer_size) {
  long int size;
  if (buffer_size != 7)
    error(1, 0, "%s.%d: Invalid picture size buffer size: %d",
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/kobolt/polaroid-320/refs/heads/master/"
          "main.c",
          122, buffer_size);
  if (buffer[0] != 0x06)
    error(0, 0, "%s.%d: Wrong picture size header: 0x%02X",
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/kobolt/polaroid-320/refs/heads/master/"
          "main.c",
          126, buffer[0]);
  size = ntohl(*(long int *)&buffer[1]);
  return size;
}


x86 assembly (clang, -O0):
<parse_picture_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x7,-0x10(%rbp)
je     1163 <parse_picture_size+0x43>
mov    -0x10(%rbp),%rax
mov    $0x1,%edi
xor    %esi,%esi
lea    0xeb3(%rip),%rdx
lea    0xed8(%rip),%rcx
mov    $0x7a,%r8d
movsbl %al,%r9d
call   1030 <error@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x6,%eax
je     1198 <parse_picture_size+0x78>
mov    -0x8(%rbp),%rax
xor    %esi,%esi
lea    0xf33(%rip),%rdx
lea    0xea5(%rip),%rcx
mov    $0x7e,%r8d
mov    %esi,%edi
movsbl (%rax),%r9d
call   1030 <error@plt>
mov    -0x8(%rbp),%rax
mov    0x1(%rax),%rdi
call   1040 <ntohl@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_picture_size>:
push   %rbx
mov    %rdi,%rbx
cmp    $0x7,%rsi
je     114e <parse_picture_size+0x2e>
movsbl %sil,%r9d
lea    0xecb(%rip),%rdx
lea    0xef0(%rip),%rcx
mov    $0x1,%edi
xor    %esi,%esi
mov    $0x7a,%r8d
call   1030 <error@plt>
mov    (%rbx),%al
cmp    $0x6,%al
je     1175 <parse_picture_size+0x55>
movsbl %al,%r9d
lea    0xf54(%rip),%rdx
lea    0xec6(%rip),%rcx
xor    %edi,%edi
xor    %esi,%esi
mov    $0x7e,%r8d
call   1030 <error@plt>
mov    0x1(%rbx),%rdi
pop    %rbx
jmp    1040 <ntohl@plt>

LLVM IR (-O0):
@.str = [44 x i8] c"%s.%d: Invalid picture size buffer size: %d\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/main.c\00"
@.str.2 = [41 x i8] c"%s.%d: Wrong picture size header: 0x%02X\00"
define i32 @parse_picture_size(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
%6 = load i64, i64* %4
%7 = icmp ne i64 %6, 7
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i64, i64* %4
%10 = trunc i64 %9 to i8
%11 = call i32 @error(i32 1, i32 0, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 122, i8 signext %10)
br label %12
12: ; preds = %8, %2
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 6
br i1 %17, label %18, label %23
18: ; preds = %12
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = call i32 @error(i32 0, i32 0, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 126, i8 signext %21)
br label %23
23: ; preds = %18, %12
%24 = load i8*, i8** %3
%25 = getelementptr inbounds i8, i8* %24, i64 1
%26 = bitcast i8* %25 to i64*
%27 = load i64, i64* %26
%28 = call i64 @ntohl(i64 %27)
store i64 %28, i64* %5
%29 = load i64, i64* %5
%30 = trunc i64 %29 to i32
ret i32 %30
}

LLVM IR (-O2):
@.str = [44 x i8] c"%s.%d: Invalid picture size buffer size: %d\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/main.c\00"
@.str.2 = [41 x i8] c"%s.%d: Wrong picture size header: 0x%02X\00"
define i32 @parse_picture_size(i8* nocapture %0, i64 %1) {
%3 = icmp eq i64 %1, 7
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = trunc i64 %1 to i8
%6 = tail call i32 @error(i32 1, i32 0, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 122, i8 signext %5)
br label %7
7: ; preds = %4, %2
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 6
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 @error(i32 0, i32 0, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 126, i8 signext %8)
br label %12
12: ; preds = %10, %7
%13 = getelementptr inbounds i8, i8* %0, i64 1
%14 = bitcast i8* %13 to i64*
%15 = load i64, i64* %14
%16 = tail call i64 @ntohl(i64 %15)
%17 = trunc i64 %16 to i32
ret i32 %17
}