#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 */
char *GetStringFromWeb();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ system(char *);
int main(int argc, char const *argv[]) {
  FILE *fw_fp = NULL;
  FILE *fp_dev = NULL;
  unsigned char *fw_ptr;
  int f_size = 0;
  int fd;
  char *cgistr;
  int nor_seek;
  int file_seek;
  int nor_size;
  int len;
  char teststr[100];
  fprintf(stdout, "Content-type:text/html\r\n\r\n");
  cgistr = GetStringFromWeb();
  system("sync");
  system("echo 3 >/proc/sys/vm/drop_caches");
  system("/etc/init.d/dm_router stop");
  system("echo timer > /sys/class/leds/longsys\:blue\:led/trigger ");
  system("echo 1000 > /sys/class/leds/longsys\:blue\:led/delay_on ");
  system("echo 1000 > /sys/class/leds/longsys\:blue\:led/delay_off ");
  system("sysupgrade -F /tmp/fwupgrade &");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1050 <GetStringFromWeb@plt>
mov    %rax,-0x38(%rbp)
lea    0xe94(%rip),%rdi
call   1030 <system@plt>
lea    0xe8d(%rip),%rdi
call   1030 <system@plt>
lea    0xea2(%rip),%rdi
call   1030 <system@plt>
lea    0xeb1(%rip),%rdi
call   1030 <system@plt>
lea    0xedc(%rip),%rdi
call   1030 <system@plt>
lea    0xf07(%rip),%rdi
call   1030 <system@plt>
lea    0xf33(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2ea8(%rip),%rax
mov    (%rax),%edi
lea    0xebf(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1050 <GetStringFromWeb@plt>
lea    0xec7(%rip),%rdi
call   1030 <system@plt>
lea    0xec0(%rip),%rdi
call   1030 <system@plt>
lea    0xed5(%rip),%rdi
call   1030 <system@plt>
lea    0xee4(%rip),%rdi
call   1030 <system@plt>
lea    0xf0f(%rip),%rdi
call   1030 <system@plt>
lea    0xf3a(%rip),%rdi
call   1030 <system@plt>
lea    0xf66(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [27 x i8] c"Content-type:text/html\0D\0A\0D\0A\00"
@.str.1 = [5 x i8] c"sync\00"
@.str.2 = [33 x i8] c"echo 3 >/proc/sys/vm/drop_caches\00"
@.str.3 = [27 x i8] c"/etc/init.d/dm_router stop\00"
@.str.4 = [55 x i8] c"echo timer > /sys/class/leds/longsys:blue:led/trigger \00"
@.str.5 = [55 x i8] c"echo 1000 > /sys/class/leds/longsys:blue:led/delay_on \00"
@.str.6 = [56 x i8] c"echo 1000 > /sys/class/leds/longsys:blue:led/delay_off \00"
@.str.7 = [31 x i8] c"sysupgrade -F /tmp/fwupgrade &\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca [100 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store i32* null, i32** %7
store i32 0, i32* %9
%17 = load i32, i32* @stdout
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%19 = call i8* (...) @GetStringFromWeb()
store i8* %19, i8** %11
%20 = call i32 @system(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @system(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 @system(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%23 = call i32 @system(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0))
%24 = call i32 @system(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.5, i64 0, i64 0))
%25 = call i32 @system(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.6, i64 0, i64 0))
%26 = call i32 @system(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [27 x i8] c"Content-type:text/html\0D\0A\0D\0A\00"
@.str.1 = [5 x i8] c"sync\00"
@.str.2 = [33 x i8] c"echo 3 >/proc/sys/vm/drop_caches\00"
@.str.3 = [27 x i8] c"/etc/init.d/dm_router stop\00"
@.str.4 = [55 x i8] c"echo timer > /sys/class/leds/longsys:blue:led/trigger \00"
@.str.5 = [55 x i8] c"echo 1000 > /sys/class/leds/longsys:blue:led/delay_on \00"
@.str.6 = [56 x i8] c"echo 1000 > /sys/class/leds/longsys:blue:led/delay_off \00"
@.str.7 = [31 x i8] c"sysupgrade -F /tmp/fwupgrade &\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @stdout
%4 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%5 = tail call i8* (...) @GetStringFromWeb()
%6 = tail call i32 @system(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @system(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @system(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%9 = tail call i32 @system(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0))
%10 = tail call i32 @system(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.5, i64 0, i64 0))
%11 = tail call i32 @system(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.6, i64 0, i64 0))
%12 = tail call i32 @system(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}