#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 /*<<< orphan*/ printf(char *, int);
int parse_no_of_pictures(char *buffer, size_t buffer_size) {
  if (buffer[0] != 0x03)
    error(0, 0, "%s.%d: Wrong number of pictures 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",
          102, buffer[0]);
  if (buffer_size > 1) {
    printf("Pictures on camera: %d\n", (int)buffer[1]);
    return buffer[1];
  } else
    error(1, 0, "%s.%d: Number of pictures buffer too small.",
          "/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",
          109);
  return 0;
}


x86 assembly (clang, -O0):
<parse_no_of_pictures>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3,%eax
je     1167 <parse_no_of_pictures+0x47>
mov    -0x10(%rbp),%rax
movsbl (%rax),%r9d
xor    %esi,%esi
lea    0xeaf(%rip),%rdx
lea    0xed7(%rip),%rcx
mov    $0x66,%r8d
mov    %esi,%edi
mov    $0x0,%al
call   1040 <error@plt>
cmpq   $0x1,-0x18(%rbp)
jbe    1196 <parse_no_of_pictures+0x76>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%esi
lea    0xf35(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11bf <parse_no_of_pictures+0x9f>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xf2a(%rip),%rdx
lea    0xe84(%rip),%rcx
mov    $0x6d,%r8d
mov    $0x0,%al
call   1040 <error@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_no_of_pictures>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movsbl (%rdi),%r9d
cmp    $0x3,%r9d
je     1153 <parse_no_of_pictures+0x33>
lea    0xec5(%rip),%rdx
lea    0xeed(%rip),%rcx
xor    %edi,%edi
xor    %esi,%esi
mov    $0x66,%r8d
xor    %eax,%eax
call   1040 <error@plt>
cmp    $0x2,%r14
jb     116f <parse_no_of_pictures+0x4f>
movsbl 0x1(%rbx),%esi
lea    0xf52(%rip),%rdi
call   1030 <printf@plt>
movsbl 0x1(%rbx),%ebx
jmp    1193 <parse_no_of_pictures+0x73>
lea    0xf58(%rip),%rdx
lea    0xeb2(%rip),%rcx
xor    %ebx,%ebx
mov    $0x1,%edi
xor    %esi,%esi
mov    $0x6d,%r8d
xor    %eax,%eax
call   1040 <error@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [47 x i8] c"%s.%d: Wrong number of pictures header: 0x%02X\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 = [24 x i8] c"Pictures on camera: %d\0A\00"
@.str.3 = [44 x i8] c"%s.%d: Number of pictures buffer too small.\00"
define i32 @parse_no_of_pictures(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
%6 = load i8*, i8** %4
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 3
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = call i32 (i32, i32, i8*, i8*, i32, ...) @error(i32 0, i32 0, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 102, i32 %15)
br label %17
17: ; preds = %11, %2
%18 = load i64, i64* %5
%19 = icmp ugt i64 %18, 1
br i1 %19, label %20, label %30
20: ; preds = %17
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
store i32 %29, i32* %3
br label %33
30: ; preds = %17
%31 = call i32 (i32, i32, i8*, i8*, i32, ...) @error(i32 1, i32 0, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 109)
br label %32
32: ; preds = %30
store i32 0, i32* %3
br label %33
33: ; preds = %32, %20
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@.str = [47 x i8] c"%s.%d: Wrong number of pictures header: 0x%02X\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 = [24 x i8] c"Pictures on camera: %d\0A\00"
@.str.3 = [44 x i8] c"%s.%d: Number of pictures buffer too small.\00"
define i32 @parse_no_of_pictures(i8* nocapture %0, i64 %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 3
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = sext i8 %3 to i32
%7 = tail call i32 (i32, i32, i8*, i8*, i32, ...) @error(i32 0, i32 0, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 102, i32 %6)
br label %8
8: ; preds = %5, %2
%9 = icmp ugt i64 %1, 1
br i1 %9, label %10, label %17
10: ; preds = %8
%11 = getelementptr inbounds i8, i8* %0, i64 1
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = load i8, i8* %11
%16 = sext i8 %15 to i32
br label %19
17: ; preds = %8
%18 = tail call i32 (i32, i32, i8*, i8*, i32, ...) @error(i32 1, i32 0, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 109)
br label %19
19: ; preds = %17, %10
%20 = phi i32 [ %16, %10 ], [ 0, %17 ]
ret i32 %20
}