#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);
scalar_t__ isprint(char);
int /*<<< orphan*/ printf(char *, ...);
int parse_camera_info(char *buffer, size_t buffer_size) {
  int i;
  if (buffer_size != 14)
    error(1, 0, "%s.%d: Invalid camera info 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",
          58, buffer_size);
  if (buffer[0] != 0x00)
    error(0, 0, "%s.%d: Wrong camera info 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",
          62, buffer[0]);
  printf("Camera information: ");
  for (i = 1; i < buffer_size; i++) {
    if (isprint(buffer[i]))
      printf("%c", buffer[i]);
    else
      printf(" (0x%02X)", (unsigned char)buffer[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<parse_camera_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0xe,-0x10(%rbp)
je     1173 <parse_camera_info+0x43>
mov    -0x10(%rbp),%rax
mov    $0x1,%edi
xor    %esi,%esi
lea    0xea3(%rip),%rdx
lea    0xec7(%rip),%rcx
mov    $0x3a,%r8d
movsbl %al,%r9d
call   1050 <error@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11a8 <parse_camera_info+0x78>
mov    -0x8(%rbp),%rax
xor    %esi,%esi
lea    0xf22(%rip),%rdx
lea    0xe94(%rip),%rcx
mov    $0x3e,%r8d
mov    %esi,%edi
movsbl (%rax),%r9d
call   1050 <error@plt>
lea    0xf2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1232 <parse_camera_info+0x102>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isprint@plt>
cmp    $0x0,%rax
je     1205 <parse_camera_info+0xd5>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xef6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121f <parse_camera_info+0xef>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1224 <parse_camera_info+0xf4>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11bd <parse_camera_info+0x8d>
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_camera_info>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
cmp    $0xe,%rsi
je     1178 <parse_camera_info+0x38>
movsbl %r14b,%r9d
lea    0xea1(%rip),%rdx
lea    0xec5(%rip),%rcx
mov    $0x1,%edi
xor    %esi,%esi
mov    $0x3a,%r8d
call   1060 <error@plt>
mov    (%r12),%al
test   %al,%al
je     11a1 <parse_camera_info+0x61>
movsbl %al,%r9d
lea    0xf27(%rip),%rdx
lea    0xe99(%rip),%rcx
xor    %edi,%edi
xor    %esi,%esi
mov    $0x3e,%r8d
call   1060 <error@plt>
lea    0xf32(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%r14
jb     1202 <parse_camera_info+0xc2>
mov    $0x1,%ebx
lea    0xf2e(%rip),%r15
jmp    11e7 <parse_camera_info+0xa7>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl %dil,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
je     1202 <parse_camera_info+0xc2>
movsbl (%r12,%rbx,1),%edi
call   1050 <isprint@plt>
movsbl (%r12,%rbx,1),%edi
test   %rax,%rax
je     11d0 <parse_camera_info+0x90>
call   1030 <putchar@plt>
jmp    11de <parse_camera_info+0x9e>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [43 x i8] c"%s.%d: Invalid camera info 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 = [40 x i8] c"%s.%d: Wrong camera info header: 0x%02X\00"
@.str.3 = [21 x i8] c"Camera information: \00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [10 x i8] c" (0x%02X)\00"
@.str.6 = [2 x i8] c"\0A\00"
define i32 @parse_camera_info(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
store i8* %0, i8** %3
store i64 %1, i64* %4
%6 = load i64, i64* %4
%7 = icmp ne i64 %6, 14
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 ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 58, 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, 0
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 ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 62, i8 signext %21)
br label %23
23: ; preds = %18, %12
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %5
br label %25
25: ; preds = %55, %23
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = load i64, i64* %4
%29 = icmp ult i64 %27, %28
br i1 %29, label %30, label %58
30: ; preds = %25
%31 = load i8*, i8** %3
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = call i64 @isprint(i8 signext %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %46
38: ; preds = %30
%39 = load i8*, i8** %3
%40 = load i32, i32* %5
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %44)
br label %54
46: ; preds = %30
%47 = load i8*, i8** %3
%48 = load i32, i32* %5
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %52)
br label %54
54: ; preds = %46, %38
br label %55
55: ; preds = %54
%56 = load i32, i32* %5
%57 = add nsw i32 %56, 1
store i32 %57, i32* %5
br label %25
58: ; preds = %25
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [43 x i8] c"%s.%d: Invalid camera info 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 = [40 x i8] c"%s.%d: Wrong camera info header: 0x%02X\00"
@.str.3 = [21 x i8] c"Camera information: \00"
@.str.5 = [10 x i8] c" (0x%02X)\00"
define i32 @parse_camera_info(i8* nocapture %0, i64 %1) {
%3 = icmp eq i64 %1, 14
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 ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 58, i8 signext %5)
br label %7
7: ; preds = %4, %2
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 @error(i32 0, i32 0, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 62, i8 signext %8)
br label %12
12: ; preds = %10, %7
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp ugt i64 %1, 1
br i1 %14, label %15, label %31
15: ; preds = %12, %28
%16 = phi i64 [ %29, %28 ], [ 1, %12 ]
%17 = getelementptr inbounds i8, i8* %0, i64 %16
%18 = load i8, i8* %17
%19 = tail call i64 @isprint(i8 signext %18)
%20 = icmp eq i64 %19, 0
%21 = load i8, i8* %17
br i1 %20, label %25, label %22
22: ; preds = %15
%23 = sext i8 %21 to i32
%24 = tail call i32 @putchar(i32 %23)
br label %28
25: ; preds = %15
%26 = zext i8 %21 to i32
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %22, %25
%29 = add nuw i64 %16, 1
%30 = icmp eq i64 %29, %1
br i1 %30, label %31, label %15
31: ; preds = %28, %12
%32 = tail call i32 @putchar(i32 10)
ret i32 0
}