#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*/ printf(char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ zipadjust(char *, char *, int);
int main(int argc, char *argv[]) {
  if (argc >= 3) {
    if ((argc >= 4) && (strcmp(argv[1], "--decompress") == 0)) {
      zipadjust(argv[2], argv[3], 1);
      return 0;
    } else {
      zipadjust(argv[1], argv[2], 0);
      return 0;
    }
  }
  printf("zipadjust - Copyright (c) 2013 Jorrit Jongma (Chainfire)\n");
  printf("\n");
  printf("Usage: zipadjust [--decompress] input.zip output.zip\n");
  printf("\n");
  printf(
      "Rewrites a zipfile removing all extra fields and comments (this "
      "includes the signapk whole-file signature), and synchronizing local "
      "headers with the central directory so no data descriptors are needed "
      "anymore. Optionally, the output zip is converted to only use STORE.\n");
  printf("\n");
  printf("Written to work specifically with Android OTA zip files, and does "
         "not cope with all possible zip file features and formats.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jl     11c1 <main+0x91>
cmpl   $0x4,-0x8(%rbp)
jl     119e <main+0x6e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe97(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    119e <main+0x6e>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
mov    $0x1,%edx
call   1030 <zipadjust@plt>
movl   $0x0,-0x4(%rbp)
jmp    121c <main+0xec>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
xor    %edx,%edx
call   1030 <zipadjust@plt>
movl   $0x0,-0x4(%rbp)
jmp    121c <main+0xec>
lea    0xe45(%rip),%rdi
call   1040 <printf@plt>
lea    0xe71(%rip),%rdi
call   1040 <printf@plt>
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
lea    0xe59(%rip),%rdi
call   1040 <printf@plt>
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
lea    0xe41(%rip),%rdi
call   1040 <printf@plt>
lea    0xf7b(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x3,%edi
jl     1171 <main+0x31>
mov    %rsi,%rbx
je     1160 <main+0x20>
mov    0x8(%rbx),%rdi
lea    0xeaa(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11c3 <main+0x83>
mov    0x8(%rbx),%rdi
mov    0x10(%rbx),%rsi
xor    %edx,%edx
call   1050 <zipadjust@plt>
jmp    11bf <main+0x7f>
lea    0xe95(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xeb8(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xed7(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xfce(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
mov    $0x1,%edx
call   1050 <zipadjust@plt>
jmp    11bf <main+0x7f>

LLVM IR (-O0):
@.str = [13 x i8] c"--decompress\00"
@.str.1 = [58 x i8] c"zipadjust - Copyright (c) 2013 Jorrit Jongma (Chainfire)\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [54 x i8] c"Usage: zipadjust [--decompress] input.zip output.zip\0A\00"
@.str.4 = [270 x i8] c"Rewrites a zipfile removing all extra fields and comments (this includes the signapk whole-file signature), and synchronizing local headers with the central directory so no data descriptors are needed anymore. Optionally, the output zip is converted to only use STORE.\0A\00"
@.str.5 = [125 x i8] c"Written to work specifically with Android OTA zip files, and does not cope with all possible zip file features and formats.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp sge i32 %6, 3
br i1 %7, label %8, label %33
8: ; preds = %2
%9 = load i32, i32* %4
%10 = icmp sge i32 %9, 4
br i1 %10, label %11, label %25
11: ; preds = %8
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %25
17: ; preds = %11
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 3
%23 = load i8*, i8** %22
%24 = call i32 @zipadjust(i8* %20, i8* %23, i32 1)
store i32 0, i32* %3
br label %41
25: ; preds = %11, %8
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i32 @zipadjust(i8* %28, i8* %31, i32 0)
store i32 0, i32* %3
br label %41
33: ; preds = %2
%34 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
%35 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%36 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0))
%37 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%38 = call i32 @printf(i8* getelementptr inbounds ([270 x i8], [270 x i8]* @.str.4, i64 0, i64 0))
%39 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%40 = call i32 @printf(i8* getelementptr inbounds ([125 x i8], [125 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %3
br label %41
41: ; preds = %33, %25, %17
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@.str = [13 x i8] c"--decompress\00"
@str = [57 x i8] c"zipadjust - Copyright (c) 2013 Jorrit Jongma (Chainfire)\00"
@str.6 = [53 x i8] c"Usage: zipadjust [--decompress] input.zip output.zip\00"
@str.7 = [269 x i8] c"Rewrites a zipfile removing all extra fields and comments (this includes the signapk whole-file signature), and synchronizing local headers with the central directory so no data descriptors are needed anymore. Optionally, the output zip is converted to only use STORE.\00"
@str.8 = [124 x i8] c"Written to work specifically with Android OTA zip files, and does not cope with all possible zip file features and formats.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 2
br i1 %3, label %4, label %23
4: ; preds = %2
%5 = icmp eq i32 %0, 3
br i1 %5, label %17, label %6
6: ; preds = %4
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %6
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8*, i8** %1, i64 3
%15 = load i8*, i8** %14
%16 = tail call i32 @zipadjust(i8* %13, i8* %15, i32 1)
br label %31
17: ; preds = %6, %4
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = tail call i32 @zipadjust(i8* %19, i8* %21, i32 0)
br label %31
23: ; preds = %2
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str, i64 0, i64 0))
%25 = tail call i32 @putchar(i32 10)
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.6, i64 0, i64 0))
%27 = tail call i32 @putchar(i32 10)
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([269 x i8], [269 x i8]* @str.7, i64 0, i64 0))
%29 = tail call i32 @putchar(i32 10)
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([124 x i8], [124 x i8]* @str.8, i64 0, i64 0))
br label %31
31: ; preds = %23, %17, %11
ret i32 0
}