#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, unsigned long *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(unsigned long *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, unsigned long);
int /*<<< orphan*/ system(char *);
void main(int argc, char *argv[]) {
  unsigned char command[132];
  unsigned long lg;
  FILE *fi;
  system("ls -l revoboot.pxe | awk '{print $5}' >pxe.size");
  fi = fopen("pxe.size", "rt");
  fscanf(fi, "%ld", &lg);
  fclose(fi);
  printf("File length : %ld\n", lg);
  lg -= 512;
  fi = fopen("revoboot.pxe", "r+b");
  fseek(fi, 32, SEEK_SET);
  fwrite(&lg, 4, 1, fi);
  fwrite(&lg, 4, 1, fi);
  fclose(fi);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe77(%rip),%rdi
call   1040 <system@plt>
lea    0xe92(%rip),%rdi
lea    0xe94(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0xb0(%rbp)
mov    -0xb0(%rbp),%rdi
lea    0xe7d(%rip),%rsi
lea    -0xa8(%rbp),%rdx
call   1060 <fscanf@plt>
mov    -0xb0(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0xa8(%rbp),%rsi
lea    0xe5b(%rip),%rdi
call   1050 <printf@plt>
mov    -0xa8(%rbp),%rax
sub    $0x200,%rax
mov    %rax,-0xa8(%rbp)
lea    0xe4e(%rip),%rdi
lea    0xe54(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0xb0(%rbp)
mov    -0xb0(%rbp),%rdi
mov    0x2dc3(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   1070 <fseek@plt>
mov    -0xb0(%rbp),%rcx
lea    -0xa8(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1090 <fwrite@plt>
mov    -0xb0(%rbp),%rcx
lea    -0xa8(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1090 <fwrite@plt>
mov    -0xb0(%rbp),%rdi
call   1030 <fclose@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xe85(%rip),%rdi
call   1040 <system@plt>
lea    0xea0(%rip),%rdi
lea    0xea2(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
lea    0xe96(%rip),%rsi
mov    %rsp,%r14
mov    %rax,%rdi
mov    %r14,%rdx
call   1060 <fscanf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    (%rsp),%rsi
lea    0xe79(%rip),%rdi
call   1050 <printf@plt>
addq   $0xfffffffffffffe00,(%rsp)
ff
lea    0xe78(%rip),%rdi
lea    0xe7e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    0x2df8(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x20,%esi
call   1070 <fseek@plt>
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1090 <fwrite@plt>
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1090 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [48 x i8] c"ls -l revoboot.pxe | awk '{print $5}' >pxe.size\00"
@.str.1 = [9 x i8] c"pxe.size\00"
@.str.2 = [3 x i8] c"rt\00"
@.str.3 = [4 x i8] c"%ld\00"
@.str.4 = [19 x i8] c"File length : %ld\0A\00"
@.str.5 = [13 x i8] c"revoboot.pxe\00"
@.str.6 = [4 x i8] c"r+b\00"
@SEEK_SET = global i32 0
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [132 x i8]
%6 = alloca i64
%7 = alloca i32*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = call i32 @system(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%9 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %9, i32** %7
%10 = load i32*, i32** %7
%11 = call i32 @fscanf(i32* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64* %6)
%12 = load i32*, i32** %7
%13 = call i32 @fclose(i32* %12)
%14 = load i64, i64* %6
%15 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i64 %14)
%16 = load i64, i64* %6
%17 = sub i64 %16, 512
store i64 %17, i64* %6
%18 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
store i32* %18, i32** %7
%19 = load i32*, i32** %7
%20 = load i32, i32* @SEEK_SET
%21 = call i32 @fseek(i32* %19, i32 32, i32 %20)
%22 = load i32*, i32** %7
%23 = call i32 @fwrite(i64* %6, i32 4, i32 1, i32* %22)
%24 = load i32*, i32** %7
%25 = call i32 @fwrite(i64* %6, i32 4, i32 1, i32* %24)
%26 = load i32*, i32** %7
%27 = call i32 @fclose(i32* %26)
ret void
}

LLVM IR (-O2):
@.str = [48 x i8] c"ls -l revoboot.pxe | awk '{print $5}' >pxe.size\00"
@.str.1 = [9 x i8] c"pxe.size\00"
@.str.2 = [3 x i8] c"rt\00"
@.str.3 = [4 x i8] c"%ld\00"
@.str.4 = [19 x i8] c"File length : %ld\0A\00"
@.str.5 = [13 x i8] c"revoboot.pxe\00"
@.str.6 = [4 x i8] c"r+b\00"
@SEEK_SET = global i32 0
define void @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = tail call i32 @system(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64* %3)
%8 = call i32 @fclose(i32* %6)
%9 = load i64, i64* %3
%10 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i64 %9)
%11 = load i64, i64* %3
%12 = add i64 %11, -512
store i64 %12, i64* %3
%13 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%14 = load i32, i32* @SEEK_SET
%15 = call i32 @fseek(i32* %13, i32 32, i32 %14)
%16 = call i32 @fwrite(i64* %3, i32 4, i32 1, i32* %13)
%17 = call i32 @fwrite(i64* %3, i32 4, i32 1, i32* %13)
%18 = call i32 @fclose(i32* %13)
ret void
}