#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 Getc();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ skip(int);
extern void image_attribute(int len) {
  int hlenlo, hlen, hver;
  hlenlo = Getc();
  hlen = Getc() * 256 + hlenlo;
  hver = Getc();
  if (hver == 1) {
    int enc = Getc();
    printf("\t\tImage encoding - %s(enc %d)\n", enc == 1 ? "JPEG" : "Unknown",
           enc);
    printf("\t\tImage data(%d bytes)\n", len - hlen);
    skip(len - 4);
  } else {
    printf("\t\tUnknown header version(ver %d)\n", hver);
    printf("\t\tUnknown data(%d bytes)\n", len - hlen);
    skip(len - 3);
  }
}


x86 assembly (clang, -O0):
<image_attribute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1050 <Getc@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1050 <Getc@plt>
shl    $0x8,%eax
add    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1050 <Getc@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jne    11c0 <image_attribute+0x90>
mov    $0x0,%al
call   1050 <Getc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
lea    0xea7(%rip),%rsi
lea    0xe9b(%rip),%rax
cmp    $0x1,%ecx
cmove  %rax,%rsi
mov    -0x14(%rbp),%edx
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%esi
sub    -0xc(%rbp),%esi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
sub    $0x4,%edi
call   1030 <skip@plt>
jmp    11f0 <image_attribute+0xc0>
mov    -0x10(%rbp),%esi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%esi
sub    -0xc(%rbp),%esi
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
sub    $0x3,%edi
call   1030 <skip@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<image_attribute>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r15d
xor    %eax,%eax
call   1050 <Getc@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1050 <Getc@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1050 <Getc@plt>
cmp    $0x1,%eax
jne    1193 <image_attribute+0x63>
xor    %eax,%eax
call   1050 <Getc@plt>
cmp    $0x1,%eax
lea    0xeb5(%rip),%rcx
lea    0xeb3(%rip),%rsi
cmove  %rcx,%rsi
lea    0xe84(%rip),%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xfffffffc,%ebx
lea    0xe9b(%rip),%rdi
jmp    11af <image_attribute+0x7f>
lea    0xeaa(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xfffffffd,%ebx
lea    0xeb7(%rip),%rdi
shl    $0x8,%ebp
add    %r14d,%ebp
mov    %r15d,%esi
sub    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    %r15d,%ebx
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <skip@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"\09\09Image encoding - %s(enc %d)\0A\00"
@.str.1 = [5 x i8] c"JPEG\00"
@.str.2 = [8 x i8] c"Unknown\00"
@.str.3 = [24 x i8] c"\09\09Image data(%d bytes)\0A\00"
@.str.4 = [34 x i8] c"\09\09Unknown header version(ver %d)\0A\00"
@.str.5 = [26 x i8] c"\09\09Unknown data(%d bytes)\0A\00"
define void @image_attribute(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
%7 = call i32 (...) @Getc()
store i32 %7, i32* %3
%8 = call i32 (...) @Getc()
%9 = mul nsw i32 %8, 256
%10 = load i32, i32* %3
%11 = add nsw i32 %9, %10
store i32 %11, i32* %4
%12 = call i32 (...) @Getc()
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %30
15: ; preds = %1
%16 = call i32 (...) @Getc()
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = icmp eq i32 %17, 1
%19 = zext i1 %18 to i64
%20 = select i1 %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0)
%21 = load i32, i32* %6
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %20, i32 %21)
%23 = load i32, i32* %2
%24 = load i32, i32* %4
%25 = sub nsw i32 %23, %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %2
%28 = sub nsw i32 %27, 4
%29 = call i32 @skip(i32 %28)
br label %40
30: ; preds = %1
%31 = load i32, i32* %5
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %2
%34 = load i32, i32* %4
%35 = sub nsw i32 %33, %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %2
%38 = sub nsw i32 %37, 3
%39 = call i32 @skip(i32 %38)
br label %40
40: ; preds = %30, %15
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c"\09\09Image encoding - %s(enc %d)\0A\00"
@.str.1 = [5 x i8] c"JPEG\00"
@.str.2 = [8 x i8] c"Unknown\00"
@.str.3 = [24 x i8] c"\09\09Image data(%d bytes)\0A\00"
@.str.4 = [34 x i8] c"\09\09Unknown header version(ver %d)\0A\00"
@.str.5 = [26 x i8] c"\09\09Unknown data(%d bytes)\0A\00"
define void @image_attribute(i32 %0) {
%2 = tail call i32 (...) @Getc()
%3 = tail call i32 (...) @Getc()
%4 = tail call i32 (...) @Getc()
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %11
6: ; preds = %1
%7 = tail call i32 (...) @Getc()
%8 = icmp eq i32 %7, 1
%9 = select i1 %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %9, i32 %7)
br label %13
11: ; preds = %1
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %4)
br label %13
13: ; preds = %11, %6
%14 = phi i8* [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), %11 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), %6 ]
%15 = phi i32 [ -3, %11 ], [ -4, %6 ]
%16 = shl nsw i32 %3, 8
%17 = add nsw i32 %16, %2
%18 = sub nsw i32 %0, %17
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %14, i32 %18)
%20 = add nsw i32 %15, %0
%21 = tail call i32 @skip(i32 %20)
ret void
}