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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  FILE *fp = NULL;
  char buf[1024];
  printf("Content-type:text/html\r\n\r\n");
  printf(
      "<html><head><title>PARTITION INFO</title>                <meta "
      "http-equiv='Content-Type' content='text/html; charset=utf-8'/></head>");
  printf("<body><div width=900px><div align=center>                "
         "<h1>PARTITION INFO</h1></div><hr> <div>");
  if ((fp = fopen("/proc/partitions", "r")) == NULL) {
    printf("can not open!\n");
    return -1;
  }
  do {
    fgets(buf, sizeof(buf), fp);
    printf("%s <br>", buf);
  } while (feof(fp) == 0);
  printf("</div><hr></div></body></html>\n");
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf0c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf5f(%rip),%rdi
lea    0xf69(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11d6 <main+0x86>
lea    0xf51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1236 <main+0xe6>
jmp    11db <main+0x8b>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x400,%esi
call   1050 <fgets@plt>
lea    -0x420(%rbp),%rsi
lea    0xf25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%rax
je     11db <main+0x8b>
lea    0xf0c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
lea    0xf8e(%rip),%rdi
call   1030 <puts@plt>
lea    0xe81(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xef8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf4b(%rip),%rdi
lea    0xf55(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1202 <main+0xa2>
mov    %rax,%rbx
mov    %rsp,%r14
lea    0xf40(%rip),%r15
nopl   0x0(%rax)
mov    %r14,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %rax,%rax
je     11c0 <main+0x60>
lea    0xf2a(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    1213 <main+0xb3>
lea    0xf31(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Content-type:text/html\0D\0A\0D\0A\00"
@.str.1 = [133 x i8] c"<html><head><title>PARTITION INFO</title> <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/></head>\00"
@.str.2 = [97 x i8] c"<body><div width=900px><div align=center> <h1>PARTITION INFO</h1></div><hr> <div>\00"
@.str.3 = [17 x i8] c"/proc/partitions\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [15 x i8] c"can not open!\0A\00"
@.str.6 = [8 x i8] c"%s <br>\00"
@.str.7 = [32 x i8] c"</div><hr></div></body></html>\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([133 x i8], [133 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %11, i32** %6
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
br label %30
15: ; preds = %2
br label %16
16: ; preds = %22, %15
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%18 = load i32*, i32** %6
%19 = call i32 @fgets(i8* %17, i32 1024, i32* %18)
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %16
%23 = load i32*, i32** %6
%24 = call i64 @feof(i32* %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %16, label %26
26: ; preds = %22
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
%28 = load i32*, i32** %6
%29 = call i32 @fclose(i32* %28)
store i32 0, i32* %3
br label %30
30: ; preds = %26, %13
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@.str.1 = [133 x i8] c"<html><head><title>PARTITION INFO</title> <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/></head>\00"
@.str.2 = [97 x i8] c"<body><div width=900px><div align=center> <h1>PARTITION INFO</h1></div><hr> <div>\00"
@.str.3 = [17 x i8] c"/proc/partitions\00"
@.str.4 = [2 x i8] c"r\00"
@.str.6 = [8 x i8] c"%s <br>\00"
@str = [26 x i8] c"Content-type:text/html\0D\0A\0D\00"
@str.8 = [31 x i8] c"</div><hr></div></body></html>\00"
@str.9 = [14 x i8] c"can not open!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([133 x i8], [133 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([97 x i8], [97 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.9, i64 0, i64 0))
br label %20
12: ; preds = %2, %12
%13 = call i32 @fgets(i8* %4, i32 1024, i32* %8)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %4)
%15 = call i64 @feof(i32* %8)
%16 = icmp eq i64 %15, 0
br i1 %16, label %12, label %17
17: ; preds = %12
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.8, i64 0, i64 0))
%19 = call i32 @fclose(i32* %8)
br label %20
20: ; preds = %17, %10
%21 = phi i32 [ -1, %10 ], [ 0, %17 ]
ret i32 %21
}