#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*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int inet_convert(char *, int);
scalar_t__ strcmp(char *, char *);
void writeit(FILE *fp, char *out_query, char *mid_query, int results,
             char *flag) {
  extern char *google_server;
  if (strcmp(flag, "header") == 0) {
    fprintf(fp, "<style>BODY {FONT-FAMILY: Verdana,Helvetica; FONT-SIZE: "
                "12px}</style>");
    fprintf(fp, "<CENTER><TABLE BORDER=1>\n");
    fprintf(fp, "<TR><TD>Search</TD><TD>Link</TD><TD>Results</TD></TR>");
  } else if (strcmp(flag, "line") == 0) {
    char *bold_start = (results == 0) ? "" : "<b>";
    char *bold_end = (results == 0) ? "" : "</b>";
    fprintf(
        fp,
        "<TR><TD>%s%s%s</TD><TD><A HREF=\"http://%s/search?%s\">link</A></TD>"
        "<TD align=\"RIGHT\">%d</TD></TR>\n",
        bold_start, mid_query, bold_end, google_server,
        inet_convert(out_query, 1), results);
  } else if (strcmp(flag, "footer") == 0) {
    fprintf(fp, "</TABLE>\n");
    fprintf(fp, "<BR>gooscan by j0hnny<br><A "
                "HREF=\"http://johnny.ihackstuff.com\">http://"
                "johnny.ihackstuff.com</A><BR>");
  } else if (strcmp(flag, "raw") == 0)
    fprintf(fp, "%s", mid_query);
}


x86 assembly (clang, -O0):
<writeit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xeaa(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11a0 <writeit+0x70>
mov    -0x8(%rbp),%rdi
lea    0xe97(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xecb(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xed3(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    12e5 <writeit+0x1b5>
mov    -0x28(%rbp),%rdi
lea    0xef2(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1263 <writeit+0x133>
mov    -0x1c(%rbp),%edx
lea    0xede(%rip),%rax
lea    0xe9b(%rip),%rcx
cmp    $0x0,%edx
cmove  %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%edx
lea    0xec6(%rip),%rax
lea    0xe7f(%rip),%rcx
cmp    $0x0,%edx
cmove  %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    0x2dbf(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1030 <inet_convert@plt>
mov    -0x60(%rbp),%rdi
mov    -0x58(%rbp),%rdx
mov    -0x50(%rbp),%rcx
mov    -0x48(%rbp),%r8
mov    -0x40(%rbp),%r9
mov    %eax,%r10d
mov    -0x1c(%rbp),%eax
lea    0xe5c(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    12e0 <writeit+0x1b0>
mov    -0x28(%rbp),%rdi
lea    0xe9f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12a6 <writeit+0x176>
mov    -0x8(%rbp),%rdi
lea    0xe8c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe84(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    12db <writeit+0x1ab>
mov    -0x28(%rbp),%rdi
lea    0xed2(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12d6 <writeit+0x1a6>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xeb8(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    12db <writeit+0x1ab>
jmp    12e0 <writeit+0x1b0>
jmp    12e5 <writeit+0x1b5>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeit>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%rbx
mov    %ecx,%r15d
mov    %rdx,%r14
mov    %rsi,%r13
mov    %rdi,%r12
lea    0xe8f(%rip),%rsi
mov    %r8,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11cb <writeit+0x7b>
lea    0xf18(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     120e <writeit+0xbe>
lea    0xf74(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     127d <writeit+0x12d>
lea    0xfd2(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12bd <writeit+0x16d>
add    $0x8,%rsp
jmp    1272 <writeit+0x122>
lea    0xe35(%rip),%rdi
mov    $0x45,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1070 <fwrite@plt>
lea    0xe62(%rip),%rdi
mov    $0x19,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1070 <fwrite@plt>
lea    0xe63(%rip),%rdi
mov    $0x35,%esi
jmp    12a2 <writeit+0x152>
test   %r15d,%r15d
lea    0xe4e(%rip),%rax
lea    0xe83(%rip),%rbx
cmove  %rax,%rbx
lea    0xe7c(%rip),%rbp
cmove  %rax,%rbp
mov    0x2da3(%rip),%rax
mov    (%rax),%rax
mov    %rax,(%rsp)
mov    %r13,%rdi
mov    $0x1,%esi
call   1030 <inet_convert@plt>
mov    %eax,%r10d
lea    0xe58(%rip),%rsi
mov    %r12,%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
mov    %rbp,%r8
mov    (%rsp),%r9
xor    %eax,%eax
push   %r15
push   %r10
call   1060 <fprintf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe90(%rip),%rdi
mov    $0x9,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1070 <fwrite@plt>
lea    0xe81(%rip),%rdi
mov    $0x64,%esi
mov    $0x1,%edx
mov    %r12,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <fwrite@plt>
mov    %r14,%rdi
mov    %r12,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fputs@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"header\00"
@.str.1 = [70 x i8] c"<style>BODY {FONT-FAMILY: Verdana,Helvetica; FONT-SIZE: 12px}</style>\00"
@.str.2 = [26 x i8] c"<CENTER><TABLE BORDER=1>\0A\00"
@.str.3 = [54 x i8] c"<TR><TD>Search</TD><TD>Link</TD><TD>Results</TD></TR>\00"
@.str.4 = [5 x i8] c"line\00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [4 x i8] c"<b>\00"
@.str.7 = [5 x i8] c"</b>\00"
@.str.8 = [98 x i8] c"<TR><TD>%s%s%s</TD><TD><A HREF=\22http://%s/search?%s\22>link</A></TD><TD align=\22RIGHT\22>%d</TD></TR>\0A\00"
@google_server = external global i8*
@.str.9 = [7 x i8] c"footer\00"
@.str.10 = [10 x i8] c"</TABLE>\0A\00"
@.str.11 = [101 x i8] c"<BR>gooscan by j0hnny<br><A HREF=\22http://johnny.ihackstuff.com\22>http://johnny.ihackstuff.com</A><BR>\00"
@.str.12 = [4 x i8] c"raw\00"
@.str.13 = [3 x i8] c"%s\00"
define void @writeit(i32* %0, i8* %1, i8* %2, i32 %3, i8* %4) {
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
store i32* %0, i32** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%13 = load i8*, i8** %10
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %5
%17 = load i32*, i32** %6
%18 = call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.1, i64 0, i64 0))
%19 = load i32*, i32** %6
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32*, i32** %6
%22 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0))
br label %65
23: ; preds = %5
%24 = load i8*, i8** %10
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %45
27: ; preds = %23
%28 = load i32, i32* %9
%29 = icmp eq i32 %28, 0
%30 = zext i1 %29 to i64
%31 = select i1 %29, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0)
store i8* %31, i8** %11
%32 = load i32, i32* %9
%33 = icmp eq i32 %32, 0
%34 = zext i1 %33 to i64
%35 = select i1 %33, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0)
store i8* %35, i8** %12
%36 = load i32*, i32** %6
%37 = load i8*, i8** %11
%38 = load i8*, i8** %8
%39 = load i8*, i8** %12
%40 = load i8*, i8** @google_server
%41 = load i8*, i8** %7
%42 = call i32 @inet_convert(i8* %41, i32 1)
%43 = load i32, i32* %9
%44 = call i32 (i32*, i8*, ...) @fprintf(i32* %36, i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str.8, i64 0, i64 0), i8* %37, i8* %38, i8* %39, i8* %40, i32 %42, i32 %43)
br label %64
45: ; preds = %23
%46 = load i8*, i8** %10
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %54
49: ; preds = %45
%50 = load i32*, i32** %6
%51 = call i32 (i32*, i8*, ...) @fprintf(i32* %50, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%52 = load i32*, i32** %6
%53 = call i32 (i32*, i8*, ...) @fprintf(i32* %52, i8* getelementptr inbounds ([101 x i8], [101 x i8]* @.str.11, i64 0, i64 0))
br label %63
54: ; preds = %45
%55 = load i8*, i8** %10
%56 = call i64 @strcmp(i8* %55, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %62
58: ; preds = %54
%59 = load i32*, i32** %6
%60 = load i8*, i8** %8
%61 = call i32 (i32*, i8*, ...) @fprintf(i32* %59, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i8* %60)
br label %62
62: ; preds = %58, %54
br label %63
63: ; preds = %62, %49
br label %64
64: ; preds = %63, %27
br label %65
65: ; preds = %64, %16
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"header\00"
@.str.1 = [70 x i8] c"<style>BODY {FONT-FAMILY: Verdana,Helvetica; FONT-SIZE: 12px}</style>\00"
@.str.2 = [26 x i8] c"<CENTER><TABLE BORDER=1>\0A\00"
@.str.3 = [54 x i8] c"<TR><TD>Search</TD><TD>Link</TD><TD>Results</TD></TR>\00"
@.str.4 = [5 x i8] c"line\00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [4 x i8] c"<b>\00"
@.str.7 = [5 x i8] c"</b>\00"
@.str.8 = [98 x i8] c"<TR><TD>%s%s%s</TD><TD><A HREF=\22http://%s/search?%s\22>link</A></TD><TD align=\22RIGHT\22>%d</TD></TR>\0A\00"
@google_server = external global i8*
@.str.9 = [7 x i8] c"footer\00"
@.str.10 = [10 x i8] c"</TABLE>\0A\00"
@.str.11 = [101 x i8] c"<BR>gooscan by j0hnny<br><A HREF=\22http://johnny.ihackstuff.com\22>http://johnny.ihackstuff.com</A><BR>\00"
@.str.12 = [4 x i8] c"raw\00"
define void @writeit(i32* nocapture %0, i8* %1, i8* %2, i32 %3, i8* %4) {
%6 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %5
%9 = tail call i64 @fwrite(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.1, i64 0, i64 0), i64 69, i64 1, i32* %0)
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i64 25, i64 1, i32* %0)
%11 = tail call i64 @fwrite(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0), i64 53, i64 1, i32* %0)
br label %33
12: ; preds = %5
%13 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = icmp eq i32 %3, 0
%17 = select i1 %16, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0)
%18 = select i1 %16, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0)
%19 = load i8*, i8** @google_server
%20 = tail call i32 @inet_convert(i8* %1, i32 1)
%21 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str.8, i64 0, i64 0), i8* %17, i8* %2, i8* %18, i8* %19, i32 %20, i32 %3)
br label %33
22: ; preds = %12
%23 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = tail call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i64 9, i64 1, i32* %0)
%27 = tail call i64 @fwrite(i8* getelementptr inbounds ([101 x i8], [101 x i8]* @.str.11, i64 0, i64 0), i64 100, i64 1, i32* %0)
br label %33
28: ; preds = %22
%29 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = tail call i32 @fputs(i8* %2, i32* %0)
br label %33
33: ; preds = %15, %28, %31, %25, %8
ret void
}