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

/* Variables and functions */
int BUFSIZ;
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ dup2(int, int);
int /*<<< orphan*/ execl(char *, char *, char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fork();
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
char *malloc(int);
int /*<<< orphan*/ mkstemp(char *);
int /*<<< orphan*/ pipe(int *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int ssl_or_tcp_read(int /*<<< orphan*/ *, int, char *, int);
int ssl_or_tcp_write(int /*<<< orphan*/ *, int, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ strstr(char *, char *);
int run_php_prog_ssl(SSL *ssl, int sock) {
  char ftempname[BUFSIZ];
  char tmpname[BUFSIZ];
  char buf[BUFSIZ];
  int pid;
  int err;
  int n, p, totaln;
  int pipefd[2];
  FILE *fp;
  char *data = NULL;
  char *data1 = NULL;
  bzero(buf, sizeof(buf));
  while (1) {
    err = ssl_or_tcp_read(ssl, sock, buf, sizeof(buf) - 1);
    if (err <= 0) {
      printf("Got EOF\n");
      break;
    }
    buf[err] = '\0';
    if (data) {
      data1 = malloc(strlen(data) + strlen(buf) + 1);
      sprintf(data1, "%s%s", data, buf);
      data = data1;
    } else {
      data = malloc(strlen(buf) + 1);
      strcpy(data, buf);
    }
    if (strstr(data, "___...___")) {
      break;
    }
  }
  printf("Input %d %s\n", strlen(data), data);
  bzero(buf, sizeof(buf));
  strcpy(tmpname, "/tmp/lxlabs_backendXXXXXX");
  mkstemp(tmpname);
  fp = fopen(tmpname, "w");
  fwrite(data, strlen(data), 1, fp);
  fclose(fp);
  snprintf(ftempname, sizeof(ftempname), "--temp-input-file=%s", tmpname);
  pipe(pipefd);
  pid = fork();
  if (pid == 0) {
    dup2(pipefd[1], 1);
    close(pipefd[0]);
    execl("/usr/bin/lxphp.exe", "lxphp.exe", "../bin/common/process_single.php",
          ftempname, NULL);
    printf("Exec failed\n");
    exit(0);
  } else {
    close(pipefd[1]);
    printf("Pipe %d\n", pipefd[0]);
    while (1) {
      n = read(pipefd[0], buf, sizeof(buf));
      totaln += n;
      if (n > 0) {
        p = ssl_or_tcp_write(ssl, sock, buf, n);
      } else {
        printf("Got %d\n\n", totaln);
        while (1) {
          bzero(tmpname, sizeof(tmpname));
          p = ssl_or_tcp_read(ssl, sock, tmpname, sizeof(tmpname));
          printf("Got %s\n\n", tmpname);
          if (p <= 0) {
            break;
          }
        }
        break;
      }
    }
  }
  exit(0);
}


x86 assembly (clang, -O0):
<run_php_prog_ssl>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2d77(%rip),%rax
mov    (%rax),%ecx
mov    %rcx,-0x98(%rbp)
mov    %rsp,%rdx
mov    %rdx,-0x18(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x90(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x20(%rbp)
mov    (%rax),%ecx
mov    %rcx,-0x88(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x80(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x28(%rbp)
mov    (%rax),%eax
mov    %rax,-0x78(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x70(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x60(%rbp)
movq   $0x0,-0x68(%rbp)
mov    %eax,%esi
call   1110 <bzero@plt>
jmp    12fb <run_php_prog_ssl+0xab>
mov    -0x70(%rbp),%rdx
mov    -0x78(%rbp),%rax
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
sub    $0x1,%rax
mov    %eax,%ecx
call   10f0 <ssl_or_tcp_read@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jg     1335 <run_php_prog_ssl+0xe5>
lea    0xcd7(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    13e5 <run_php_prog_ssl+0x195>
mov    -0x70(%rbp),%rax
movslq -0x38(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
cmpq   $0x0,-0x60(%rbp)
je     139d <run_php_prog_ssl+0x14d>
mov    -0x60(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x70(%rbp),%rdi
mov    %eax,-0x9c(%rbp)
call   1060 <strlen@plt>
mov    -0x9c(%rbp),%edi
add    %eax,%edi
add    $0x1,%edi
call   10d0 <malloc@plt>
mov    -0x70(%rbp),%rcx
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rdi
mov    -0x60(%rbp),%rdx
lea    0xc7e(%rip),%rsi
call   1120 <sprintf@plt>
mov    -0x68(%rbp),%rax
mov    %rax,-0x60(%rbp)
jmp    13c1 <run_php_prog_ssl+0x171>
mov    -0x70(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
call   10d0 <malloc@plt>
mov    -0x70(%rbp),%rsi
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rdi
call   1030 <strcpy@plt>
mov    -0x60(%rbp),%rdi
lea    0xc42(%rip),%rsi
call   1170 <strstr@plt>
cmp    $0x0,%rax
je     13e0 <run_php_prog_ssl+0x190>
jmp    13e5 <run_php_prog_ssl+0x195>
jmp    12f6 <run_php_prog_ssl+0xa6>
mov    -0x60(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%esi
mov    -0x60(%rbp),%rdx
lea    0xc1d(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%rax
mov    %eax,%esi
call   1110 <bzero@plt>
mov    -0x80(%rbp),%rdi
lea    0xc09(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x80(%rbp),%rdi
call   10e0 <mkstemp@plt>
mov    -0x80(%rbp),%rdi
lea    0xc0a(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x58(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x60(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xa8(%rbp),%rdi
mov    %eax,%esi
mov    -0x58(%rbp),%rcx
mov    $0x1,%edx
call   1140 <fwrite@plt>
mov    -0x58(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x90(%rbp),%rdi
mov    -0x80(%rbp),%rcx
mov    -0x98(%rbp),%rax
mov    %eax,%esi
lea    0xbb4(%rip),%rdx
call   1090 <snprintf@plt>
lea    -0x4c(%rbp),%rdi
call   10b0 <pipe@plt>
mov    $0x0,%al
call   1160 <fork@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    14ff <run_php_prog_ssl+0x2af>
mov    -0x48(%rbp),%edi
mov    $0x1,%esi
call   1070 <dup2@plt>
mov    -0x4c(%rbp),%edi
call   10a0 <close@plt>
mov    -0x90(%rbp),%rcx
lea    0xb84(%rip),%rdi
lea    0xb86(%rip),%rsi
lea    0xb89(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
call   1150 <execl@plt>
lea    0xb99(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
xor    %edi,%edi
call   1130 <exit@plt>
mov    -0x48(%rbp),%edi
call   10a0 <close@plt>
mov    -0x4c(%rbp),%esi
lea    0xb86(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    151d <run_php_prog_ssl+0x2cd>
mov    -0x70(%rbp),%rsi
mov    -0x78(%rbp),%rax
mov    -0x4c(%rbp),%edi
mov    %eax,%edx
call   10c0 <read@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
add    -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jle    1560 <run_php_prog_ssl+0x310>
mov    -0x70(%rbp),%rdx
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x3c(%rbp),%ecx
call   1040 <ssl_or_tcp_write@plt>
mov    %eax,-0x40(%rbp)
jmp    15cf <run_php_prog_ssl+0x37f>
mov    -0x44(%rbp),%esi
lea    0xb36(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1576 <run_php_prog_ssl+0x326>
mov    -0x80(%rbp),%rdi
mov    -0x88(%rbp),%rax
mov    %eax,%esi
call   1110 <bzero@plt>
mov    -0x80(%rbp),%rdx
mov    -0x88(%rbp),%rax
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    %eax,%ecx
call   10f0 <ssl_or_tcp_read@plt>
mov    -0x80(%rbp),%rsi
mov    %eax,-0x40(%rbp)
lea    0xafa(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
cmpl   $0x0,-0x40(%rbp)
jg     15c5 <run_php_prog_ssl+0x375>
jmp    15ca <run_php_prog_ssl+0x37a>
jmp    1571 <run_php_prog_ssl+0x321>
jmp    15d4 <run_php_prog_ssl+0x384>
jmp    1518 <run_php_prog_ssl+0x2c8>
jmp    15d9 <run_php_prog_ssl+0x389>
xor    %edi,%edi
call   1130 <exit@plt>

x86 assembly (clang, -O2):
<run_php_prog_ssl>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %esi,-0x2c(%rbp)
mov    %rdi,%r12
mov    0x2d62(%rip),%rax
mov    (%rax),%ebx
mov    %rsp,%rcx
mov    %rbx,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rsp,%rcx
sub    %rax,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rsp,%r15
sub    %rax,%r15
mov    %r15,%rsp
mov    %r15,%rdi
mov    %ebx,%esi
call   1120 <bzero@plt>
mov    %rbx,%r13
lea    -0x1(%rbx),%eax
mov    %eax,-0x38(%rbp)
xor    %r14d,%r14d
jmp    131c <run_php_prog_ssl+0xbc>
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1070 <strlen@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1070 <strlen@plt>
lea    (%rbx,%rax,1),%edi
add    $0x1,%edi
call   10e0 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
lea    0xd06(%rip),%rsi
mov    %r14,%rdx
mov    %r15,%rcx
call   1130 <sprintf@plt>
mov    %rbx,%r14
mov    %r14,%rdi
lea    0xcf3(%rip),%rsi
call   1180 <strstr@plt>
test   %rax,%rax
jne    1369 <run_php_prog_ssl+0x109>
mov    %r12,%rdi
mov    -0x2c(%rbp),%esi
mov    %r15,%rdx
mov    -0x38(%rbp),%ecx
call   1100 <ssl_or_tcp_read@plt>
test   %eax,%eax
jle    135d <run_php_prog_ssl+0xfd>
mov    %eax,%eax
movb   $0x0,(%r15,%rax,1)
test   %r14,%r14
jne    12d0 <run_php_prog_ssl+0x70>
mov    %r15,%rdi
call   1070 <strlen@plt>
lea    0x1(%rax),%edi
call   10e0 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
jmp    1308 <run_php_prog_ssl+0xa8>
lea    0xd44(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1070 <strlen@plt>
lea    0xc97(%rip),%rdi
mov    %eax,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %r13,-0x48(%rbp)
call   1120 <bzero@plt>
lea    0xc82(%rip),%rsi
mov    -0x40(%rbp),%r13
mov    %r13,%rdi
call   1030 <strcpy@plt>
mov    %r13,%rdi
call   10f0 <mkstemp@plt>
lea    0xc81(%rip),%rsi
mov    %r13,%rdi
call   1110 <fopen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1070 <strlen@plt>
mov    %r14,%rdi
mov    -0x48(%rbp),%r14
mov    %eax,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1150 <fwrite@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
lea    0xc4b(%rip),%rdx
mov    -0x50(%rbp),%rbx
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %r13,%rcx
call   10a0 <snprintf@plt>
lea    -0x34(%rbp),%rdi
call   10c0 <pipe@plt>
xor    %eax,%eax
call   1170 <fork@plt>
mov    -0x30(%rbp),%edi
test   %eax,%eax
jne    145b <run_php_prog_ssl+0x1fb>
mov    $0x1,%esi
call   1080 <dup2@plt>
mov    -0x34(%rbp),%edi
call   10b0 <close@plt>
lea    0xc1e(%rip),%rdi
lea    0xc20(%rip),%rsi
lea    0xc23(%rip),%rdx
mov    %rbx,%rcx
xor    %r8d,%r8d
call   1160 <execl@plt>
lea    0xc4d(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1140 <exit@plt>
call   10b0 <close@plt>
mov    -0x34(%rbp),%esi
lea    0xc17(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    -0x34(%rbp),%edi
mov    %r15,%rsi
mov    %r14d,%edx
call   10d0 <read@plt>
mov    -0x2c(%rbp),%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12,%rdi
mov    %r13d,%esi
mov    %r15,%rdx
mov    %eax,%ecx
call   1050 <ssl_or_tcp_write@plt>
mov    -0x34(%rbp),%edi
mov    %r15,%rsi
mov    %r14d,%edx
call   10d0 <read@plt>
add    %eax,%ebx
test   %eax,%eax
jg     1490 <run_php_prog_ssl+0x230>
lea    0xbcf(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r14,%r15
mov    -0x40(%rbp),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15d,%esi
call   1120 <bzero@plt>
mov    %r12,%rdi
mov    %r13d,%esi
mov    %r14,%rdx
mov    %r15d,%ecx
call   1100 <ssl_or_tcp_read@plt>
mov    %eax,%ebx
lea    0xb9e(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
test   %ebx,%ebx
jg     14d0 <run_php_prog_ssl+0x270>
xor    %edi,%edi
call   1140 <exit@plt>

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [9 x i8] c"Got EOF\0A\00"
@.str.1 = [5 x i8] c"%s%s\00"
@.str.2 = [10 x i8] c"___...___\00"
@.str.3 = [13 x i8] c"Input %d %s\0A\00"
@.str.4 = [26 x i8] c"/tmp/lxlabs_backendXXXXXX\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [21 x i8] c"--temp-input-file=%s\00"
@.str.7 = [19 x i8] c"/usr/bin/lxphp.exe\00"
@.str.8 = [10 x i8] c"lxphp.exe\00"
@.str.9 = [33 x i8] c"../bin/common/process_single.php\00"
@.str.10 = [13 x i8] c"Exec failed\0A\00"
@.str.11 = [9 x i8] c"Pipe %d\0A\00"
@.str.12 = [9 x i8] c"Got %d\0A\0A\00"
@.str.13 = [9 x i8] c"Got %s\0A\0A\00"
define i32 @run_php_prog_ssl(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca [2 x i32]
%15 = alloca i32*
%16 = alloca i8*
%17 = alloca i8*
store i32* %0, i32** %3
store i32 %1, i32* %4
%18 = load i32, i32* @BUFSIZ
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %5
%21 = alloca i8, i64 %19
store i64 %19, i64* %6
%22 = load i32, i32* @BUFSIZ
%23 = zext i32 %22 to i64
%24 = alloca i8, i64 %23
store i64 %23, i64* %7
%25 = load i32, i32* @BUFSIZ
%26 = zext i32 %25 to i64
%27 = alloca i8, i64 %26
store i64 %26, i64* %8
store i8* null, i8** %16
store i8* null, i8** %17
%28 = trunc i64 %26 to i32
%29 = call i32 @bzero(i8* %27, i32 %28)
br label %30
30: ; preds = %69, %2
br label %31
31: ; preds = %30
%32 = load i32*, i32** %3
%33 = load i32, i32* %4
%34 = sub i64 %26, 1
%35 = trunc i64 %34 to i32
%36 = call i32 @ssl_or_tcp_read(i32* %32, i32 %33, i8* %27, i32 %35)
store i32 %36, i32* %10
%37 = load i32, i32* %10
%38 = icmp sle i32 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %31
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %70
41: ; preds = %31
%42 = load i32, i32* %10
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %27, i64 %43
store i8 0, i8* %44
%45 = load i8*, i8** %16
%46 = icmp ne i8* %45, null
br i1 %46, label %47, label %58
47: ; preds = %41
%48 = load i8*, i8** %16
%49 = call i32 @strlen(i8* %48)
%50 = call i32 @strlen(i8* %27)
%51 = add nsw i32 %49, %50
%52 = add nsw i32 %51, 1
%53 = call i8* @malloc(i32 %52)
store i8* %53, i8** %17
%54 = load i8*, i8** %17
%55 = load i8*, i8** %16
%56 = call i32 @sprintf(i8* %54, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %55, i8* %27)
%57 = load i8*, i8** %17
store i8* %57, i8** %16
br label %64
58: ; preds = %41
%59 = call i32 @strlen(i8* %27)
%60 = add nsw i32 %59, 1
%61 = call i8* @malloc(i32 %60)
store i8* %61, i8** %16
%62 = load i8*, i8** %16
%63 = call i32 @strcpy(i8* %62, i8* %27)
br label %64
64: ; preds = %58, %47
%65 = load i8*, i8** %16
%66 = call i64 @strstr(i8* %65, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%67 = icmp ne i64 %66, 0
br i1 %67, label %68, label %69
68: ; preds = %64
br label %70
69: ; preds = %64
br label %30
70: ; preds = %68, %39
%71 = load i8*, i8** %16
%72 = call i32 @strlen(i8* %71)
%73 = load i8*, i8** %16
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %72, i8* %73)
%75 = trunc i64 %26 to i32
%76 = call i32 @bzero(i8* %27, i32 %75)
%77 = call i32 @strcpy(i8* %24, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%78 = call i32 @mkstemp(i8* %24)
%79 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %79, i32** %15
%80 = load i8*, i8** %16
%81 = load i8*, i8** %16
%82 = call i32 @strlen(i8* %81)
%83 = load i32*, i32** %15
%84 = call i32 @fwrite(i8* %80, i32 %82, i32 1, i32* %83)
%85 = load i32*, i32** %15
%86 = call i32 @fclose(i32* %85)
%87 = trunc i64 %19 to i32
%88 = call i32 @snprintf(i8* %21, i32 %87, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %24)
%89 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%90 = call i32 @pipe(i32* %89)
%91 = call i32 (...) @fork()
store i32 %91, i32* %9
%92 = load i32, i32* %9
%93 = icmp eq i32 %92, 0
br i1 %93, label %94, label %104
94: ; preds = %70
%95 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 1
%96 = load i32, i32* %95
%97 = call i32 @dup2(i32 %96, i32 1)
%98 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%99 = load i32, i32* %98
%100 = call i32 @close(i32 %99)
%101 = call i32 @execl(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i8* %21, i32* null)
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
%103 = call i32 @exit(i32 0)
unreachable
104: ; preds = %70
%105 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 1
%106 = load i32, i32* %105
%107 = call i32 @close(i32 %106)
%108 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%109 = load i32, i32* %108
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), i32 %109)
br label %111
111: ; preds = %144, %104
br label %112
112: ; preds = %111
%113 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%114 = load i32, i32* %113
%115 = trunc i64 %26 to i32
%116 = call i32 @read(i32 %114, i8* %27, i32 %115)
store i32 %116, i32* %11
%117 = load i32, i32* %11
%118 = load i32, i32* %13
%119 = add nsw i32 %118, %117
store i32 %119, i32* %13
%120 = load i32, i32* %11
%121 = icmp sgt i32 %120, 0
br i1 %121, label %122, label %127
122: ; preds = %112
%123 = load i32*, i32** %3
%124 = load i32, i32* %4
%125 = load i32, i32* %11
%126 = call i32 @ssl_or_tcp_write(i32* %123, i32 %124, i8* %27, i32 %125)
store i32 %126, i32* %12
br label %144
127: ; preds = %112
%128 = load i32, i32* %13
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %128)
br label %130
130: ; preds = %142, %127
br label %131
131: ; preds = %130
%132 = trunc i64 %23 to i32
%133 = call i32 @bzero(i8* %24, i32 %132)
%134 = load i32*, i32** %3
%135 = load i32, i32* %4
%136 = trunc i64 %23 to i32
%137 = call i32 @ssl_or_tcp_read(i32* %134, i32 %135, i8* %24, i32 %136)
store i32 %137, i32* %12
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i64 0, i64 0), i8* %24)
%139 = load i32, i32* %12
%140 = icmp sle i32 %139, 0
br i1 %140, label %141, label %142
141: ; preds = %131
br label %143
142: ; preds = %131
br label %130
143: ; preds = %141
br label %145
144: ; preds = %122
br label %111
145: ; preds = %143
br label %146
146: ; preds = %145
%147 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str.1 = [5 x i8] c"%s%s\00"
@.str.2 = [10 x i8] c"___...___\00"
@.str.3 = [13 x i8] c"Input %d %s\0A\00"
@.str.4 = [26 x i8] c"/tmp/lxlabs_backendXXXXXX\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [21 x i8] c"--temp-input-file=%s\00"
@.str.7 = [19 x i8] c"/usr/bin/lxphp.exe\00"
@.str.8 = [10 x i8] c"lxphp.exe\00"
@.str.9 = [33 x i8] c"../bin/common/process_single.php\00"
@.str.11 = [9 x i8] c"Pipe %d\0A\00"
@.str.12 = [9 x i8] c"Got %d\0A\0A\00"
@.str.13 = [9 x i8] c"Got %s\0A\0A\00"
@str = [12 x i8] c"Exec failed\00"
@str.14 = [8 x i8] c"Got EOF\00"
define i32 @run_php_prog_ssl(i32* %0, i32 %1) {
%3 = alloca [2 x i32]
%4 = load i32, i32* @BUFSIZ
%5 = zext i32 %4 to i64
%6 = alloca i8, i64 %5
%7 = alloca i8, i64 %5
%8 = alloca i8, i64 %5
%9 = bitcast [2 x i32]* %3 to i8*
%10 = call i32 @bzero(i8* %8, i32 %4)
%11 = add i32 %4, -1
br label %12
12: ; preds = %34, %2
%13 = phi i8* [ null, %2 ], [ %35, %34 ]
%14 = call i32 @ssl_or_tcp_read(i32* %0, i32 %1, i8* %8, i32 %11)
%15 = icmp slt i32 %14, 1
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.14, i64 0, i64 0))
br label %38
18: ; preds = %12
%19 = zext i32 %14 to i64
%20 = getelementptr inbounds i8, i8* %8, i64 %19
store i8 0, i8* %20
%21 = icmp eq i8* %13, null
br i1 %21, label %29, label %22
22: ; preds = %18
%23 = call i32 @strlen(i8* %13)
%24 = call i32 @strlen(i8* %8)
%25 = add i32 %23, 1
%26 = add i32 %25, %24
%27 = call i8* @malloc(i32 %26)
%28 = call i32 @sprintf(i8* dereferenceable(1) %27, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %13, i8* %8)
br label %34
29: ; preds = %18
%30 = call i32 @strlen(i8* %8)
%31 = add nsw i32 %30, 1
%32 = call i8* @malloc(i32 %31)
%33 = call i32 @strcpy(i8* %32, i8* %8)
br label %34
34: ; preds = %29, %22
%35 = phi i8* [ %27, %22 ], [ %32, %29 ]
%36 = call i64 @strstr(i8* %35, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %12, label %38
38: ; preds = %34, %16
%39 = phi i8* [ %13, %16 ], [ %35, %34 ]
%40 = call i32 @strlen(i8* %39)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %40, i8* %39)
%42 = call i32 @bzero(i8* %8, i32 %4)
%43 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%44 = call i32 @mkstemp(i8* %7)
%45 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%46 = call i32 @strlen(i8* %39)
%47 = call i32 @fwrite(i8* %39, i32 %46, i32 1, i32* %45)
%48 = call i32 @fclose(i32* %45)
%49 = call i32 @snprintf(i8* %6, i32 %4, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %7)
%50 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%51 = call i32 @pipe(i32* %50)
%52 = call i32 (...) @fork()
%53 = icmp eq i32 %52, 0
%54 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%55 = load i32, i32* %54
br i1 %53, label %56, label %63
56: ; preds = %38
%57 = call i32 @dup2(i32 %55, i32 1)
%58 = load i32, i32* %50
%59 = call i32 @close(i32 %58)
%60 = call i32 @execl(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i8* %6, i32* null)
%61 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%62 = call i32 @exit(i32 0)
unreachable
63: ; preds = %38
%64 = call i32 @close(i32 %55)
%65 = load i32, i32* %50
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), i32 %65)
%67 = load i32, i32* %50
%68 = call i32 @read(i32 %67, i8* %8, i32 %4)
%69 = icmp sgt i32 %68, 0
br label %70
70: ; preds = %63, %70
%71 = phi i32 [ %76, %70 ], [ undef, %63 ]
%72 = phi i32 [ %75, %70 ], [ %68, %63 ]
%73 = call i32 @ssl_or_tcp_write(i32* %0, i32 %1, i8* %8, i32 %72)
%74 = load i32, i32* %50
%75 = call i32 @read(i32 %74, i8* %8, i32 %4)
%76 = add nsw i32 %75, %71
%77 = icmp sgt i32 %75, 0
br i1 %77, label %70, label %78
78: ; preds = %70
%79 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %76)
br label %80
80: ; preds = %80, %78
%81 = call i32 @bzero(i8* %7, i32 %4)
%82 = call i32 @ssl_or_tcp_read(i32* %0, i32 %1, i8* %7, i32 %4)
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i64 0, i64 0), i8* %7)
%84 = icmp slt i32 %82, 1
br i1 %84, label %85, label %80
85: ; preds = %80
%86 = call i32 @exit(i32 0)
unreachable
}