#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 atoi(char *);
char *getenv(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ system(char *);
int main() {
  char *XY_led = NULL;
  int status = 0;
  XY_led = getenv("XY_led");
  if (XY_led != NULL)
    status = atoi(XY_led);
  else
    status = -1;
  printf("Content-type: text/html\r\n\r\n");
  printf(
      "<html><head><title>Led控制</title>		<meta "
      "http-equiv='Content-Type' content='text/html; charset=utf-8'/></head>");
  printf("<body><div width=900px><div align=center>		"
         "<h1>Led控制</h1></div><hr> <div>");
  printf("star\n");
  if (status == 1) {
    char cmd[] = "insmod /mnt/led/led.ko";
    system(cmd);
    printf("led on!!!<br>");
    printf("<span style='width:40px;height:50px;'>			<img "
           "border='0' src='../img/led_on.gif'			 width='38' "
           "heigth='23'></span>");
    printf("<span style='width:40px;height:50px;'>			<img "
           "border='0' src='../img/led_on.gif'			 width='38' "
           "heigth='23'></span>");
    printf("<span style='width:40px;height:50px;'>			<img "
           "border='0' src='../img/led_on.gif'			 width='38' "
           "heigth='23'></span>");
    printf("<span style='width:40px;height:50px;'>			<img "
           "border='0' src='../img/led_on.gif'			 width='38' "
           "heigth='23'></span><br>");
  } else if (status == 0) {
    char cmd[] = "rmmod led";
    system(cmd);
    printf("led off!!!<br>");
    printf("<span style='width:40px;height:50px;'>			<img "
           "border='0' src='../img/led_off.jpg'			 width='38' "
           "heigth='23'></span>");
    printf("<span style='width:40px;height:50px;'>			<img "
           "border='0' src='../img/led_off.jpg'			 width='38' "
           "heigth='23'></span>");
    printf("<span style='width:40px;height:50px;'>			<img "
           "border='0' src='../img/led_off.jpg'			 width='38' "
           "heigth='23'></span>");
    printf("<span style='width:40px;height:50px;'>			<img "
           "border='0' src='../img/led_off.jpg'			 width='38' "
           "heigth='23'></span><br>");
  }
  printf("status:%d", status);
  printf("<form action=led.xcgi method=post>");
  printf("<input name='XY_led' value='1' checked='checked'		 "
         "type='radio'><label >ON &nbsp;</label>");
  printf("<input name='XY_led' value='0' type='radio'>		<label >OFF "
         "&nbsp;</label>");
  printf("<br><input type=submit value=配置 >		<input type=reset "
         "value=重置 ></form>		</div><hr></div></body></html>\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe9b(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     118a <main+0x4a>
mov    -0x10(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
jmp    1191 <main+0x51>
movl   $0xffffffff,-0x14(%rbp)
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xf21(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x1,-0x14(%rbp)
jne    125a <main+0x11a>
mov    0x1256(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x1253(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x1251(%rip),%eax
mov    %eax,-0x20(%rbp)
mov    0x124b(%rip),%ax
mov    %ax,-0x1c(%rbp)
mov    0x1243(%rip),%al
mov    %al,-0x1a(%rbp)
lea    -0x30(%rbp),%rdi
call   1040 <system@plt>
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xf1c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12ce <main+0x18e>
cmpl   $0x0,-0x14(%rbp)
jne    12c9 <main+0x189>
mov    0xf76(%rip),%rax
mov    %rax,-0x3a(%rbp)
mov    0xf73(%rip),%ax
mov    %ax,-0x32(%rbp)
lea    -0x3a(%rbp),%rdi
call   1040 <system@plt>
lea    0xf61(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xf62(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xf54(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xf46(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xfac(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12ce <main+0x18e>
mov    -0x14(%rbp),%esi
lea    0x100e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0x100a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0x101f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0x106b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0x10a6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xea2(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1174 <main+0x24>
mov    %rax,%rdi
call   1070 <atoi@plt>
mov    %eax,%ebx
jmp    1179 <main+0x29>
mov    $0xffffffff,%ebx
lea    0x1214(%rip),%rdi
call   1040 <puts@plt>
lea    0xe7b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xedf(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x1207(%rip),%rdi
call   1040 <puts@plt>
test   %ebx,%ebx
je     1218 <main+0xc8>
cmp    $0x1,%ebx
jne    1276 <main+0x126>
movaps 0x126f(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0x6f6b2e64656c2f,%rax
mov    %rax,0xf(%rsp)
mov    %rsp,%rdi
call   1050 <system@plt>
lea    0xee4(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xee4(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xf32(%rip),%rdi
jmp    126f <main+0x11f>
movabs $0x656c20646f6d6d72,%rax
20 6c 65
mov    %rax,(%rsp)
movw   $0x64,0x8(%rsp)
mov    %rsp,%rdi
call   1050 <system@plt>
lea    0xf8d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xf8e(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xfdd(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x1047(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x1041(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x1056(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x10a2(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x10fd(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"XY_led\00"
@.str.1 = [28 x i8] c"Content-type: text/html\0D\0A\0D\0A\00"
@.str.2 = [114 x i8] c"<html><head><title>Led\E6\8E\A7\E5\88\B6</title>\09\09<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/></head>\00"
@.str.3 = [78 x i8] c"<body><div width=900px><div align=center>\09\09<h1>Led\E6\8E\A7\E5\88\B6</h1></div><hr> <div>\00"
@.str.4 = [6 x i8] c"star\0A\00"
@__const.main.cmd = [23 x i8] c"insmod /mnt/led/led.ko\00"
@.str.5 = [14 x i8] c"led on!!!<br>\00"
@.str.6 = [115 x i8] c"<span style='width:40px;height:50px;'>\09\09\09<img border='0' src='../img/led_on.gif'\09\09\09 width='38' heigth='23'></span>\00"
@.str.7 = [119 x i8] c"<span style='width:40px;height:50px;'>\09\09\09<img border='0' src='../img/led_on.gif'\09\09\09 width='38' heigth='23'></span><br>\00"
@__const.main.cmd.8 = [10 x i8] c"rmmod led\00"
@.str.9 = [15 x i8] c"led off!!!<br>\00"
@.str.10 = [116 x i8] c"<span style='width:40px;height:50px;'>\09\09\09<img border='0' src='../img/led_off.jpg'\09\09\09 width='38' heigth='23'></span>\00"
@.str.11 = [120 x i8] c"<span style='width:40px;height:50px;'>\09\09\09<img border='0' src='../img/led_off.jpg'\09\09\09 width='38' heigth='23'></span><br>\00"
@.str.12 = [10 x i8] c"status:%d\00"
@.str.13 = [35 x i8] c"<form action=led.xcgi method=post>\00"
@.str.14 = [90 x i8] c"<input name='XY_led' value='1' checked='checked'\09\09 type='radio'><label >ON &nbsp;</label>\00"
@.str.15 = [73 x i8] c"<input name='XY_led' value='0' type='radio'>\09\09<label >OFF &nbsp;</label>\00"
@.str.16 = [112 x i8] c"<br><input type=submit value=\E9\85\8D\E7\BD\AE >\09\09<input type=reset value=\E9\87\8D\E7\BD\AE ></form>\09\09</div><hr></div></body></html>\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [23 x i8]
%5 = alloca [10 x i8]
store i32 0, i32* %1
store i8* null, i8** %2
store i32 0, i32* %3
%6 = call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %2
%7 = load i8*, i8** %2
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = load i8*, i8** %2
%11 = call i32 @atoi(i8* %10)
store i32 %11, i32* %3
br label %13
12: ; preds = %0
store i32 -1, i32* %3
br label %13
13: ; preds = %12, %9
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([114 x i8], [114 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %29
20: ; preds = %13
%21 = bitcast [23 x i8]* %4 to i8*
%22 = getelementptr inbounds [23 x i8], [23 x i8]* %4, i64 0, i64 0
%23 = call i32 @system(i8* %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str.6, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str.6, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str.6, i64 0, i64 0))
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([119 x i8], [119 x i8]* @.str.7, i64 0, i64 0))
br label %42
29: ; preds = %13
%30 = load i32, i32* %3
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %41
32: ; preds = %29
%33 = bitcast [10 x i8]* %5 to i8*
%34 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%35 = call i32 @system(i8* %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.10, i64 0, i64 0))
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.10, i64 0, i64 0))
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.10, i64 0, i64 0))
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([120 x i8], [120 x i8]* @.str.11, i64 0, i64 0))
br label %41
41: ; preds = %32, %29
br label %42
42: ; preds = %41, %20
%43 = load i32, i32* %3
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i32 %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.13, i64 0, i64 0))
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.14, i64 0, i64 0))
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.15, i64 0, i64 0))
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([112 x i8], [112 x i8]* @.str.16, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"XY_led\00"
@.str.2 = [114 x i8] c"<html><head><title>Led\E6\8E\A7\E5\88\B6</title>\09\09<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/></head>\00"
@.str.3 = [78 x i8] c"<body><div width=900px><div align=center>\09\09<h1>Led\E6\8E\A7\E5\88\B6</h1></div><hr> <div>\00"
@__const.main.cmd = [23 x i8] c"insmod /mnt/led/led.ko\00"
@.str.5 = [14 x i8] c"led on!!!<br>\00"
@.str.6 = [115 x i8] c"<span style='width:40px;height:50px;'>\09\09\09<img border='0' src='../img/led_on.gif'\09\09\09 width='38' heigth='23'></span>\00"
@.str.7 = [119 x i8] c"<span style='width:40px;height:50px;'>\09\09\09<img border='0' src='../img/led_on.gif'\09\09\09 width='38' heigth='23'></span><br>\00"
@__const.main.cmd.8 = [10 x i8] c"rmmod led\00"
@.str.9 = [15 x i8] c"led off!!!<br>\00"
@.str.10 = [116 x i8] c"<span style='width:40px;height:50px;'>\09\09\09<img border='0' src='../img/led_off.jpg'\09\09\09 width='38' heigth='23'></span>\00"
@.str.11 = [120 x i8] c"<span style='width:40px;height:50px;'>\09\09\09<img border='0' src='../img/led_off.jpg'\09\09\09 width='38' heigth='23'></span><br>\00"
@.str.12 = [10 x i8] c"status:%d\00"
@.str.13 = [35 x i8] c"<form action=led.xcgi method=post>\00"
@.str.14 = [90 x i8] c"<input name='XY_led' value='1' checked='checked'\09\09 type='radio'><label >ON &nbsp;</label>\00"
@.str.15 = [73 x i8] c"<input name='XY_led' value='0' type='radio'>\09\09<label >OFF &nbsp;</label>\00"
@str = [27 x i8] c"Content-type: text/html\0D\0A\0D\00"
@str.17 = [5 x i8] c"star\00"
@str.18 = [111 x i8] c"<br><input type=submit value=\E9\85\8D\E7\BD\AE >\09\09<input type=reset value=\E9\87\8D\E7\BD\AE ></form>\09\09</div><hr></div></body></html>\00"
define i32 @main() {
%1 = alloca [23 x i8]
%2 = alloca [10 x i8]
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = tail call i32 @atoi(i8* %3)
br label %7
7: ; preds = %0, %5
%8 = phi i32 [ %6, %5 ], [ -1, %0 ]
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([114 x i8], [114 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @.str.3, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.17, i64 0, i64 0))
switch i32 %8, label %29 [
i32 1, label %13
i32 0, label %21
]
13: ; preds = %7
%14 = getelementptr inbounds [23 x i8], [23 x i8]* %1, i64 0, i64 0
%15 = call i32 @system(i8* %14)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([115 x i8], [115 x i8]* @.str.6, i64 0, i64 0))
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([115 x i8], [115 x i8]* @.str.6, i64 0, i64 0))
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([115 x i8], [115 x i8]* @.str.6, i64 0, i64 0))
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([119 x i8], [119 x i8]* @.str.7, i64 0, i64 0))
br label %29
21: ; preds = %7
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%23 = call i32 @system(i8* %22)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([116 x i8], [116 x i8]* @.str.10, i64 0, i64 0))
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([116 x i8], [116 x i8]* @.str.10, i64 0, i64 0))
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([116 x i8], [116 x i8]* @.str.10, i64 0, i64 0))
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([120 x i8], [120 x i8]* @.str.11, i64 0, i64 0))
br label %29
29: ; preds = %7, %21, %13
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i32 %8)
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.13, i64 0, i64 0))
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([90 x i8], [90 x i8]* @.str.14, i64 0, i64 0))
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @.str.15, i64 0, i64 0))
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([111 x i8], [111 x i8]* @str.18, i64 0, i64 0))
ret i32 0
}