#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 /*<<< orphan*/ LOG_INFO;
int /*<<< orphan*/ sendline(int, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, char *);
void exturlredirector(int sock, char *directorytolist) {
  char *rawurl = directorytolist + 4;
  char linebuff[1024];
  syslog(LOG_INFO,
         "The request is asking for a URL redirection - returned a html "
         "document redirecting to '%s'",
         rawurl);
  sendline(sock, "<!DOCTYPE html>");
  sendline(sock, "<html>");
  sendline(sock, "  <head>");
  sendline(sock, "    <title>Non-gopher link detected</title>");
  sprintf(linebuff, "    <meta http-equiv=\"refresh\" content=\"10;url=%s\">",
          rawurl);
  sendline(sock, linebuff);
  sendline(sock, "  </head>");
  sendline(sock, "  <body style=\"margin: 1em 2em 1em 2em; background-color: "
                 "#D0E0FF; color: #101010;\">");
  sendline(sock, "    <table style=\"margin-left: auto; margin-right: auto; "
                 "width: 70%%; border: 1px solid black; padding: 1.5em 1.1em "
                 "1.5em 1.1em; background-color: #E0F0FF;\">");
  sendline(sock, "      <tr>");
  sendline(sock, "        <td>");
  sendline(sock,
           "          <p style=\"text-align: center; font-size: 1.3em; margin: "
           "0 0 2em 0;\">A non-gopher link has been detected.</p>");
  sendline(sock, "          <p style=\"text-align: justify; margin: 0 0 0 "
                 "0;\">It appears that you clicked on a non-gopher link, which "
                 "will make you use another protocol from now on (typically "
                 "HTTP). Your gopher journey ends here.</p>");
  sendline(
      sock,
      "          <p style=\"text-align: center; margin: 0.8em 0 0 0;\">Click "
      "on the link below to continue (or wait 10 seconds):</p>");
  sprintf(linebuff,
          "          <p style=\"text-align: center; font-size: 1.1em; margin: "
          "0.8em 0 0 0;\"><a href=\"%s\" style=\"color: #0000F0;\">%s</a></p>",
          rawurl, rawurl);
  sendline(sock, linebuff);
  sendline(sock, "        </td>");
  sendline(sock, "      </tr>");
  sendline(sock, "    </table>");
  sendline(sock, "  </body>");
  sendline(sock, "</html>");
}


x86 assembly (clang, -O0):
<exturlredirector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe9e(%rip),%rsi
call   1040 <syslog@plt>
mov    -0x4(%rbp),%edi
lea    0xeea(%rip),%rsi
call   1030 <sendline@plt>
mov    -0x4(%rbp),%edi
lea    0xeeb(%rip),%rsi
call   1030 <sendline@plt>
mov    -0x4(%rbp),%edi
lea    0xee3(%rip),%rsi
call   1030 <sendline@plt>
mov    -0x4(%rbp),%edi
lea    0xedd(%rip),%rsi
call   1030 <sendline@plt>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xef2(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x4(%rbp),%edi
lea    -0x420(%rbp),%rsi
call   1030 <sendline@plt>
mov    -0x4(%rbp),%edi
lea    0xf06(%rip),%rsi
call   1030 <sendline@plt>
mov    -0x4(%rbp),%edi
lea    0xf01(%rip),%rsi
call   1030 <sendline@plt>
mov    -0x4(%rbp),%edi
lea    0xf47(%rip),%rsi
call   1030 <sendline@plt>
mov    -0x4(%rbp),%edi
lea    0xfd6(%rip),%rsi
call   1030 <sendline@plt>
mov    -0x4(%rbp),%edi
lea    0xfd2(%rip),%rsi
call   1030 <sendline@plt>
mov    -0x4(%rbp),%edi
lea    0xfd0(%rip),%rsi
call   1030 <sendline@plt>
mov    -0x4(%rbp),%edi
lea    0x1038(%rip),%rsi
call   1030 <sendline@plt>
mov    -0x4(%rbp),%edi
lea    0x1100(%rip),%rsi
call   1030 <sendline@plt>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0x1161(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x4(%rbp),%edi
lea    -0x420(%rbp),%rsi
call   1030 <sendline@plt>
mov    -0x4(%rbp),%edi
lea    0x11c1(%rip),%rsi
call   1030 <sendline@plt>
mov    -0x4(%rbp),%edi
lea    0x11c0(%rip),%rsi
call   1030 <sendline@plt>
mov    -0x4(%rbp),%edi
lea    0x11bd(%rip),%rsi
call   1030 <sendline@plt>
mov    -0x4(%rbp),%edi
lea    0x11bb(%rip),%rsi
call   1030 <sendline@plt>
mov    -0x4(%rbp),%edi
lea    0x11b6(%rip),%rsi
call   1030 <sendline@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exturlredirector>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %edi,%ebx
lea    0x4(%rsi),%r14
mov    0x2e97(%rip),%rax
mov    (%rax),%edi
lea    0xeae(%rip),%rsi
mov    %r14,%rdx
call   1040 <syslog@plt>
lea    0xefa(%rip),%rsi
mov    %ebx,%edi
call   1030 <sendline@plt>
lea    0xefc(%rip),%rsi
mov    %ebx,%edi
call   1030 <sendline@plt>
lea    0xef5(%rip),%rsi
mov    %ebx,%edi
call   1030 <sendline@plt>
lea    0xef0(%rip),%rsi
mov    %ebx,%edi
call   1030 <sendline@plt>
lea    0xf0e(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %ebx,%edi
mov    %r15,%rsi
call   1030 <sendline@plt>
lea    0xf21(%rip),%rsi
mov    %ebx,%edi
call   1030 <sendline@plt>
lea    0xf1d(%rip),%rsi
mov    %ebx,%edi
call   1030 <sendline@plt>
lea    0xf64(%rip),%rsi
mov    %ebx,%edi
call   1030 <sendline@plt>
lea    0xff4(%rip),%rsi
mov    %ebx,%edi
call   1030 <sendline@plt>
lea    0xff1(%rip),%rsi
mov    %ebx,%edi
call   1030 <sendline@plt>
lea    0xff0(%rip),%rsi
mov    %ebx,%edi
call   1030 <sendline@plt>
lea    0x1059(%rip),%rsi
mov    %ebx,%edi
call   1030 <sendline@plt>
lea    0x1122(%rip),%rsi
mov    %ebx,%edi
call   1030 <sendline@plt>
lea    0x1190(%rip),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %ebx,%edi
mov    %r15,%rsi
call   1030 <sendline@plt>
lea    0x11ef(%rip),%rsi
mov    %ebx,%edi
call   1030 <sendline@plt>
lea    0x11ef(%rip),%rsi
mov    %ebx,%edi
call   1030 <sendline@plt>
lea    0x11ed(%rip),%rsi
mov    %ebx,%edi
call   1030 <sendline@plt>
lea    0x11ec(%rip),%rsi
mov    %ebx,%edi
call   1030 <sendline@plt>
lea    0x11e8(%rip),%rsi
mov    %ebx,%edi
call   1030 <sendline@plt>
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@LOG_INFO = global i32 0
@.str = [91 x i8] c"The request is asking for a URL redirection - returned a html document redirecting to '%s'\00"
@.str.1 = [16 x i8] c"<!DOCTYPE html>\00"
@.str.2 = [7 x i8] c"<html>\00"
@.str.3 = [9 x i8] c" <head>\00"
@.str.4 = [44 x i8] c" <title>Non-gopher link detected</title>\00"
@.str.5 = [52 x i8] c" <meta http-equiv=\22refresh\22 content=\2210;url=%s\22>\00"
@.str.6 = [10 x i8] c" </head>\00"
@.str.7 = [85 x i8] c" <body style=\22margin: 1em 2em 1em 2em; background-color: #D0E0FF; color:;\22>\00"
@.str.8 = [158 x i8] c" <table style=\22margin-left: auto; margin-right: auto; width: 70%%; border: 1px solid black; padding: 1.5em 1.1em 1.5em 1.1em; background-color: #E0F0FF;\22>\00"
@.str.9 = [11 x i8] c" <tr>\00"
@.str.10 = [13 x i8] c" <td>\00"
@.str.11 = [119 x i8] c" <p style=\22text-align: center; font-size: 1.3em; margin: 0 0 2em 0;\22>A non-gopher link has been detected.</p>\00"
@.str.12 = [215 x i8] c" <p style=\22text-align: justify; margin: 0 0 0 0;\22>It appears that you clicked on a non-gopher link, which will make you use another protocol from now on (typically HTTP). Your gopher journey ends here.</p>\00"
@.str.13 = [124 x i8] c" <p style=\22text-align: center; margin: 0.8em 0 0 0;\22>Click on the link below to continue (or wait 10 seconds):</p>\00"
@.str.14 = [128 x i8] c" <p style=\22text-align: center; font-size: 1.1em; margin: 0.8em 0 0 0;\22><a href=\22%s\22 style=\22color:F0;\22>%s</a></p>\00"
@.str.15 = [14 x i8] c" </td>\00"
@.str.16 = [12 x i8] c" </tr>\00"
@.str.17 = [13 x i8] c" </table>\00"
@.str.18 = [10 x i8] c" </body>\00"
@.str.19 = [8 x i8] c"</html>\00"
define void @exturlredirector(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [1024 x i8]
store i32 %0, i32* %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = getelementptr inbounds i8, i8* %7, i64 4
store i8* %8, i8** %5
%9 = load i32, i32* @LOG_INFO
%10 = load i8*, i8** %5
%11 = call i32 @syslog(i32 %9, i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i32, i32* %3
%13 = call i32 @sendline(i32 %12, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* %3
%15 = call i32 @sendline(i32 %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* %3
%17 = call i32 @sendline(i32 %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%18 = load i32, i32* %3
%19 = call i32 @sendline(i32 %18, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%21 = load i8*, i8** %5
%22 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %20, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i8* %21)
%23 = load i32, i32* %3
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%25 = call i32 @sendline(i32 %23, i8* %24)
%26 = load i32, i32* %3
%27 = call i32 @sendline(i32 %26, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%28 = load i32, i32* %3
%29 = call i32 @sendline(i32 %28, i8* getelementptr inbounds ([85 x i8], [85 x i8]* @.str.7, i64 0, i64 0))
%30 = load i32, i32* %3
%31 = call i32 @sendline(i32 %30, i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str.8, i64 0, i64 0))
%32 = load i32, i32* %3
%33 = call i32 @sendline(i32 %32, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0))
%34 = load i32, i32* %3
%35 = call i32 @sendline(i32 %34, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
%36 = load i32, i32* %3
%37 = call i32 @sendline(i32 %36, i8* getelementptr inbounds ([119 x i8], [119 x i8]* @.str.11, i64 0, i64 0))
%38 = load i32, i32* %3
%39 = call i32 @sendline(i32 %38, i8* getelementptr inbounds ([215 x i8], [215 x i8]* @.str.12, i64 0, i64 0))
%40 = load i32, i32* %3
%41 = call i32 @sendline(i32 %40, i8* getelementptr inbounds ([124 x i8], [124 x i8]* @.str.13, i64 0, i64 0))
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%43 = load i8*, i8** %5
%44 = load i8*, i8** %5
%45 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %42, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @.str.14, i64 0, i64 0), i8* %43, i8* %44)
%46 = load i32, i32* %3
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%48 = call i32 @sendline(i32 %46, i8* %47)
%49 = load i32, i32* %3
%50 = call i32 @sendline(i32 %49, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.15, i64 0, i64 0))
%51 = load i32, i32* %3
%52 = call i32 @sendline(i32 %51, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i64 0, i64 0))
%53 = load i32, i32* %3
%54 = call i32 @sendline(i32 %53, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.17, i64 0, i64 0))
%55 = load i32, i32* %3
%56 = call i32 @sendline(i32 %55, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.18, i64 0, i64 0))
%57 = load i32, i32* %3
%58 = call i32 @sendline(i32 %57, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.19, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@LOG_INFO = global i32 0
@.str = [91 x i8] c"The request is asking for a URL redirection - returned a html document redirecting to '%s'\00"
@.str.1 = [16 x i8] c"<!DOCTYPE html>\00"
@.str.2 = [7 x i8] c"<html>\00"
@.str.3 = [9 x i8] c" <head>\00"
@.str.4 = [44 x i8] c" <title>Non-gopher link detected</title>\00"
@.str.5 = [52 x i8] c" <meta http-equiv=\22refresh\22 content=\2210;url=%s\22>\00"
@.str.6 = [10 x i8] c" </head>\00"
@.str.7 = [85 x i8] c" <body style=\22margin: 1em 2em 1em 2em; background-color: #D0E0FF; color:;\22>\00"
@.str.8 = [158 x i8] c" <table style=\22margin-left: auto; margin-right: auto; width: 70%%; border: 1px solid black; padding: 1.5em 1.1em 1.5em 1.1em; background-color: #E0F0FF;\22>\00"
@.str.9 = [11 x i8] c" <tr>\00"
@.str.10 = [13 x i8] c" <td>\00"
@.str.11 = [119 x i8] c" <p style=\22text-align: center; font-size: 1.3em; margin: 0 0 2em 0;\22>A non-gopher link has been detected.</p>\00"
@.str.12 = [215 x i8] c" <p style=\22text-align: justify; margin: 0 0 0 0;\22>It appears that you clicked on a non-gopher link, which will make you use another protocol from now on (typically HTTP). Your gopher journey ends here.</p>\00"
@.str.13 = [124 x i8] c" <p style=\22text-align: center; margin: 0.8em 0 0 0;\22>Click on the link below to continue (or wait 10 seconds):</p>\00"
@.str.14 = [128 x i8] c" <p style=\22text-align: center; font-size: 1.1em; margin: 0.8em 0 0 0;\22><a href=\22%s\22 style=\22color:F0;\22>%s</a></p>\00"
@.str.15 = [14 x i8] c" </td>\00"
@.str.16 = [12 x i8] c" </tr>\00"
@.str.17 = [13 x i8] c" </table>\00"
@.str.18 = [10 x i8] c" </body>\00"
@.str.19 = [8 x i8] c"</html>\00"
define void @exturlredirector(i32 %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds i8, i8* %1, i64 4
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = load i32, i32* @LOG_INFO
%7 = tail call i32 @syslog(i32 %6, i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str, i64 0, i64 0), i8* %4)
%8 = tail call i32 @sendline(i32 %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @sendline(i32 %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 @sendline(i32 %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%11 = tail call i32 @sendline(i32 %0, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i8* %4)
%13 = call i32 @sendline(i32 %0, i8* %5)
%14 = call i32 @sendline(i32 %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%15 = call i32 @sendline(i32 %0, i8* getelementptr inbounds ([85 x i8], [85 x i8]* @.str.7, i64 0, i64 0))
%16 = call i32 @sendline(i32 %0, i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str.8, i64 0, i64 0))
%17 = call i32 @sendline(i32 %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0))
%18 = call i32 @sendline(i32 %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
%19 = call i32 @sendline(i32 %0, i8* getelementptr inbounds ([119 x i8], [119 x i8]* @.str.11, i64 0, i64 0))
%20 = call i32 @sendline(i32 %0, i8* getelementptr inbounds ([215 x i8], [215 x i8]* @.str.12, i64 0, i64 0))
%21 = call i32 @sendline(i32 %0, i8* getelementptr inbounds ([124 x i8], [124 x i8]* @.str.13, i64 0, i64 0))
%22 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([128 x i8], [128 x i8]* @.str.14, i64 0, i64 0), i8* %4, i8* %4)
%23 = call i32 @sendline(i32 %0, i8* %5)
%24 = call i32 @sendline(i32 %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.15, i64 0, i64 0))
%25 = call i32 @sendline(i32 %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i64 0, i64 0))
%26 = call i32 @sendline(i32 %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.17, i64 0, i64 0))
%27 = call i32 @sendline(i32 %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.18, i64 0, i64 0))
%28 = call i32 @sendline(i32 %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.19, i64 0, i64 0))
ret void
}