#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*/ chdir(char *);
scalar_t__ check_file_size(char *);
int /*<<< orphan*/ chmod(char *, int);
int /*<<< orphan*/ copy_file(char *, char *);
int /*<<< orphan*/ extract_tar_file(char *);
int /*<<< orphan*/ unlink(char *);
int main(int argc, char **argv) {
  if (check_file_size("looper2.ko") < 0 || check_file_size("spi.ko") < 0 ||
      check_file_size("userif") < 0 || check_file_size("lp1-www.tar") < 0) {
    return -1;
  }
  copy_file("looper2.ko", "/j/looper2.ko");
  copy_file("spi.ko", "/j/spi.ko");
  copy_file("userif", "/j/userif");
  chmod("/j/userif", 0755);
  if (check_file_size("uImage") == 0) {
    copy_file("uImage", "/dev/mtdblock1");
  }
  unlink("uImage");
  chdir("/j");
  unlink("html/testpage.html");
  unlink("html/upgrade.html");
  unlink("cgi-bin/test.cgi");
  extract_tar_file("/mnt/lp1-www.tar");
  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)
lea    0xe86(%rip),%rdi
call   1060 <check_file_size@plt>
cmp    $0x0,%rax
jl     11ce <main+0x6e>
lea    0xe7e(%rip),%rdi
call   1060 <check_file_size@plt>
cmp    $0x0,%rax
jl     11ce <main+0x6e>
lea    0xe72(%rip),%rdi
call   1060 <check_file_size@plt>
cmp    $0x0,%rax
jl     11ce <main+0x6e>
lea    0xeb7(%rip),%rdi
call   1060 <check_file_size@plt>
cmp    $0x0,%rax
jge    11da <main+0x7a>
movl   $0xffffffff,-0x4(%rbp)
jmp    129c <main+0x13c>
lea    0xe22(%rip),%rdi
lea    0xe18(%rip),%rsi
call   1030 <copy_file@plt>
lea    0xe1d(%rip),%rdi
lea    0xe13(%rip),%rsi
call   1030 <copy_file@plt>
lea    0xe14(%rip),%rdi
lea    0xe0a(%rip),%rsi
call   1030 <copy_file@plt>
lea    0xdfe(%rip),%rdi
mov    $0x1ed,%esi
call   1070 <chmod@plt>
lea    0xdf7(%rip),%rdi
call   1060 <check_file_size@plt>
cmp    $0x0,%rax
jne    124d <main+0xed>
lea    0xde1(%rip),%rdi
lea    0xde1(%rip),%rsi
call   1030 <copy_file@plt>
lea    0xdce(%rip),%rdi
call   1040 <unlink@plt>
lea    0xdd8(%rip),%rdi
call   1050 <chdir@plt>
lea    0xdcf(%rip),%rdi
call   1040 <unlink@plt>
lea    0xdd6(%rip),%rdi
call   1040 <unlink@plt>
lea    0xddc(%rip),%rdi
call   1040 <unlink@plt>
lea    0xde1(%rip),%rdi
call   1080 <extract_tar_file@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xe9b(%rip),%rdi
call   1060 <check_file_size@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
js     1271 <main+0x111>
lea    0xe8f(%rip),%rdi
call   1060 <check_file_size@plt>
test   %rax,%rax
js     1271 <main+0x111>
lea    0xe84(%rip),%rdi
call   1060 <check_file_size@plt>
test   %rax,%rax
js     1271 <main+0x111>
lea    0xeca(%rip),%rdi
call   1060 <check_file_size@plt>
test   %rax,%rax
js     1271 <main+0x111>
lea    0xe42(%rip),%rdi
lea    0xe38(%rip),%rsi
call   1030 <copy_file@plt>
lea    0xe3d(%rip),%rdi
lea    0xe33(%rip),%rsi
call   1030 <copy_file@plt>
lea    0xe34(%rip),%rdi
lea    0xe2a(%rip),%rbx
mov    %rbx,%rsi
call   1030 <copy_file@plt>
mov    %rbx,%rdi
mov    $0x1ed,%esi
call   1070 <chmod@plt>
lea    0xe18(%rip),%rdi
call   1060 <check_file_size@plt>
test   %rax,%rax
jne    1227 <main+0xc7>
lea    0xe07(%rip),%rdi
lea    0xe07(%rip),%rsi
call   1030 <copy_file@plt>
lea    0xdf4(%rip),%rdi
call   1040 <unlink@plt>
lea    0xdfe(%rip),%rdi
call   1050 <chdir@plt>
lea    0xdf5(%rip),%rdi
call   1040 <unlink@plt>
lea    0xdfc(%rip),%rdi
call   1040 <unlink@plt>
lea    0xe02(%rip),%rdi
call   1040 <unlink@plt>
lea    0xe07(%rip),%rdi
call   1080 <extract_tar_file@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"looper2.ko\00"
@.str.1 = [7 x i8] c"spi.ko\00"
@.str.2 = [7 x i8] c"userif\00"
@.str.3 = [12 x i8] c"lp1-www.tar\00"
@.str.4 = [14 x i8] c"/j/looper2.ko\00"
@.str.5 = [10 x i8] c"/j/spi.ko\00"
@.str.6 = [10 x i8] c"/j/userif\00"
@.str.7 = [7 x i8] c"uImage\00"
@.str.8 = [15 x i8] c"/dev/mtdblock1\00"
@.str.9 = [3 x i8] c"/j\00"
@.str.10 = [19 x i8] c"html/testpage.html\00"
@.str.11 = [18 x i8] c"html/upgrade.html\00"
@.str.12 = [17 x i8] c"cgi-bin/test.cgi\00"
@.str.13 = [17 x i8] c"/mnt/lp1-www.tar\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 = call i64 @check_file_size(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%7 = icmp slt i64 %6, 0
br i1 %7, label %17, label %8
8: ; preds = %2
%9 = call i64 @check_file_size(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp slt i64 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %8
%12 = call i64 @check_file_size(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp slt i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = call i64 @check_file_size(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %14, %11, %8, %2
store i32 -1, i32* %3
br label %34
18: ; preds = %14
%19 = call i32 @copy_file(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 @copy_file(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%21 = call i32 @copy_file(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%22 = call i32 @chmod(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 493)
%23 = call i64 @check_file_size(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %18
%26 = call i32 @copy_file(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %27
27: ; preds = %25, %18
%28 = call i32 @unlink(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%29 = call i32 @chdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%30 = call i32 @unlink(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
%31 = call i32 @unlink(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
%32 = call i32 @unlink(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i64 0, i64 0))
%33 = call i32 @extract_tar_file(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0))
store i32 0, i32* %3
br label %34
34: ; preds = %27, %17
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@.str = [11 x i8] c"looper2.ko\00"
@.str.1 = [7 x i8] c"spi.ko\00"
@.str.2 = [7 x i8] c"userif\00"
@.str.3 = [12 x i8] c"lp1-www.tar\00"
@.str.4 = [14 x i8] c"/j/looper2.ko\00"
@.str.5 = [10 x i8] c"/j/spi.ko\00"
@.str.6 = [10 x i8] c"/j/userif\00"
@.str.7 = [7 x i8] c"uImage\00"
@.str.8 = [15 x i8] c"/dev/mtdblock1\00"
@.str.9 = [3 x i8] c"/j\00"
@.str.10 = [19 x i8] c"html/testpage.html\00"
@.str.11 = [18 x i8] c"html/upgrade.html\00"
@.str.12 = [17 x i8] c"cgi-bin/test.cgi\00"
@.str.13 = [17 x i8] c"/mnt/lp1-www.tar\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @check_file_size(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%4 = icmp slt i64 %3, 0
br i1 %4, label %30, label %5
5: ; preds = %2
%6 = tail call i64 @check_file_size(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp slt i64 %6, 0
br i1 %7, label %30, label %8
8: ; preds = %5
%9 = tail call i64 @check_file_size(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp slt i64 %9, 0
br i1 %10, label %30, label %11
11: ; preds = %8
%12 = tail call i64 @check_file_size(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp slt i64 %12, 0
br i1 %13, label %30, label %14
14: ; preds = %11
%15 = tail call i32 @copy_file(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%16 = tail call i32 @copy_file(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%17 = tail call i32 @copy_file(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%18 = tail call i32 @chmod(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 493)
%19 = tail call i64 @check_file_size(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %14
%22 = tail call i32 @copy_file(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %23
23: ; preds = %21, %14
%24 = tail call i32 @unlink(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%25 = tail call i32 @chdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%26 = tail call i32 @unlink(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
%27 = tail call i32 @unlink(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
%28 = tail call i32 @unlink(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i64 0, i64 0))
%29 = tail call i32 @extract_tar_file(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0))
br label %30
30: ; preds = %2, %5, %8, %11, %23
%31 = phi i32 [ 0, %23 ], [ -1, %11 ], [ -1, %8 ], [ -1, %5 ], [ -1, %2 ]
ret i32 %31
}