#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, unsigned int, unsigned int);
int /*<<< orphan*/ stderr;
scalar_t__ strncmp(char const *, char *, int);
int progress_update(unsigned int pos, unsigned int size, const char *buf,
                    unsigned int len) {
  printf("Processing ZIP... %d/%d\r", pos, size);
  if (buf && len && pos == 0x8000) {
    if (strncmp(buf, "PK", 2)) {
      fprintf(stderr, "Invalid zip file - aborting!\n");
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<progress_update>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xeae(%rip),%rdi
call   1040 <printf@plt>
cmpq   $0x0,-0x18(%rbp)
je     11be <progress_update+0x8e>
cmpl   $0x0,-0x1c(%rbp)
je     11be <progress_update+0x8e>
cmpl   $0x8000,-0x8(%rbp)
jne    11be <progress_update+0x8e>
mov    -0x18(%rbp),%rdi
lea    0xe95(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11b9 <progress_update+0x89>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
lea    0xe74(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c5 <progress_update+0x95>
jmp    11be <progress_update+0x8e>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<progress_update>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%rbx
mov    %esi,%edx
mov    %edi,%ebp
lea    0xeb8(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
mov    $0x1,%r15d
cmp    $0x8000,%ebp
jne    1198 <progress_update+0x68>
test   %rbx,%rbx
je     1198 <progress_update+0x68>
test   %r14d,%r14d
je     1198 <progress_update+0x68>
lea    0xeab(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1198 <progress_update+0x68>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe8c(%rip),%rsi
call   1050 <fprintf@plt>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Processing ZIP... %d/%d\0D\00"
@.str.1 = [3 x i8] c"PK\00"
@stderr = global i32 0
@.str.2 = [30 x i8] c"Invalid zip file - aborting!\0A\00"
define i32 @progress_update(i32 %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%10 = load i32, i32* %6
%11 = load i32, i32* %7
%12 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11)
%13 = load i8*, i8** %8
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %29
15: ; preds = %4
%16 = load i32, i32* %9
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %29
18: ; preds = %15
%19 = load i32, i32* %6
%20 = icmp eq i32 %19, 32768
br i1 %20, label %21, label %29
21: ; preds = %18
%22 = load i8*, i8** %8
%23 = call i64 @strncmp(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %5
br label %30
28: ; preds = %21
br label %29
29: ; preds = %28, %18, %15, %4
store i32 1, i32* %5
br label %30
30: ; preds = %29, %25
%31 = load i32, i32* %5
ret i32 %31
}

LLVM IR (-O2):
@.str = [25 x i8] c"Processing ZIP... %d/%d\0D\00"
@.str.1 = [3 x i8] c"PK\00"
@stderr = global i32 0
@.str.2 = [30 x i8] c"Invalid zip file - aborting!\0A\00"
define i32 @progress_update(i32 %0, i32 %1, i8* %2, i32 %3) {
%5 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
%6 = icmp ne i8* %2, null
%7 = icmp ne i32 %3, 0
%8 = and i1 %6, %7
%9 = icmp eq i32 %0, 32768
%10 = and i1 %9, %8
br i1 %10, label %11, label %17
11: ; preds = %4
%12 = tail call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%13 = icmp eq i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %17
17: ; preds = %4, %11, %14
%18 = phi i32 [ 0, %14 ], [ 1, %11 ], [ 1, %4 ]
ret i32 %18
}