#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 */
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ printf(char *);
int check_id2_info(char *id2info) {
  int textlength = 0;
  int imagelength = 0;
  if (memcmp(id2info, "\x00\x00\x90", 3)) {
    printf("id2_head_err:\n");
    return -1;
  }
  textlength = (id2info[3] << 8) + id2info[3 + 1];
  if (textlength != 256) {
    printf("textlength err \n");
    return -1;
  }
  imagelength = (id2info[3 + 2] << 8) + id2info[3 + 3];
  if (imagelength != 1024) {
    printf("imagelength err \n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<check_id2_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xebb(%rip),%rsi
mov    $0x3,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     1171 <check_id2_info+0x51>
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f2 <check_id2_info+0xd2>
mov    -0x10(%rbp),%rax
movsbl 0x3(%rax),%eax
shl    $0x8,%eax
mov    -0x10(%rbp),%rcx
movsbl 0x4(%rcx),%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
je     11ae <check_id2_info+0x8e>
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f2 <check_id2_info+0xd2>
mov    -0x10(%rbp),%rax
movsbl 0x5(%rax),%eax
shl    $0x8,%eax
mov    -0x10(%rbp),%rcx
movsbl 0x6(%rcx),%ecx
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x400,-0x18(%rbp)
je     11eb <check_id2_info+0xcb>
lea    0xe4a(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f2 <check_id2_info+0xd2>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_id2_info>:
push   %rbx
mov    %rdi,%rbx
lea    0xed5(%rip),%rsi
mov    $0x3,%edx
call   1040 <memcmp@plt>
test   %rax,%rax
je     1143 <check_id2_info+0x23>
lea    0xee4(%rip),%rdi
jmp    117f <check_id2_info+0x5f>
movsbl 0x3(%rbx),%eax
shl    $0x8,%eax
movsbl 0x4(%rbx),%ecx
add    %eax,%ecx
cmp    $0x100,%ecx
jne    1178 <check_id2_info+0x58>
movsbl 0x5(%rbx),%eax
shl    $0x8,%eax
movsbl 0x6(%rbx),%ecx
add    %eax,%ecx
xor    %eax,%eax
cmp    $0x400,%ecx
je     1189 <check_id2_info+0x69>
lea    0xe8e(%rip),%rdi
jmp    117f <check_id2_info+0x5f>
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"\00\00\90\00"
@.str.1 = [15 x i8] c"id2_head_err:\0A\00"
@.str.2 = [17 x i8] c"textlength err \0A\00"
@.str.3 = [18 x i8] c"imagelength err \0A\00"
define i32 @check_id2_info(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
store i32 0, i32* %5
%6 = load i8*, i8** %3
%7 = call i64 @memcmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %2
br label %42
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 3
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = shl i32 %15, 8
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 4
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = add nsw i32 %16, %20
store i32 %21, i32* %4
%22 = load i32, i32* %4
%23 = icmp ne i32 %22, 256
br i1 %23, label %24, label %26
24: ; preds = %11
%25 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %2
br label %42
26: ; preds = %11
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i64 5
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = shl i32 %30, 8
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i64 6
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = add nsw i32 %31, %35
store i32 %36, i32* %5
%37 = load i32, i32* %5
%38 = icmp ne i32 %37, 1024
br i1 %38, label %39, label %41
39: ; preds = %26
%40 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %2
br label %42
41: ; preds = %26
store i32 0, i32* %2
br label %42
42: ; preds = %41, %39, %24, %9
%43 = load i32, i32* %2
ret i32 %43
}

LLVM IR (-O2):
@.str = [4 x i8] c"\00\00\90\00"
@str = [17 x i8] c"imagelength err \00"
@str.4 = [16 x i8] c"textlength err \00"
@str.5 = [14 x i8] c"id2_head_err:\00"
define i32 @check_id2_info(i8* %0) {
%2 = tail call i64 @memcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %24
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 3
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = shl nsw i32 %7, 8
%9 = getelementptr inbounds i8, i8* %0, i64 4
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = add nsw i32 %8, %11
%13 = icmp eq i32 %12, 256
br i1 %13, label %14, label %24
14: ; preds = %4
%15 = getelementptr inbounds i8, i8* %0, i64 5
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = shl nsw i32 %17, 8
%19 = getelementptr inbounds i8, i8* %0, i64 6
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = add nsw i32 %18, %21
%23 = icmp eq i32 %22, 1024
br i1 %23, label %27, label %24
24: ; preds = %14, %4, %1
%25 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.5, i64 0, i64 0), %1 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @str.4, i64 0, i64 0), %4 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0), %14 ]
%26 = tail call i32 @puts(i8* dereferenceable(1) %25)
br label %27
27: ; preds = %24, %14
%28 = phi i32 [ 0, %14 ], [ -1, %24 ]
ret i32 %28
}