#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ serv_addr;
typedef int /*<<< orphan*/ cli_addr;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int EOF;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fdopen(int, char *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int listen(int, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ sanitize(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int serv_sock, cli_sock;
  struct sockaddr_in serv_addr, cli_addr;
  socklen_t cli_size;
  int c;
  char cmd[1024], dirname[1024];
  FILE *sock_fpin, *sock_fpout, *pipe_fp;
  serv_sock = socket(AF_INET, SOCK_STREAM, 0);
  if (serv_sock == -1) {
    perror("socket() failed");
    exit(1);
  };
  memset(&serv_addr, 0, sizeof(serv_addr));
  serv_addr.sin_family = AF_INET;
  serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
  serv_addr.sin_port = htons(15000);
  if (bind(serv_sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) == -1) {
    perror("bind() failed");
    exit(1);
  };
  if (listen(serv_sock, 5) == -1) {
    perror("listen() failed");
    exit(1);
  };
  while (1) {
    cli_size = sizeof(cli_addr);
    cli_sock = accept(serv_sock, (struct sockaddr *)&cli_addr, &cli_size);
    if (cli_sock == -1) {
      perror("accept() failed");
      exit(1);
    };
    sock_fpin = fdopen(cli_sock, "r");
    if (sock_fpin == NULL) {
      perror("fdopen() reading failed");
      exit(1);
    };
    if (fgets(dirname, 1024, sock_fpin) == NULL) {
      perror("fgets() failed");
      exit(1);
    };
    sanitize(dirname);
    sock_fpout = fdopen(cli_sock, "w");
    if (sock_fpout == NULL) {
      perror("fdopen() writing failed");
      exit(1);
    };
    snprintf(cmd, 1024, "ls %s", dirname);
    if ((pipe_fp = popen(cmd, "r")) == NULL) {
      perror("popen() failed");
      exit(1);
    };
    while ((c = getc(pipe_fp)) != EOF)
      putc(c, sock_fpout);
    fflush(sock_fpout);
    pclose(pipe_fp);
    fclose(sock_fpin);
    fclose(sock_fpout);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x860,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2d98(%rip),%rax
mov    (%rax),%edi
mov    0x2d6f(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1285 <main+0x55>
lea    0xd8a(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    0x2d4c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2d38(%rip),%rax
mov    (%rax),%edi
call   1070 <htonl@plt>
mov    %eax,-0x24(%rbp)
mov    $0x3a98,%edi
call   1040 <htons@plt>
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0xc,%edx
call   10e0 <bind@plt>
cmp    $0xffffffff,%eax
jne    12ef <main+0xbf>
lea    0xd30(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x14(%rbp),%edi
mov    $0x5,%esi
call   10c0 <listen@plt>
cmp    $0xffffffff,%eax
jne    131b <main+0xeb>
lea    0xd12(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
jmp    1320 <main+0xf0>
movl   $0xc,-0x3c(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x38(%rbp),%rsi
lea    -0x3c(%rbp),%rdx
call   1110 <accept@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    135a <main+0x12a>
lea    0xce3(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x18(%rbp),%edi
lea    0xcda(%rip),%rsi
call   10d0 <fdopen@plt>
mov    %rax,-0x848(%rbp)
cmpq   $0x0,-0x848(%rbp)
jne    1394 <main+0x164>
lea    0xcbb(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
lea    -0x840(%rbp),%rdi
mov    -0x848(%rbp),%rdx
mov    $0x400,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
jne    13cc <main+0x19c>
lea    0xc9b(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
lea    -0x840(%rbp),%rdi
call   1130 <sanitize@plt>
mov    -0x18(%rbp),%edi
lea    0xc85(%rip),%rsi
call   10d0 <fdopen@plt>
mov    %rax,-0x850(%rbp)
cmpq   $0x0,-0x850(%rbp)
jne    1412 <main+0x1e2>
lea    0xc66(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
lea    -0x440(%rbp),%rdi
lea    -0x840(%rbp),%rcx
mov    $0x400,%esi
lea    0xc55(%rip),%rdx
call   1060 <snprintf@plt>
lea    -0x440(%rbp),%rdi
lea    0xbff(%rip),%rsi
call   10f0 <popen@plt>
mov    %rax,-0x858(%rbp)
cmp    $0x0,%rax
jne    146b <main+0x23b>
lea    0xc2b(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
jmp    1470 <main+0x240>
mov    -0x858(%rbp),%rdi
call   1140 <getc@plt>
mov    %eax,-0x40(%rbp)
mov    0x2b52(%rip),%rcx
cmp    (%rcx),%eax
je     14a2 <main+0x272>
mov    -0x40(%rbp),%edi
mov    -0x850(%rbp),%rsi
call   10a0 <putc@plt>
jmp    1470 <main+0x240>
mov    -0x850(%rbp),%rdi
call   10b0 <fflush@plt>
mov    -0x858(%rbp),%rdi
call   1050 <pclose@plt>
mov    -0x848(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x850(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1320 <main+0xf0>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x838,%rsp
mov    0x2da0(%rip),%rbx
mov    (%rbx),%edi
mov    0x2d77(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
cmp    $0xffffffff,%eax
jne    126b <main+0x3b>
lea    0xd9a(%rip),%rdi
jmp    1303 <main+0xd3>
mov    %eax,%ebp
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    (%rbx),%eax
mov    %eax,0x18(%rsp)
mov    0x2d52(%rip),%rax
mov    (%rax),%edi
call   1070 <htonl@plt>
mov    %eax,0x14(%rsp)
mov    $0x3a98,%edi
call   1040 <htons@plt>
mov    %eax,0x10(%rsp)
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   10e0 <bind@plt>
cmp    $0xffffffff,%eax
jne    12c4 <main+0x94>
lea    0xd4e(%rip),%rdi
jmp    1303 <main+0xd3>
mov    %ebp,%edi
mov    $0x5,%esi
call   10c0 <listen@plt>
cmp    $0xffffffff,%eax
jne    12de <main+0xae>
lea    0xd42(%rip),%rdi
jmp    1303 <main+0xd3>
movl   $0xc,0xc(%rsp)
lea    0x20(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %ebp,%edi
call   1110 <accept@plt>
cmp    $0xffffffff,%eax
jne    1312 <main+0xe2>
lea    0xd2b(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    %eax,%ebx
lea    0x30(%rsp),%r14
mov    0x2cb8(%rip),%r13
jmp    1370 <main+0x140>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
call   10b0 <fflush@plt>
mov    %rbx,%rdi
call   1050 <pclose@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    %r12,%rdi
call   1030 <fclose@plt>
movl   $0xc,0xc(%rsp)
mov    %ebp,%edi
lea    0x20(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1110 <accept@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     12fc <main+0xcc>
mov    %ebx,%edi
lea    0xcc5(%rip),%rsi
call   10d0 <fdopen@plt>
test   %rax,%rax
je     141e <main+0x1ee>
mov    %rax,%r15
mov    %r14,%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     142a <main+0x1fa>
mov    %r14,%rdi
call   1130 <sanitize@plt>
mov    %ebx,%edi
lea    0xcb3(%rip),%rsi
call   10d0 <fdopen@plt>
test   %rax,%rax
je     1436 <main+0x206>
mov    %rax,%r12
lea    0x430(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
lea    0xca9(%rip),%rdx
mov    %r14,%rcx
call   1060 <snprintf@plt>
mov    %rbx,%rdi
lea    0xc54(%rip),%rsi
call   10f0 <popen@plt>
test   %rax,%rax
je     1442 <main+0x212>
mov    %rax,%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1140 <getc@plt>
cmp    0x0(%r13),%eax
je     1330 <main+0x100>
mov    %eax,%edi
mov    %r12,%rsi
call   10a0 <putc@plt>
jmp    1400 <main+0x1d0>
lea    0xc1b(%rip),%rdi
jmp    1303 <main+0xd3>
lea    0xc27(%rip),%rdi
jmp    1303 <main+0xd3>
lea    0xc2c(%rip),%rdi
jmp    1303 <main+0xd3>
lea    0xc3e(%rip),%rdi
jmp    1303 <main+0xd3>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [16 x i8] c"socket() failed\00"
@INADDR_ANY = global i32 0
@.str.1 = [14 x i8] c"bind() failed\00"
@.str.2 = [16 x i8] c"listen() failed\00"
@.str.3 = [16 x i8] c"accept() failed\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [24 x i8] c"fdopen() reading failed\00"
@.str.6 = [15 x i8] c"fgets() failed\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [24 x i8] c"fdopen() writing failed\00"
@.str.9 = [6 x i8] c"ls %s\00"
@.str.10 = [15 x i8] c"popen() failed\00"
@EOF = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.sockaddr_in
%9 = alloca %struct.sockaddr_in
%10 = alloca i32
%11 = alloca i32
%12 = alloca [1024 x i8]
%13 = alloca [1024 x i8]
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i32, i32* @AF_INET
%18 = load i32, i32* @SOCK_STREAM
%19 = call i32 @socket(i32 %17, i32 %18, i32 0)
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %25
22: ; preds = %2
%23 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %2
%26 = call i32 @memset(%struct.sockaddr_in* %8, i32 0, i32 12)
%27 = load i32, i32* @AF_INET
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 2
store i32 %27, i32* %28
%29 = load i32, i32* @INADDR_ANY
%30 = call i32 @htonl(i32 %29)
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
%32 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %31, i32 0, i32 0
store i32 %30, i32* %32
%33 = call i32 @htons(i32 15000)
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
store i32 %33, i32* %34
%35 = load i32, i32* %6
%36 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%37 = call i32 @bind(i32 %35, %struct.sockaddr* %36, i32 12)
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %42
39: ; preds = %25
%40 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %25
%43 = load i32, i32* %6
%44 = call i32 @listen(i32 %43, i32 5)
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %49
46: ; preds = %42
%47 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %42
br label %50
50: ; preds = %49, %105
store i32 12, i32* %10
%51 = load i32, i32* %6
%52 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%53 = call i32 @accept(i32 %51, %struct.sockaddr* %52, i32* %10)
store i32 %53, i32* %7
%54 = load i32, i32* %7
%55 = icmp eq i32 %54, -1
br i1 %55, label %56, label %59
56: ; preds = %50
%57 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%58 = call i32 @exit(i32 1)
unreachable
59: ; preds = %50
%60 = load i32, i32* %7
%61 = call i32* @fdopen(i32 %60, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %61, i32** %14
%62 = load i32*, i32** %14
%63 = icmp eq i32* %62, null
br i1 %63, label %64, label %67
64: ; preds = %59
%65 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %59
%68 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%69 = load i32*, i32** %14
%70 = call i32* @fgets(i8* %68, i32 1024, i32* %69)
%71 = icmp eq i32* %70, null
br i1 %71, label %72, label %75
72: ; preds = %67
%73 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%74 = call i32 @exit(i32 1)
unreachable
75: ; preds = %67
%76 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%77 = call i32 @sanitize(i8* %76)
%78 = load i32, i32* %7
%79 = call i32* @fdopen(i32 %78, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %79, i32** %15
%80 = load i32*, i32** %15
%81 = icmp eq i32* %80, null
br i1 %81, label %82, label %85
82: ; preds = %75
%83 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
%84 = call i32 @exit(i32 1)
unreachable
85: ; preds = %75
%86 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%87 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%88 = call i32 @snprintf(i8* %86, i32 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i8* %87)
%89 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%90 = call i32* @popen(i8* %89, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %90, i32** %16
%91 = icmp eq i32* %90, null
br i1 %91, label %92, label %95
92: ; preds = %85
%93 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0))
%94 = call i32 @exit(i32 1)
unreachable
95: ; preds = %85
br label %96
96: ; preds = %101, %95
%97 = load i32*, i32** %16
%98 = call i32 @getc(i32* %97)
store i32 %98, i32* %11
%99 = load i32, i32* @EOF
%100 = icmp ne i32 %98, %99
br i1 %100, label %101, label %105
101: ; preds = %96
%102 = load i32, i32* %11
%103 = load i32*, i32** %15
%104 = call i32 @putc(i32 %102, i32* %103)
br label %96
105: ; preds = %96
%106 = load i32*, i32** %15
%107 = call i32 @fflush(i32* %106)
%108 = load i32*, i32** %16
%109 = call i32 @pclose(i32* %108)
%110 = load i32*, i32** %14
%111 = call i32 @fclose(i32* %110)
%112 = load i32*, i32** %15
%113 = call i32 @fclose(i32* %112)
br label %50
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [16 x i8] c"socket() failed\00"
@INADDR_ANY = global i32 0
@.str.1 = [14 x i8] c"bind() failed\00"
@.str.2 = [16 x i8] c"listen() failed\00"
@.str.3 = [16 x i8] c"accept() failed\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [24 x i8] c"fdopen() reading failed\00"
@.str.6 = [15 x i8] c"fgets() failed\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [24 x i8] c"fdopen() writing failed\00"
@.str.9 = [6 x i8] c"ls %s\00"
@.str.10 = [15 x i8] c"popen() failed\00"
@EOF = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = alloca [1024 x i8]
%7 = alloca [1024 x i8]
%8 = bitcast %struct.sockaddr_in* %3 to i8*
%9 = bitcast %struct.sockaddr_in* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%13 = load i32, i32* @AF_INET
%14 = load i32, i32* @SOCK_STREAM
%15 = tail call i32 @socket(i32 %13, i32 %14, i32 0)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%19 = tail call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 12)
%22 = load i32, i32* @AF_INET
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %22, i32* %23
%24 = load i32, i32* @INADDR_ANY
%25 = call i32 @htonl(i32 %24)
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %25, i32* %26
%27 = call i32 @htons(i32 15000)
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %27, i32* %28
%29 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%30 = call i32 @bind(i32 %15, %struct.sockaddr* %29, i32 12)
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %35
32: ; preds = %20
%33 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %20
%36 = call i32 @listen(i32 %15, i32 5)
%37 = icmp eq i32 %36, -1
br i1 %37, label %42, label %38
38: ; preds = %35
%39 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
store i32 12, i32* %5
%40 = call i32 @accept(i32 %15, %struct.sockaddr* %39, i32* %5)
%41 = icmp eq i32 %40, -1
br i1 %41, label %45, label %48
42: ; preds = %35
%43 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %85, %38
%46 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %38, %85
%49 = phi i32 [ %90, %85 ], [ %40, %38 ]
%50 = call i32* @fdopen(i32 %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%51 = icmp eq i32* %50, null
br i1 %51, label %52, label %55
52: ; preds = %48
%53 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %48
%56 = call i32* @fgets(i8* %12, i32 1024, i32* %50)
%57 = icmp eq i32* %56, null
br i1 %57, label %58, label %61
58: ; preds = %55
%59 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%60 = call i32 @exit(i32 1)
unreachable
61: ; preds = %55
%62 = call i32 @sanitize(i8* %12)
%63 = call i32* @fdopen(i32 %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%64 = icmp eq i32* %63, null
br i1 %64, label %65, label %68
65: ; preds = %61
%66 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
%67 = call i32 @exit(i32 1)
unreachable
68: ; preds = %61
%69 = call i32 @snprintf(i8* %11, i32 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i8* %12)
%70 = call i32* @popen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%71 = icmp eq i32* %70, null
br i1 %71, label %76, label %72
72: ; preds = %68
%73 = call i32 @getc(i32* %70)
%74 = load i32, i32* @EOF
%75 = icmp eq i32 %73, %74
br i1 %75, label %85, label %79
76: ; preds = %68
%77 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0))
%78 = call i32 @exit(i32 1)
unreachable
79: ; preds = %72, %79
%80 = phi i32 [ %82, %79 ], [ %73, %72 ]
%81 = call i32 @putc(i32 %80, i32* %63)
%82 = call i32 @getc(i32* %70)
%83 = load i32, i32* @EOF
%84 = icmp eq i32 %82, %83
br i1 %84, label %85, label %79
85: ; preds = %79, %72
%86 = call i32 @fflush(i32* %63)
%87 = call i32 @pclose(i32* %70)
%88 = call i32 @fclose(i32* %50)
%89 = call i32 @fclose(i32* %63)
store i32 12, i32* %5
%90 = call i32 @accept(i32 %15, %struct.sockaddr* %39, i32* %5)
%91 = icmp eq i32 %90, -1
br i1 %91, label %45, label %48
}