#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);
int parse_camera_state(char *buffer, size_t buffer_size) {
  if (buffer_size != 24)
    error(1, 0, "%s.%d: Invalid camera state 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",
          82, buffer_size);
  if (buffer[0] != 0x02)
    error(0, 0, "%s.%d: Wrong camera state 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",
          86, buffer[0]);
  return 0;
}


x86 assembly (clang, -O0):
<parse_camera_state>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x18,-0x10(%rbp)
je     1153 <parse_camera_state+0x43>
mov    -0x10(%rbp),%rax
mov    $0x1,%edi
xor    %esi,%esi
lea    0xec3(%rip),%rdx
lea    0xee8(%rip),%rcx
mov    $0x52,%r8d
movsbl %al,%r9d
call   1030 <error@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2,%eax
je     1188 <parse_camera_state+0x78>
mov    -0x8(%rbp),%rax
xor    %esi,%esi
lea    0xf43(%rip),%rdx
lea    0xeb5(%rip),%rcx
mov    $0x56,%r8d
mov    %esi,%edi
movsbl (%rax),%r9d
call   1030 <error@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_camera_state>:
push   %rbx
mov    %rdi,%rbx
cmp    $0x18,%rsi
je     113e <parse_camera_state+0x2e>
movsbl %sil,%r9d
lea    0xedb(%rip),%rdx
lea    0xf00(%rip),%rcx
mov    $0x1,%edi
xor    %esi,%esi
mov    $0x52,%r8d
call   1030 <error@plt>
mov    (%rbx),%al
cmp    $0x2,%al
je     1165 <parse_camera_state+0x55>
movsbl %al,%r9d
lea    0xf64(%rip),%rdx
lea    0xed6(%rip),%rcx
xor    %edi,%edi
xor    %esi,%esi
mov    $0x56,%r8d
call   1030 <error@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [44 x i8] c"%s.%d: Invalid camera state 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 camera state header: 0x%02X\00"
define i32 @parse_camera_state(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
%5 = load i64, i64* %4
%6 = icmp ne i64 %5, 24
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i64, i64* %4
%9 = trunc i64 %8 to i8
%10 = 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 82, i8 signext %9)
br label %11
11: ; preds = %7, %2
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 2
br i1 %16, label %17, label %22
17: ; preds = %11
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 0
%20 = load i8, i8* %19
%21 = 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 86, i8 signext %20)
br label %22
22: ; preds = %17, %11
ret i32 0
}

LLVM IR (-O2):
@.str = [44 x i8] c"%s.%d: Invalid camera state 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 camera state header: 0x%02X\00"
define i32 @parse_camera_state(i8* nocapture %0, i64 %1) {
%3 = icmp eq i64 %1, 24
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 82, i8 signext %5)
br label %7
7: ; preds = %4, %2
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 2
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 86, i8 signext %8)
br label %12
12: ; preds = %10, %7
ret i32 0
}