#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 {
  TYPE_1__ sin_addr;
  void *sin_port;
  void *sin_family;
};

/* Variables and functions */
int accept(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ assert(int);
void *atoi(char *);
int /*<<< orphan*/ atol(char *);
char *calloc(int, int);
int /*<<< orphan*/ close(int);
int comm_connect_addr(int, struct sockaddr_in *);
int dup(int);
int /*<<< orphan*/ dup2(int, int);
int /*<<< orphan*/ execvp(char *, char **);
int ipcCloseAllFD(int, int, int, int);
int /*<<< orphan*/ no_suid();
int open(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ putenv(char *);
int send(int, char const *, int, int /*<<< orphan*/);
int /*<<< orphan*/ setsid();
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int strlen(char const *);
scalar_t__ write(int, char const *, int);
int main(int argc, char *argv[]) {
  struct sockaddr_in PS;
  int prfd, pwfd, crfd, cwfd, cefd;
  int type;
  char *prog, *debugOptions;
  const char *hello_string = "hi there\n";
  int fd, t1, t2, t3, x;
  int tmp_s;
  char *env_str;
  if (argc < 12)
    return (1);
  prog = *++argv;
  debugOptions = *++argv;
  type = atoi(*++argv);
  prfd = atoi(*++argv);
  pwfd = atoi(*++argv);
  crfd = atoi(*++argv);
  cwfd = atoi(*++argv);
  cefd = atoi(*++argv);
  PS.sin_family = atoi(*++argv);
  PS.sin_port = atoi(*++argv);
  PS.sin_addr.s_addr = atol(*++argv);
  no_suid();
  close(prfd);
  if (pwfd != prfd)
    close(pwfd);
  pwfd = prfd = -1;
  if (type == 1) {
    if ((fd = accept(crfd, NULL, NULL)) < 0) {
      return (1);
    }
    close(crfd);
    cwfd = crfd = fd;
  } else if (type == 2) {
    if (comm_connect_addr(crfd, &PS) == (-1))
      return ipcCloseAllFD(prfd, pwfd, crfd, cwfd);
  }
  if (type == 2) {
    x = send(cwfd, hello_string, strlen(hello_string), 0);
    if (x < 0) {
      return (1);
    }
  } else {
    if (write(cwfd, hello_string, strlen(hello_string)) < 0) {
      return (1);
    }
  }
  env_str = calloc((tmp_s = strlen(debugOptions) + 32), 1);
  snprintf(env_str, tmp_s, "SQUID_DEBUG=%s", debugOptions);
  putenv(env_str);
  do {
    x = open("/dev/null", 0, 0444);
  } while (x < 3);
  t1 = dup(crfd);
  t2 = dup(cwfd);
  t3 = dup(cefd);
  assert(t1 > 2 && t2 > 2 && t3 > 2);
  close(crfd);
  close(cwfd);
  close(cefd);
  dup2(t1, 0);
  dup2(t2, 1);
  dup2(t3, 2);
  close(t1);
  close(t2);
  close(t3);
  setsid();
  execvp(prog, argv);
  return (1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xdb0(%rip),%rax
mov    %rax,-0x58(%rbp)
cmpl   $0xc,-0x8(%rbp)
jge    126a <main+0x3a>
movl   $0x1,-0x4(%rbp)
jmp    1618 <main+0x3e8>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
call   1140 <atoi@plt>
mov    %eax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
call   1140 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
call   1140 <atoi@plt>
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
call   1140 <atoi@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
call   1140 <atoi@plt>
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
call   1140 <atoi@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
call   1140 <atoi@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
call   1140 <atoi@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
call   1100 <atol@plt>
mov    %eax,-0x28(%rbp)
mov    $0x0,%al
call   1040 <no_suid@plt>
mov    -0x2c(%rbp),%edi
call   10b0 <close@plt>
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
je     13b0 <main+0x180>
mov    -0x30(%rbp),%edi
call   10b0 <close@plt>
movl   $0xffffffff,-0x2c(%rbp)
movl   $0xffffffff,-0x30(%rbp)
cmpl   $0x1,-0x40(%rbp)
jne    1405 <main+0x1d5>
mov    -0x34(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1120 <accept@plt>
mov    %eax,-0x5c(%rbp)
cmp    $0x0,%eax
jge    13ef <main+0x1bf>
movl   $0x1,-0x4(%rbp)
jmp    1618 <main+0x3e8>
mov    -0x34(%rbp),%edi
call   10b0 <close@plt>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    %eax,-0x38(%rbp)
jmp    1447 <main+0x217>
cmpl   $0x2,-0x40(%rbp)
jne    1442 <main+0x212>
mov    -0x34(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   1030 <comm_connect_addr@plt>
cmp    $0xffffffff,%eax
jne    143d <main+0x20d>
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    -0x38(%rbp),%ecx
call   1150 <ipcCloseAllFD@plt>
mov    %eax,-0x4(%rbp)
jmp    1618 <main+0x3e8>
jmp    1442 <main+0x212>
jmp    1447 <main+0x217>
cmpl   $0x2,-0x40(%rbp)
jne    149c <main+0x26c>
mov    -0x38(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x58(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x84(%rbp),%edi
mov    -0x80(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0x0,-0x6c(%rbp)
jge    1497 <main+0x267>
movl   $0x1,-0x4(%rbp)
jmp    1618 <main+0x3e8>
jmp    14e8 <main+0x2b8>
mov    -0x38(%rbp),%eax
mov    %eax,-0x94(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x58(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x94(%rbp),%edi
mov    -0x90(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
cmp    $0x0,%rax
jge    14e3 <main+0x2b3>
movl   $0x1,-0x4(%rbp)
jmp    1618 <main+0x3e8>
jmp    14e8 <main+0x2b8>
mov    -0x50(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%edi
add    $0x20,%edi
mov    %edi,-0x70(%rbp)
mov    $0x1,%esi
call   10d0 <calloc@plt>
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rdi
mov    -0x70(%rbp),%esi
mov    -0x50(%rbp),%rcx
lea    0xaf1(%rip),%rdx
call   1090 <snprintf@plt>
mov    -0x78(%rbp),%rdi
call   10e0 <putenv@plt>
lea    0xaeb(%rip),%rdi
xor    %esi,%esi
mov    $0x124,%edx
call   1110 <open@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0x3,-0x6c(%rbp)
jl     1527 <main+0x2f7>
mov    -0x34(%rbp),%edi
call   10a0 <dup@plt>
mov    %eax,-0x60(%rbp)
mov    -0x38(%rbp),%edi
call   10a0 <dup@plt>
mov    %eax,-0x64(%rbp)
mov    -0x3c(%rbp),%edi
call   10a0 <dup@plt>
mov    %eax,-0x68(%rbp)
xor    %eax,%eax
cmpl   $0x2,-0x60(%rbp)
mov    %al,-0x95(%rbp)
jle    1599 <main+0x369>
xor    %eax,%eax
cmpl   $0x2,-0x64(%rbp)
mov    %al,-0x95(%rbp)
jle    1599 <main+0x369>
cmpl   $0x2,-0x68(%rbp)
setg   %al
mov    %al,-0x95(%rbp)
mov    -0x95(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   10f0 <assert@plt>
mov    -0x34(%rbp),%edi
call   10b0 <close@plt>
mov    -0x38(%rbp),%edi
call   10b0 <close@plt>
mov    -0x3c(%rbp),%edi
call   10b0 <close@plt>
mov    -0x60(%rbp),%edi
xor    %esi,%esi
call   1070 <dup2@plt>
mov    -0x64(%rbp),%edi
mov    $0x1,%esi
call   1070 <dup2@plt>
mov    -0x68(%rbp),%edi
mov    $0x2,%esi
call   1070 <dup2@plt>
mov    -0x60(%rbp),%edi
call   10b0 <close@plt>
mov    -0x64(%rbp),%edi
call   10b0 <close@plt>
mov    -0x68(%rbp),%edi
call   10b0 <close@plt>
mov    $0x0,%al
call   10c0 <setsid@plt>
mov    -0x48(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1130 <execvp@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    $0x1,%r15d
cmp    $0xc,%edi
jl     14ca <main+0x29a>
mov    %rsi,%rbx
mov    0x8(%rsi),%rax
mov    %rax,0x18(%rsp)
mov    0x10(%rsi),%rax
mov    %rax,0x8(%rsp)
mov    0x18(%rsi),%rdi
call   1140 <atoi@plt>
mov    %rax,%r12
mov    0x20(%rbx),%rdi
call   1140 <atoi@plt>
mov    %rax,%r14
mov    0x28(%rbx),%rdi
call   1140 <atoi@plt>
mov    %rax,%rbp
mov    0x30(%rbx),%rdi
call   1140 <atoi@plt>
mov    %rax,%r13
mov    0x38(%rbx),%rdi
call   1140 <atoi@plt>
mov    %rax,(%rsp)
mov    0x40(%rbx),%rdi
call   1140 <atoi@plt>
mov    %rax,0x10(%rsp)
mov    0x48(%rbx),%rdi
call   1140 <atoi@plt>
mov    %rax,0x30(%rsp)
mov    0x50(%rbx),%rdi
call   1140 <atoi@plt>
mov    %rax,0x28(%rsp)
mov    0x58(%rbx),%rdi
call   1100 <atol@plt>
mov    %eax,0x20(%rsp)
xor    %eax,%eax
call   1040 <no_suid@plt>
mov    %r14d,%edi
call   10b0 <close@plt>
cmp    %r14d,%ebp
je     12f1 <main+0xc1>
mov    %ebp,%edi
call   10b0 <close@plt>
cmp    $0x2,%r12d
je     1323 <main+0xf3>
cmp    $0x1,%r12d
jne    1367 <main+0x137>
mov    %r13d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1120 <accept@plt>
test   %eax,%eax
js     14ca <main+0x29a>
mov    %eax,%ebp
mov    %r13d,%edi
call   10b0 <close@plt>
mov    %ebp,%r12d
mov    %rbp,%r13
jmp    136e <main+0x13e>
lea    0x20(%rsp),%rsi
mov    %r13,%r12
mov    %r12d,%edi
call   1030 <comm_connect_addr@plt>
cmp    $0xffffffff,%eax
je     14b1 <main+0x281>
lea    0xcbd(%rip),%rbp
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    (%rsp),%r13
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
test   %eax,%eax
jns    1393 <main+0x163>
jmp    14ca <main+0x29a>
mov    %r13,%r12
mov    (%rsp),%r13
lea    0xc8b(%rip),%rbp
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1050 <write@plt>
test   %rax,%rax
js     14ca <main+0x29a>
add    $0x58,%rbx
mov    0x8(%rsp),%r15
mov    %r15,%rdi
call   1060 <strlen@plt>
lea    0x20(%rax),%r14d
mov    %r14d,%edi
mov    $0x1,%esi
call   10d0 <calloc@plt>
mov    %rax,%rbp
lea    0xc4b(%rip),%rdx
mov    %rax,%rdi
mov    %r14d,%esi
mov    %r15,%rcx
call   1090 <snprintf@plt>
mov    %rbp,%rdi
call   10e0 <putenv@plt>
lea    0xc3d(%rip),%rbp
nopl   0x0(%rax)
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x124,%edx
call   1110 <open@plt>
cmp    $0x3,%eax
jl     13e0 <main+0x1b0>
mov    %r12d,%edi
call   10a0 <dup@plt>
mov    %eax,%r14d
mov    %r13d,%edi
call   10a0 <dup@plt>
mov    %r12,(%rsp)
mov    %eax,%r12d
mov    0x10(%rsp),%rbp
mov    %ebp,%edi
call   10a0 <dup@plt>
mov    %r13,%r15
mov    %eax,%r13d
cmp    $0x3,%r14d
setge  %al
cmp    $0x3,%r12d
setge  %cl
and    %al,%cl
cmp    $0x3,%r13d
setge  %al
and    %cl,%al
movzbl %al,%edi
call   10f0 <assert@plt>
mov    (%rsp),%rdi
call   10b0 <close@plt>
mov    %r15d,%edi
call   10b0 <close@plt>
mov    %ebp,%edi
call   10b0 <close@plt>
mov    %r14d,%edi
xor    %esi,%esi
call   1070 <dup2@plt>
mov    $0x1,%r15d
mov    %r12d,%edi
mov    $0x1,%esi
call   1070 <dup2@plt>
mov    %r13d,%edi
mov    $0x2,%esi
call   1070 <dup2@plt>
mov    %r14d,%edi
call   10b0 <close@plt>
mov    %r12d,%edi
call   10b0 <close@plt>
mov    %r13d,%edi
call   10b0 <close@plt>
xor    %eax,%eax
call   10c0 <setsid@plt>
mov    0x18(%rsp),%rdi
mov    %rbx,%rsi
call   1130 <execvp@plt>
jmp    14ca <main+0x29a>
mov    $0xffffffff,%edi
mov    $0xffffffff,%esi
mov    %r12d,%edx
mov    (%rsp),%rcx
call   1150 <ipcCloseAllFD@plt>
mov    %eax,%r15d
mov    %r15d,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i8* }
%struct.TYPE_2__ = type { i32 }
@.str = [10 x i8] c"hi there\0A\00"
@.str.1 = [15 x i8] c"SQUID_DEBUG=%s\00"
@.str.2 = [10 x i8] c"/dev/null\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.sockaddr_in
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %15
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 12
br i1 %24, label %25, label %26
25: ; preds = %2
store i32 1, i32* %3
br label %194
26: ; preds = %2
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i32 1
store i8** %28, i8*** %5
%29 = load i8*, i8** %28
store i8* %29, i8** %13
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i32 1
store i8** %31, i8*** %5
%32 = load i8*, i8** %31
store i8* %32, i8** %14
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i32 1
store i8** %34, i8*** %5
%35 = load i8*, i8** %34
%36 = call i8* @atoi(i8* %35)
%37 = ptrtoint i8* %36 to i32
store i32 %37, i32* %12
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i32 1
store i8** %39, i8*** %5
%40 = load i8*, i8** %39
%41 = call i8* @atoi(i8* %40)
%42 = ptrtoint i8* %41 to i32
store i32 %42, i32* %7
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i32 1
store i8** %44, i8*** %5
%45 = load i8*, i8** %44
%46 = call i8* @atoi(i8* %45)
%47 = ptrtoint i8* %46 to i32
store i32 %47, i32* %8
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i32 1
store i8** %49, i8*** %5
%50 = load i8*, i8** %49
%51 = call i8* @atoi(i8* %50)
%52 = ptrtoint i8* %51 to i32
store i32 %52, i32* %9
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i32 1
store i8** %54, i8*** %5
%55 = load i8*, i8** %54
%56 = call i8* @atoi(i8* %55)
%57 = ptrtoint i8* %56 to i32
store i32 %57, i32* %10
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i32 1
store i8** %59, i8*** %5
%60 = load i8*, i8** %59
%61 = call i8* @atoi(i8* %60)
%62 = ptrtoint i8* %61 to i32
store i32 %62, i32* %11
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i32 1
store i8** %64, i8*** %5
%65 = load i8*, i8** %64
%66 = call i8* @atoi(i8* %65)
%67 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 2
store i8* %66, i8** %67
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i32 1
store i8** %69, i8*** %5
%70 = load i8*, i8** %69
%71 = call i8* @atoi(i8* %70)
%72 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 1
store i8* %71, i8** %72
%73 = load i8**, i8*** %5
%74 = getelementptr inbounds i8*, i8** %73, i32 1
store i8** %74, i8*** %5
%75 = load i8*, i8** %74
%76 = call i32 @atol(i8* %75)
%77 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
%78 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %77, i32 0, i32 0
store i32 %76, i32* %78
%79 = call i32 (...) @no_suid()
%80 = load i32, i32* %7
%81 = call i32 @close(i32 %80)
%82 = load i32, i32* %8
%83 = load i32, i32* %7
%84 = icmp ne i32 %82, %83
br i1 %84, label %85, label %88
85: ; preds = %26
%86 = load i32, i32* %8
%87 = call i32 @close(i32 %86)
br label %88
88: ; preds = %85, %26
store i32 -1, i32* %7
store i32 -1, i32* %8
%89 = load i32, i32* %12
%90 = icmp eq i32 %89, 1
br i1 %90, label %91, label %100
91: ; preds = %88
%92 = load i32, i32* %9
%93 = call i32 @accept(i32 %92, i32* null, i32* null)
store i32 %93, i32* %16
%94 = icmp slt i32 %93, 0
br i1 %94, label %95, label %96
95: ; preds = %91
store i32 1, i32* %3
br label %194
96: ; preds = %91
%97 = load i32, i32* %9
%98 = call i32 @close(i32 %97)
%99 = load i32, i32* %16
store i32 %99, i32* %9
store i32 %99, i32* %10
br label %115
100: ; preds = %88
%101 = load i32, i32* %12
%102 = icmp eq i32 %101, 2
br i1 %102, label %103, label %114
103: ; preds = %100
%104 = load i32, i32* %9
%105 = call i32 @comm_connect_addr(i32 %104, %struct.sockaddr_in* %6)
%106 = icmp eq i32 %105, -1
br i1 %106, label %107, label %113
107: ; preds = %103
%108 = load i32, i32* %7
%109 = load i32, i32* %8
%110 = load i32, i32* %9
%111 = load i32, i32* %10
%112 = call i32 @ipcCloseAllFD(i32 %108, i32 %109, i32 %110, i32 %111)
store i32 %112, i32* %3
br label %194
113: ; preds = %103
br label %114
114: ; preds = %113, %100
br label %115
115: ; preds = %114, %96
%116 = load i32, i32* %12
%117 = icmp eq i32 %116, 2
br i1 %117, label %118, label %128
118: ; preds = %115
%119 = load i32, i32* %10
%120 = load i8*, i8** %15
%121 = load i8*, i8** %15
%122 = call i32 @strlen(i8* %121)
%123 = call i32 @send(i32 %119, i8* %120, i32 %122, i32 0)
store i32 %123, i32* %20
%124 = load i32, i32* %20
%125 = icmp slt i32 %124, 0
br i1 %125, label %126, label %127
126: ; preds = %118
store i32 1, i32* %3
br label %194
127: ; preds = %118
br label %137
128: ; preds = %115
%129 = load i32, i32* %10
%130 = load i8*, i8** %15
%131 = load i8*, i8** %15
%132 = call i32 @strlen(i8* %131)
%133 = call i64 @write(i32 %129, i8* %130, i32 %132)
%134 = icmp slt i64 %133, 0
br i1 %134, label %135, label %136
135: ; preds = %128
store i32 1, i32* %3
br label %194
136: ; preds = %128
br label %137
137: ; preds = %136, %127
%138 = load i8*, i8** %14
%139 = call i32 @strlen(i8* %138)
%140 = add nsw i32 %139, 32
store i32 %140, i32* %21
%141 = call i8* @calloc(i32 %140, i32 1)
store i8* %141, i8** %22
%142 = load i8*, i8** %22
%143 = load i32, i32* %21
%144 = load i8*, i8** %14
%145 = call i32 @snprintf(i8* %142, i32 %143, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %144)
%146 = load i8*, i8** %22
%147 = call i32 @putenv(i8* %146)
br label %148
148: ; preds = %150, %137
%149 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 292)
store i32 %149, i32* %20
br label %150
150: ; preds = %148
%151 = load i32, i32* %20
%152 = icmp slt i32 %151, 3
br i1 %152, label %148, label %153
153: ; preds = %150
%154 = load i32, i32* %9
%155 = call i32 @dup(i32 %154)
store i32 %155, i32* %17
%156 = load i32, i32* %10
%157 = call i32 @dup(i32 %156)
store i32 %157, i32* %18
%158 = load i32, i32* %11
%159 = call i32 @dup(i32 %158)
store i32 %159, i32* %19
%160 = load i32, i32* %17
%161 = icmp sgt i32 %160, 2
br i1 %161, label %162, label %168
162: ; preds = %153
%163 = load i32, i32* %18
%164 = icmp sgt i32 %163, 2
br i1 %164, label %165, label %168
165: ; preds = %162
%166 = load i32, i32* %19
%167 = icmp sgt i32 %166, 2
br label %168
168: ; preds = %165, %162, %153
%169 = phi i1 [ false, %162 ], [ false, %153 ], [ %167, %165 ]
%170 = zext i1 %169 to i32
%171 = call i32 @assert(i32 %170)
%172 = load i32, i32* %9
%173 = call i32 @close(i32 %172)
%174 = load i32, i32* %10
%175 = call i32 @close(i32 %174)
%176 = load i32, i32* %11
%177 = call i32 @close(i32 %176)
%178 = load i32, i32* %17
%179 = call i32 @dup2(i32 %178, i32 0)
%180 = load i32, i32* %18
%181 = call i32 @dup2(i32 %180, i32 1)
%182 = load i32, i32* %19
%183 = call i32 @dup2(i32 %182, i32 2)
%184 = load i32, i32* %17
%185 = call i32 @close(i32 %184)
%186 = load i32, i32* %18
%187 = call i32 @close(i32 %186)
%188 = load i32, i32* %19
%189 = call i32 @close(i32 %188)
%190 = call i32 (...) @setsid()
%191 = load i8*, i8** %13
%192 = load i8**, i8*** %5
%193 = call i32 @execvp(i8* %191, i8** %192)
store i32 1, i32* %3
br label %194
194: ; preds = %168, %135, %126, %107, %95, %25
%195 = load i32, i32* %3
ret i32 %195
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i8* }
%struct.TYPE_2__ = type { i32 }
@.str = [10 x i8] c"hi there\0A\00"
@.str.1 = [15 x i8] c"SQUID_DEBUG=%s\00"
@.str.2 = [10 x i8] c"/dev/null\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.sockaddr_in
%4 = bitcast %struct.sockaddr_in* %3 to i8*
%5 = icmp slt i32 %0, 12
br i1 %5, label %112, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8*, i8** %1, i64 3
%12 = load i8*, i8** %11
%13 = tail call i8* @atoi(i8* %12)
%14 = ptrtoint i8* %13 to i64
%15 = trunc i64 %14 to i32
%16 = getelementptr inbounds i8*, i8** %1, i64 4
%17 = load i8*, i8** %16
%18 = tail call i8* @atoi(i8* %17)
%19 = ptrtoint i8* %18 to i64
%20 = trunc i64 %19 to i32
%21 = getelementptr inbounds i8*, i8** %1, i64 5
%22 = load i8*, i8** %21
%23 = tail call i8* @atoi(i8* %22)
%24 = ptrtoint i8* %23 to i64
%25 = trunc i64 %24 to i32
%26 = getelementptr inbounds i8*, i8** %1, i64 6
%27 = load i8*, i8** %26
%28 = tail call i8* @atoi(i8* %27)
%29 = ptrtoint i8* %28 to i64
%30 = trunc i64 %29 to i32
%31 = getelementptr inbounds i8*, i8** %1, i64 7
%32 = load i8*, i8** %31
%33 = tail call i8* @atoi(i8* %32)
%34 = ptrtoint i8* %33 to i64
%35 = trunc i64 %34 to i32
%36 = getelementptr inbounds i8*, i8** %1, i64 8
%37 = load i8*, i8** %36
%38 = tail call i8* @atoi(i8* %37)
%39 = ptrtoint i8* %38 to i64
%40 = trunc i64 %39 to i32
%41 = getelementptr inbounds i8*, i8** %1, i64 9
%42 = load i8*, i8** %41
%43 = tail call i8* @atoi(i8* %42)
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i8* %43, i8** %44
%45 = getelementptr inbounds i8*, i8** %1, i64 10
%46 = load i8*, i8** %45
%47 = tail call i8* @atoi(i8* %46)
%48 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i8* %47, i8** %48
%49 = getelementptr inbounds i8*, i8** %1, i64 11
%50 = load i8*, i8** %49
%51 = tail call i32 @atol(i8* %50)
%52 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0, i32 0
store i32 %51, i32* %52
%53 = tail call i32 (...) @no_suid()
%54 = tail call i32 @close(i32 %20)
%55 = icmp eq i32 %25, %20
br i1 %55, label %58, label %56
56: ; preds = %6
%57 = tail call i32 @close(i32 %25)
br label %58
58: ; preds = %56, %6
switch i32 %15, label %73 [
i32 1, label %59
i32 2, label %64
]
59: ; preds = %58
%60 = tail call i32 @accept(i32 %30, i32* null, i32* null)
%61 = icmp slt i32 %60, 0
br i1 %61, label %112, label %62
62: ; preds = %59
%63 = tail call i32 @close(i32 %30)
br label %73
64: ; preds = %58
%65 = call i32 @comm_connect_addr(i32 %30, %struct.sockaddr_in* %3)
%66 = icmp eq i32 %65, -1
br i1 %66, label %67, label %69
67: ; preds = %64
%68 = call i32 @ipcCloseAllFD(i32 -1, i32 -1, i32 %30, i32 %35)
br label %112
69: ; preds = %64
%70 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%71 = call i32 @send(i32 %35, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %70, i32 0)
%72 = icmp slt i32 %71, 0
br i1 %72, label %112, label %79
73: ; preds = %58, %62
%74 = phi i32 [ %35, %58 ], [ %60, %62 ]
%75 = phi i32 [ %30, %58 ], [ %60, %62 ]
%76 = tail call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%77 = tail call i64 @write(i32 %74, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %76)
%78 = icmp slt i64 %77, 0
br i1 %78, label %112, label %79
79: ; preds = %73, %69
%80 = phi i32 [ %75, %73 ], [ %30, %69 ]
%81 = phi i32 [ %74, %73 ], [ %35, %69 ]
%82 = call i32 @strlen(i8* %10)
%83 = add nsw i32 %82, 32
%84 = call i8* @calloc(i32 %83, i32 1)
%85 = call i32 @snprintf(i8* %84, i32 %83, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%86 = call i32 @putenv(i8* %84)
br label %87
87: ; preds = %87, %79
%88 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 292)
%89 = icmp slt i32 %88, 3
br i1 %89, label %87, label %90
90: ; preds = %87
%91 = call i32 @dup(i32 %80)
%92 = call i32 @dup(i32 %81)
%93 = call i32 @dup(i32 %40)
%94 = icmp sgt i32 %91, 2
%95 = icmp sgt i32 %92, 2
%96 = select i1 %94, i1 %95, i1 false
%97 = icmp sgt i32 %93, 2
%98 = select i1 %96, i1 %97, i1 false
%99 = zext i1 %98 to i32
%100 = call i32 @assert(i32 %99)
%101 = call i32 @close(i32 %80)
%102 = call i32 @close(i32 %81)
%103 = call i32 @close(i32 %40)
%104 = call i32 @dup2(i32 %91, i32 0)
%105 = call i32 @dup2(i32 %92, i32 1)
%106 = call i32 @dup2(i32 %93, i32 2)
%107 = call i32 @close(i32 %91)
%108 = call i32 @close(i32 %92)
%109 = call i32 @close(i32 %93)
%110 = call i32 (...) @setsid()
%111 = call i32 @execvp(i8* %8, i8** %49)
br label %112
112: ; preds = %73, %69, %59, %2, %90, %67
%113 = phi i32 [ 1, %90 ], [ %68, %67 ], [ 1, %2 ], [ 1, %59 ], [ 1, %69 ], [ 1, %73 ]
ret i32 %113
}