#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*/ dprintf(char *, ...);
void PrintSOF(const unsigned char *stream) {
  int width;
  int height;
  int nr_components;
  int precision;
  const char *nr_components_to_string[] = {"????", "Grayscale", "????", "YCbCr",
                                           "CYMK"};
  precision = stream[2];
  height = (((stream + 3)[0] << 8) | (stream + 3)[1]);
  width = (((stream + 5)[0] << 8) | (stream + 5)[1]);
  nr_components = stream[7];
  dprintf("> SOF marker\n");
  dprintf("Size:%dx%d nr_components:%d (%s)  precision:%d\n", width, height,
          nr_components, nr_components_to_string[nr_components], precision);
}


x86 assembly (clang, -O0):
<PrintSOF>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1030 <memset@plt>
lea    0xebd(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xeb7(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xea7(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xeab(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xea6(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x2(%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x3(%rax),%eax
shl    $0x8,%eax
mov    -0x8(%rbp),%rcx
movzbl 0x4(%rcx),%ecx
or     %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x5(%rax),%eax
shl    $0x8,%eax
mov    -0x8(%rbp),%rcx
movzbl 0x6(%rcx),%ecx
or     %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x7(%rax),%eax
mov    %eax,-0x14(%rbp)
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1040 <dprintf@plt>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
movslq -0x14(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%r8
mov    -0x18(%rbp),%r9d
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1040 <dprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintSOF>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xedf(%rip),%rax
mov    %rax,(%rsp)
lea    0xed9(%rip),%rcx
mov    %rcx,0x8(%rsp)
mov    %rax,0x10(%rsp)
lea    0xed2(%rip),%rax
mov    %rax,0x18(%rsp)
lea    0xecc(%rip),%rax
mov    %rax,0x20(%rsp)
movzbl 0x2(%rdi),%r14d
movzwl 0x3(%rdi),%ebp
shl    $0x10,%ebp
bswap  %ebp
movzwl 0x5(%rdi),%ebx
shl    $0x10,%ebx
bswap  %ebx
movzbl 0x7(%rdi),%r15d
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1030 <dprintf@plt>
mov    (%rsp,%r15,8),%r8
lea    0xea5(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r15d,%ecx
mov    %r14d,%r9d
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <dprintf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"????\00"
@.str.1 = [10 x i8] c"Grayscale\00"
@.str.2 = [6 x i8] c"YCbCr\00"
@.str.3 = [5 x i8] c"CYMK\00"
@.str.4 = [14 x i8] c"> SOF marker\0A\00"
@.str.5 = [48 x i8] c"Size:%dx%d nr_components:%d (%s) precision:%d\0A\00"
define void @PrintSOF(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [5 x i8*]
store i8* %0, i8** %2
%8 = bitcast [5 x i8*]* %7 to i8*
%9 = bitcast i8* %8 to [5 x i8*]*
%10 = getelementptr inbounds [5 x i8*], [5 x i8*]* %9, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8** %10
%11 = getelementptr inbounds [5 x i8*], [5 x i8*]* %9, i32 0, i32 1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i32 0, i32 0), i8** %11
%12 = getelementptr inbounds [5 x i8*], [5 x i8*]* %9, i32 0, i32 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8** %12
%13 = getelementptr inbounds [5 x i8*], [5 x i8*]* %9, i32 0, i32 3
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8** %13
%14 = getelementptr inbounds [5 x i8*], [5 x i8*]* %9, i32 0, i32 4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8** %14
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i64 2
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
store i32 %18, i32* %6
%19 = load i8*, i8** %2
%20 = getelementptr inbounds i8, i8* %19, i64 3
%21 = getelementptr inbounds i8, i8* %20, i64 0
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = shl i32 %23, 8
%25 = load i8*, i8** %2
%26 = getelementptr inbounds i8, i8* %25, i64 3
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = or i32 %24, %29
store i32 %30, i32* %4
%31 = load i8*, i8** %2
%32 = getelementptr inbounds i8, i8* %31, i64 5
%33 = getelementptr inbounds i8, i8* %32, i64 0
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = shl i32 %35, 8
%37 = load i8*, i8** %2
%38 = getelementptr inbounds i8, i8* %37, i64 5
%39 = getelementptr inbounds i8, i8* %38, i64 1
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = or i32 %36, %41
store i32 %42, i32* %3
%43 = load i8*, i8** %2
%44 = getelementptr inbounds i8, i8* %43, i64 7
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
store i32 %46, i32* %5
%47 = call i32 (i8*, ...) @dprintf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%48 = load i32, i32* %3
%49 = load i32, i32* %4
%50 = load i32, i32* %5
%51 = load i32, i32* %5
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [5 x i8*], [5 x i8*]* %7, i64 0, i64 %52
%54 = load i8*, i8** %53
%55 = load i32, i32* %6
%56 = call i32 (i8*, ...) @dprintf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i32 %48, i32 %49, i32 %50, i8* %54, i32 %55)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"????\00"
@.str.1 = [10 x i8] c"Grayscale\00"
@.str.2 = [6 x i8] c"YCbCr\00"
@.str.3 = [5 x i8] c"CYMK\00"
@.str.4 = [14 x i8] c"> SOF marker\0A\00"
@.str.5 = [48 x i8] c"Size:%dx%d nr_components:%d (%s) precision:%d\0A\00"
define void @PrintSOF(i8* nocapture %0) {
%2 = alloca [5 x i8*]
%3 = bitcast [5 x i8*]* %2 to i8*
%4 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 3
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds i8, i8* %0, i64 2
%10 = load i8, i8* %9
%11 = zext i8 %10 to i32
%12 = getelementptr inbounds i8, i8* %0, i64 3
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = shl nuw nsw i32 %14, 8
%16 = getelementptr inbounds i8, i8* %0, i64 4
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = or i32 %15, %18
%20 = getelementptr inbounds i8, i8* %0, i64 5
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = shl nuw nsw i32 %22, 8
%24 = getelementptr inbounds i8, i8* %0, i64 6
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = or i32 %23, %26
%28 = getelementptr inbounds i8, i8* %0, i64 7
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = tail call i32 (i8*, ...) @dprintf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%32 = zext i8 %29 to i64
%33 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 %32
%34 = load i8*, i8** %33
%35 = tail call i32 (i8*, ...) @dprintf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i32 %27, i32 %19, i32 %30, i8* %34, i32 %11)
ret void
}