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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ iwlist();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
scalar_t__ strncmp(char *, char *, int);
int main(int argc, char *argv[]) {
  int fd;
  FILE *fp;
  char tmpssid[32] = "/tmp/tmpname";
  pid_t cpid;
  int status;
  char line[256];
  printf("Content type: text/html\n\n");
  iwlist();
  fp = fopen(tmpssid, "r");
  while (fgets(line, sizeof(line), fp)) {
    char *p = line;
    const int LINE_MAX = 256;
    while (strncmp(p, "ESSID", 5)) {
      p++;
      if (p - line > LINE_MAX || *p == 0) {
        p = NULL;
        break;
      }
    }
    if (p) {
      while (*p && *p++ != '\"') {
        if (p - line > LINE_MAX)
          break;
      }
      while (*p && *p != '\"') {
        if (p - line > LINE_MAX)
          break;
        putchar(*p);
        p++;
      }
      putchar('\n');
    }
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe70(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe6d(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe6a(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe67(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe64(%rip),%rdi
call   1070 <printf@plt>
mov    $0x0,%al
call   1050 <iwlist@plt>
lea    -0x40(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
lea    -0x150(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x100,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     13b8 <main+0x248>
lea    -0x150(%rbp),%rax
mov    %rax,-0x158(%rbp)
movl   $0x100,-0x15c(%rbp)
mov    -0x158(%rbp),%rdi
lea    0xe1b(%rip),%rsi
mov    $0x5,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     128c <main+0x11c>
mov    -0x158(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x158(%rbp)
mov    -0x158(%rbp),%rax
lea    -0x150(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x100,%rax
jg     1277 <main+0x107>
mov    -0x158(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1287 <main+0x117>
movq   $0x0,-0x158(%rbp)
jmp    128c <main+0x11c>
jmp    1213 <main+0xa3>
cmpq   $0x0,-0x158(%rbp)
je     13b3 <main+0x243>
jmp    129f <main+0x12f>
mov    -0x158(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x15d(%rbp)
je     12de <main+0x16e>
mov    -0x158(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x158(%rbp)
movsbl (%rax),%eax
cmp    $0x22,%eax
setne  %al
mov    %al,-0x15d(%rbp)
mov    -0x15d(%rbp),%al
test   $0x1,%al
jne    12f1 <main+0x181>
jmp    1318 <main+0x1a8>
mov    -0x158(%rbp),%rax
lea    -0x150(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x100,%rax
jle    1313 <main+0x1a3>
jmp    1318 <main+0x1a8>
jmp    129f <main+0x12f>
jmp    131d <main+0x1ad>
mov    -0x158(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x15e(%rbp)
je     134e <main+0x1de>
mov    -0x158(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
setne  %al
mov    %al,-0x15e(%rbp)
mov    -0x15e(%rbp),%al
test   $0x1,%al
jne    1361 <main+0x1f1>
jmp    13a9 <main+0x239>
mov    -0x158(%rbp),%rax
lea    -0x150(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x100,%rax
jle    1383 <main+0x213>
jmp    13a9 <main+0x239>
mov    -0x158(%rbp),%rax
movsbl (%rax),%edi
call   1030 <putchar@plt>
mov    -0x158(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x158(%rbp)
jmp    131d <main+0x1ad>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11dc <main+0x6c>
mov    -0x20(%rbp),%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x138,%rsp
movaps 0xe88(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe6c(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xe88(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1060 <iwlist@plt>
lea    0xe6d(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1090 <fopen@plt>
mov    %rax,%r12
lea    0x30(%rsp),%r14
mov    %r14,%rdi
mov    $0x100,%esi
mov    %rax,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     12d2 <main+0x162>
mov    $0x1,%eax
sub    %r14,%rax
mov    %rax,0x8(%rsp)
mov    %r14,%r13
neg    %r13
lea    0xe2a(%rip),%r15
mov    %r14,%rbx
jmp    1226 <main+0xb6>
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    $0x100,%esi
mov    %r12,%rdx
call   1080 <fgets@plt>
mov    %r14,%rbx
test   %rax,%rax
je     12d2 <main+0x162>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x5,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1260 <main+0xf0>
lea    0x130(%rsp),%rax
cmp    %rax,%rbx
je     120a <main+0x9a>
add    $0x1,%rbx
cmpb   $0x0,(%rbx)
jne    1226 <main+0xb6>
jmp    120a <main+0x9a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x8(%rsp),%rax
add    %rbx,%rax
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%ecx
test   %cl,%cl
je     128f <main+0x11f>
add    $0x1,%rbx
cmp    $0x22,%cl
je     128f <main+0x11f>
lea    0x1(%rax),%rcx
cmp    $0x101,%rax
mov    %rcx,%rax
jl     1270 <main+0x100>
lea    (%rbx,%r13,1),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%rbx),%eax
test   %al,%al
je     1200 <main+0x90>
cmp    $0x22,%al
je     1200 <main+0x90>
cmp    $0x100,%rbp
jg     1200 <main+0x90>
movsbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
add    $0x1,%rbp
jmp    12a0 <main+0x130>
mov    %r12,%rdi
call   1070 <fclose@plt>
xor    %eax,%eax
add    $0x138,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.tmpssid = [32 x i8] c"/tmp/tmpname\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [26 x i8] c"Content type: text/html\0A\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"ESSID\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 [32 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca [256 x i8]
%12 = alloca i8*
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = bitcast [32 x i8]* %8 to i8*
%15 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%16 = call i32 (...) @iwlist()
%17 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %7
br label %19
19: ; preds = %101, %2
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%21 = load i32*, i32** %7
%22 = call i64 @fgets(i8* %20, i32 256, i32* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %102
24: ; preds = %19
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
store i8* %25, i8** %12
store i32 256, i32* %13
br label %26
26: ; preds = %45, %24
%27 = load i8*, i8** %12
%28 = call i64 @strncmp(i8* %27, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 5)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %46
30: ; preds = %26
%31 = load i8*, i8** %12
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %12
%33 = load i8*, i8** %12
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%35 = ptrtoint i8* %33 to i64
%36 = ptrtoint i8* %34 to i64
%37 = sub i64 %35, %36
%38 = icmp sgt i64 %37, 256
br i1 %38, label %44, label %39
39: ; preds = %30
%40 = load i8*, i8** %12
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %45
44: ; preds = %39, %30
store i8* null, i8** %12
br label %46
45: ; preds = %39
br label %26
46: ; preds = %44, %26
%47 = load i8*, i8** %12
%48 = icmp ne i8* %47, null
br i1 %48, label %49, label %101
49: ; preds = %46
br label %50
50: ; preds = %71, %49
%51 = load i8*, i8** %12
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %61
55: ; preds = %50
%56 = load i8*, i8** %12
%57 = getelementptr inbounds i8, i8* %56, i32 1
store i8* %57, i8** %12
%58 = load i8, i8* %56
%59 = sext i8 %58 to i32
%60 = icmp ne i32 %59, 34
br label %61
61: ; preds = %55, %50
%62 = phi i1 [ false, %50 ], [ %60, %55 ]
br i1 %62, label %63, label %72
63: ; preds = %61
%64 = load i8*, i8** %12
%65 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%66 = ptrtoint i8* %64 to i64
%67 = ptrtoint i8* %65 to i64
%68 = sub i64 %66, %67
%69 = icmp sgt i64 %68, 256
br i1 %69, label %70, label %71
70: ; preds = %63
br label %72
71: ; preds = %63
br label %50
72: ; preds = %70, %61
br label %73
73: ; preds = %93, %72
%74 = load i8*, i8** %12
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = icmp ne i32 %76, 0
br i1 %77, label %78, label %83
78: ; preds = %73
%79 = load i8*, i8** %12
%80 = load i8, i8* %79
%81 = sext i8 %80 to i32
%82 = icmp ne i32 %81, 34
br label %83
83: ; preds = %78, %73
%84 = phi i1 [ false, %73 ], [ %82, %78 ]
br i1 %84, label %85, label %99
85: ; preds = %83
%86 = load i8*, i8** %12
%87 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%88 = ptrtoint i8* %86 to i64
%89 = ptrtoint i8* %87 to i64
%90 = sub i64 %88, %89
%91 = icmp sgt i64 %90, 256
br i1 %91, label %92, label %93
92: ; preds = %85
br label %99
93: ; preds = %85
%94 = load i8*, i8** %12
%95 = load i8, i8* %94
%96 = call i32 @putchar(i8 signext %95)
%97 = load i8*, i8** %12
%98 = getelementptr inbounds i8, i8* %97, i32 1
store i8* %98, i8** %12
br label %73
99: ; preds = %92, %83
%100 = call i32 @putchar(i8 signext 10)
br label %101
101: ; preds = %99, %46
br label %19
102: ; preds = %19
%103 = load i32*, i32** %7
%104 = call i32 @fclose(i32* %103)
ret i32 0
}

LLVM IR (-O2):
@__const.main.tmpssid = [32 x i8] c"/tmp/tmpname\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"ESSID\00"
@str = [25 x i8] c"Content type: text/html\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [32 x i8]
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 (...) @iwlist()
%9 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = call i64 @fgets(i8* %6, i32 256, i32* %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %55, label %12
12: ; preds = %2
%13 = ptrtoint [256 x i8]* %4 to i64
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 1, i64 0
br label %15
15: ; preds = %25, %12
%16 = phi i8* [ %6, %12 ], [ %26, %25 ]
%17 = call i64 @strncmp(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 5)
%18 = icmp eq i64 %17, 0
br i1 %18, label %27, label %19
19: ; preds = %15
%20 = getelementptr inbounds i8, i8* %16, i64 1
%21 = icmp eq i8* %16, %14
br i1 %21, label %52, label %22
22: ; preds = %19
%23 = load i8, i8* %20
%24 = icmp eq i8 %23, 0
br i1 %24, label %52, label %25
25: ; preds = %22, %52
%26 = phi i8* [ %20, %22 ], [ %6, %52 ]
br label %15
27: ; preds = %15, %31
%28 = phi i8* [ %32, %31 ], [ %16, %15 ]
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
br i1 %30, label %38, label %31
31: ; preds = %27
%32 = getelementptr inbounds i8, i8* %28, i64 1
%33 = icmp eq i8 %29, 34
%34 = ptrtoint i8* %32 to i64
%35 = sub i64 %34, %13
%36 = icmp sgt i64 %35, 256
%37 = select i1 %33, i1 true, i1 %36
br i1 %37, label %38, label %27
38: ; preds = %27, %31
%39 = phi i8* [ %28, %27 ], [ %32, %31 ]
br label %40
40: ; preds = %38, %47
%41 = phi i8* [ %49, %47 ], [ %39, %38 ]
%42 = load i8, i8* %41
switch i8 %42, label %43 [
i8 0, label %50
i8 34, label %50
]
43: ; preds = %40
%44 = ptrtoint i8* %41 to i64
%45 = sub i64 %44, %13
%46 = icmp sgt i64 %45, 256
br i1 %46, label %50, label %47
47: ; preds = %43
%48 = call i32 @putchar(i8 signext %42)
%49 = getelementptr inbounds i8, i8* %41, i64 1
br label %40
50: ; preds = %40, %40, %43
%51 = call i32 @putchar(i8 signext 10)
br label %52
52: ; preds = %19, %22, %50
%53 = call i64 @fgets(i8* %6, i32 256, i32* %9)
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %25
55: ; preds = %52, %2
%56 = call i32 @fclose(i32* %9)
ret i32 0
}