#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 ssize_t;

/* Variables and functions */
int /*<<< orphan*/ F_GETFL;
int /*<<< orphan*/ F_SETFL;
int O_NONBLOCK;
int /*<<< orphan*/ STDERR_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ WEXITSTATUS(int);
int /*<<< orphan*/ WIFEXITED(int);
int /*<<< orphan*/ close(int);
int dup2(int, int /*<<< orphan*/);
int /*<<< orphan*/ execl(char *, char *, char *, int /*<<< orphan*/ *);
int fcntl(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getline(char **, size_t *, int /*<<< orphan*/);
int pipe(int *);
int read(int, char **, int);
int /*<<< orphan*/ say(char *, char *, ...);
int sscanf(char *, char *, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int strlen(char *);
int /*<<< orphan*/ *strstr(char *, char *);
int /*<<< orphan*/ wait(int *);
int main() {
  size_t len = 0;
  ssize_t i;
  char *line = NULL;
  while ((i = getline(&line, &len, stdin)) != -1) {
    if (strstr(line, "PRIVMSG") == NULL) {
      continue;
    }
    if (strstr(line, ":tweet ") == NULL) {
      continue;
    }
    if (strlen(line) < 1) {
      continue;
    }
    char who[strlen(line)];
    char channel[strlen(line)];
    char content[strlen(line)];
    if ((sscanf(line, "%s PRIVMSG %s ::tweet %[^\n\r]", who, channel,
                content)) == 3) {
      int out[2], err[2];
      if (pipe(out) == -1 || pipe(err) == -1) {
        say(channel, "FAIL pipe()");
        continue;
      }
      if (fork() == 0) {
        close(out[0]);
        close(err[0]);
        if (dup2(out[1], STDOUT_FILENO) == -1) {
          fprintf(stderr, "FAIL dup2()\n");
          return 2;
        }
        if (dup2(err[1], STDERR_FILENO) == -1) {
          fprintf(stderr, "FAIL dup2()\n");
          return 2;
        }
        execl("/home/fridim/bin/twty", "twty", content, NULL);
        return 2;
      } else {
        int status;
        wait(&status);
        if (!WIFEXITED(status)) {
          say(channel, "twty failed, ret = %d", WEXITSTATUS(status));
          goto CLOSE;
        }
        int flags = fcntl(err[0], F_GETFL, 0);
        fcntl(err[0], F_SETFL, flags | O_NONBLOCK);
        char buf[256];
        int k = 0;
        while ((k = read(err[0], &buf, 255)) > 0) {
          buf[k] = '\0';
          fprintf(stderr, "%s", buf);
        }
        fflush(stderr);
        if ((k = read(out[0], &buf, 255)) == -1) {
          say(channel, "FAIL read pipe.");
          goto CLOSE;
        }
        buf[k] = '\0';
        char tweetid[128] = "";
        if ((sscanf(buf, "tweeted: %127s", tweetid) == 1)) {
          say(channel, "tweeted: %s%s", "https://twitter.com/cabotirc/status/",
              tweetid);
        } else {
          say(channel, "could not parse twty output.");
        }
      CLOSE:
        close(out[1]);
        close(err[1]);
        close(out[0]);
        close(err[0]);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
mov    0x2d8f(%rip),%rax
mov    (%rax),%edx
lea    -0x20(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   10e0 <getline@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1691 <main+0x471>
mov    -0x20(%rbp),%rdi
lea    0xd91(%rip),%rsi
call   1130 <strstr@plt>
cmp    $0x0,%rax
jne    1283 <main+0x63>
jmp    1242 <main+0x22>
mov    -0x20(%rbp),%rdi
lea    0xd7a(%rip),%rsi
call   1130 <strstr@plt>
cmp    $0x0,%rax
jne    12a2 <main+0x82>
jmp    1242 <main+0x22>
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x1,%eax
jge    12b9 <main+0x99>
jmp    1242 <main+0x22>
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x208(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x200(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x208(%rbp),%rdx
mov    -0x200(%rbp),%rcx
mov    %eax,%eax
mov    %rax,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%r8
sub    %rsi,%r8
mov    %r8,-0x1f8(%rbp)
mov    %r8,%rsp
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xcb9(%rip),%rsi
mov    $0x0,%al
call   10c0 <sscanf@plt>
cmp    $0x3,%eax
jne    164f <main+0x42f>
lea    -0x48(%rbp),%rdi
call   1080 <pipe@plt>
cmp    $0xffffffff,%eax
je     138b <main+0x16b>
lea    -0x50(%rbp),%rdi
call   1080 <pipe@plt>
cmp    $0xffffffff,%eax
jne    13ac <main+0x18c>
mov    -0x200(%rbp),%rdi
lea    0xc94(%rip),%rsi
mov    $0x0,%al
call   1140 <say@plt>
movl   $0x2,-0x54(%rbp)
jmp    1656 <main+0x436>
mov    $0x0,%al
call   1120 <fork@plt>
cmp    $0x0,%rax
jne    1486 <main+0x266>
mov    -0x48(%rbp),%edi
call   1070 <close@plt>
mov    -0x50(%rbp),%edi
call   1070 <close@plt>
mov    -0x44(%rbp),%edi
mov    0x2c19(%rip),%rax
mov    (%rax),%esi
call   1050 <dup2@plt>
cmp    $0xffffffff,%eax
jne    1411 <main+0x1f1>
mov    0x2bda(%rip),%rax
mov    (%rax),%edi
lea    0xc42(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    1656 <main+0x436>
mov    -0x4c(%rbp),%edi
mov    0x2b95(%rip),%rax
mov    (%rax),%esi
call   1050 <dup2@plt>
cmp    $0xffffffff,%eax
jne    1455 <main+0x235>
mov    0x2b96(%rip),%rax
mov    (%rax),%edi
lea    0xbfe(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    1656 <main+0x436>
mov    -0x1f8(%rbp),%rdx
lea    0xbe3(%rip),%rdi
lea    0xbed(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
call   1100 <execl@plt>
movl   $0x2,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    1656 <main+0x436>
lea    -0x58(%rbp),%rdi
call   1110 <wait@plt>
mov    -0x58(%rbp),%edi
call   10f0 <WIFEXITED@plt>
cmp    $0x0,%eax
jne    14c4 <main+0x2a4>
mov    -0x58(%rbp),%edi
call   10d0 <WEXITSTATUS@plt>
mov    -0x200(%rbp),%rdi
mov    %eax,%edx
lea    0xba4(%rip),%rsi
mov    $0x0,%al
call   1140 <say@plt>
jmp    162a <main+0x40a>
mov    -0x50(%rbp),%edi
mov    0x2aea(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x50(%rbp),%edi
mov    0x2adc(%rip),%rax
mov    (%rax),%esi
mov    -0x5c(%rbp),%edx
mov    0x2af0(%rip),%rax
or     (%rax),%edx
call   1030 <fcntl@plt>
movl   $0x0,-0x164(%rbp)
mov    -0x50(%rbp),%edi
lea    -0x160(%rbp),%rsi
mov    $0xff,%edx
call   1090 <read@plt>
mov    %eax,-0x164(%rbp)
cmp    $0x0,%eax
jle    1556 <main+0x336>
movslq -0x164(%rbp),%rax
movb   $0x0,-0x160(%rbp,%rax,1)
mov    0x2a8e(%rip),%rax
mov    (%rax),%edi
lea    -0x160(%rbp),%rdx
lea    0xb52(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    1501 <main+0x2e1>
mov    0x2a6b(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
mov    -0x48(%rbp),%edi
lea    -0x160(%rbp),%rsi
mov    $0xff,%edx
call   1090 <read@plt>
mov    %eax,-0x164(%rbp)
cmp    $0xffffffff,%eax
jne    15a1 <main+0x381>
mov    -0x200(%rbp),%rdi
lea    0xadd(%rip),%rsi
mov    $0x0,%al
call   1140 <say@plt>
jmp    162a <main+0x40a>
movslq -0x164(%rbp),%rax
movb   $0x0,-0x160(%rbp,%rax,1)
lea    -0x1f0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1060 <memset@plt>
lea    -0x160(%rbp),%rdi
lea    -0x1f0(%rbp),%rdx
lea    0xaaa(%rip),%rsi
mov    $0x0,%al
call   10c0 <sscanf@plt>
cmp    $0x1,%eax
jne    1610 <main+0x3f0>
mov    -0x200(%rbp),%rdi
lea    -0x1f0(%rbp),%rcx
lea    0xa94(%rip),%rsi
lea    0xa9b(%rip),%rdx
mov    $0x0,%al
call   1140 <say@plt>
jmp    1625 <main+0x405>
mov    -0x200(%rbp),%rdi
lea    0xaa6(%rip),%rsi
mov    $0x0,%al
call   1140 <say@plt>
jmp    162a <main+0x40a>
mov    -0x44(%rbp),%edi
call   1070 <close@plt>
mov    -0x4c(%rbp),%edi
call   1070 <close@plt>
mov    -0x48(%rbp),%edi
call   1070 <close@plt>
mov    -0x50(%rbp),%edi
call   1070 <close@plt>
jmp    164f <main+0x42f>
movl   $0x0,-0x54(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x54(%rbp),%eax
mov    %eax,-0x20c(%rbp)
test   %eax,%eax
je     168c <main+0x46c>
jmp    1673 <main+0x453>
mov    -0x20c(%rbp),%eax
sub    $0x1,%eax
je     1698 <main+0x478>
jmp    1687 <main+0x467>
jmp    1242 <main+0x22>
jmp    1242 <main+0x22>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a8,%rsp
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x30(%rbp)
mov    0x2d9d(%rip),%r14
mov    (%r14),%edx
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   10d0 <getline@plt>
cmp    $0xffffffff,%eax
je     153a <main+0x32a>
lea    0xda5(%rip),%r12
mov    0x2d66(%rip),%r15
jmp    1289 <main+0x79>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r14),%edx
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   10d0 <getline@plt>
cmp    $0xffffffff,%eax
je     153a <main+0x32a>
mov    -0x30(%rbp),%rbx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1120 <strstr@plt>
test   %rax,%rax
je     1270 <main+0x60>
mov    %rbx,%rdi
lea    0xd61(%rip),%rsi
call   1120 <strstr@plt>
test   %rax,%rax
je     1270 <main+0x60>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1270 <main+0x60>
mov    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rsp,%rbx
mov    %eax,%eax
mov    %r15,%r13
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%eax
mov    %rsp,%r12
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    -0x30(%rbp),%rdi
lea    0xcee(%rip),%rsi
mov    %r15,%rdx
mov    %r13,%r15
lea    0xd6d(%rip),%r13
mov    %r12,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   10b0 <sscanf@plt>
cmp    $0x3,%eax
jne    1510 <main+0x300>
lea    -0x44(%rbp),%rdi
call   1070 <pipe@plt>
cmp    $0xffffffff,%eax
je     1400 <main+0x1f0>
lea    -0x38(%rbp),%rdi
call   1070 <pipe@plt>
cmp    $0xffffffff,%eax
je     1400 <main+0x1f0>
xor    %eax,%eax
call   1110 <fork@plt>
test   %rax,%rax
je     154b <main+0x33b>
lea    -0x3c(%rbp),%rdi
call   1100 <wait@plt>
mov    -0x3c(%rbp),%edi
call   10e0 <WIFEXITED@plt>
test   %eax,%eax
je     14b0 <main+0x2a0>
mov    -0x38(%rbp),%edi
mov    0x2c1c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    -0x38(%rbp),%edi
mov    0x2c11(%rip),%rcx
mov    (%rcx),%esi
mov    0x2c28(%rip),%rcx
or     (%rcx),%eax
mov    %eax,%edx
call   1030 <fcntl@plt>
mov    -0x38(%rbp),%edi
lea    -0x1d0(%rbp),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rsi
mov    $0xff,%edx
call   1080 <read@plt>
test   %eax,%eax
jle    1416 <main+0x206>
mov    %eax,%eax
movb   $0x0,-0x1d0(%rbp,%rax,1)
mov    (%r15),%edi
mov    %r13,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    -0x38(%rbp),%edi
jmp    13d0 <main+0x1c0>
mov    %r12,%rdi
lea    0xc23(%rip),%rsi
xor    %eax,%eax
call   1130 <say@plt>
jmp    1510 <main+0x300>
mov    (%r15),%edi
call   10a0 <fflush@plt>
mov    -0x44(%rbp),%edi
mov    %r14,%rsi
mov    $0xff,%edx
call   1080 <read@plt>
cmp    $0xffffffff,%eax
je     14cd <main+0x2bd>
cltq
movb   $0x0,-0x1d0(%rbp,%rax,1)
xorps  %xmm0,%xmm0
movaps %xmm0,-0xd0(%rbp)
movaps %xmm0,-0xc0(%rbp)
movaps %xmm0,-0xb0(%rbp)
movaps %xmm0,-0xa0(%rbp)
movaps %xmm0,-0x90(%rbp)
movaps %xmm0,-0x80(%rbp)
movaps %xmm0,-0x70(%rbp)
movaps %xmm0,-0x60(%rbp)
mov    %r14,%rdi
lea    0xc05(%rip),%rsi
lea    -0xd0(%rbp),%r14
mov    %r14,%rdx
xor    %eax,%eax
call   10b0 <sscanf@plt>
mov    %r12,%rdi
cmp    $0x1,%eax
jne    14d9 <main+0x2c9>
lea    0xbf4(%rip),%rsi
lea    0xbfb(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1130 <say@plt>
jmp    14e7 <main+0x2d7>
mov    -0x3c(%rbp),%edi
call   10c0 <WEXITSTATUS@plt>
mov    %r12,%rdi
lea    0xb9a(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1130 <say@plt>
jmp    14e7 <main+0x2d7>
mov    %r12,%rdi
lea    0xb9b(%rip),%rsi
jmp    14e0 <main+0x2d0>
lea    0xbe4(%rip),%rsi
xor    %eax,%eax
call   1130 <say@plt>
mov    -0x40(%rbp),%edi
call   1060 <close@plt>
mov    -0x34(%rbp),%edi
call   1060 <close@plt>
mov    -0x44(%rbp),%edi
call   1060 <close@plt>
mov    -0x38(%rbp),%edi
call   1060 <close@plt>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rsp
mov    0x2abe(%rip),%r14
mov    (%r14),%edx
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   10d0 <getline@plt>
cmp    $0xffffffff,%eax
lea    0xacc(%rip),%r12
jne    1289 <main+0x79>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    -0x44(%rbp),%edi
call   1060 <close@plt>
mov    -0x38(%rbp),%edi
call   1060 <close@plt>
mov    -0x40(%rbp),%edi
mov    0x2a8b(%rip),%rax
mov    (%rax),%esi
call   1050 <dup2@plt>
cmp    $0xffffffff,%eax
je     15a1 <main+0x391>
mov    -0x34(%rbp),%edi
mov    0x2a35(%rip),%rax
mov    (%rax),%esi
call   1050 <dup2@plt>
cmp    $0xffffffff,%eax
je     15a1 <main+0x391>
lea    0xab8(%rip),%rdi
lea    0xac2(%rip),%rsi
mov    %r14,%rdx
xor    %ecx,%ecx
call   10f0 <execl@plt>
jmp    15b2 <main+0x3a2>
mov    (%r15),%edi
lea    0xa8e(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x2,%eax
mov    %rbx,%rsp
jmp    153c <main+0x32c>

LLVM IR (-O0):
@stdin = global i32 0
@.str = [8 x i8] c"PRIVMSG\00"
@.str.1 = [8 x i8] c":tweet \00"
@.str.2 = [29 x i8] c"%s PRIVMSG %s ::tweet %[^\0A\0D]\00"
@.str.3 = [12 x i8] c"FAIL pipe()\00"
@STDOUT_FILENO = global i32 0
@stderr = global i32 0
@.str.4 = [13 x i8] c"FAIL dup2()\0A\00"
@STDERR_FILENO = global i32 0
@.str.5 = [22 x i8] c"/home/fridim/bin/twty\00"
@.str.6 = [5 x i8] c"twty\00"
@.str.7 = [22 x i8] c"twty failed, ret = %d\00"
@F_GETFL = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@.str.8 = [3 x i8] c"%s\00"
@.str.9 = [16 x i8] c"FAIL read pipe.\00"
@.str.10 = [15 x i8] c"tweeted: %127s\00"
@.str.11 = [14 x i8] c"tweeted: %s%s\00"
@.str.12 = [37 x i8] c"https://twitter.com/cabotirc/status/\00"
@.str.13 = [29 x i8] c"could not parse twty output.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca [2 x i32]
%10 = alloca [2 x i32]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca [256 x i8]
%15 = alloca i32
%16 = alloca [128 x i8]
store i32 0, i32* %1
store i64 0, i64* %2
store i8* null, i8** %4
br label %17
17: ; preds = %169, %166, %35, %30, %25, %0
%18 = load i32, i32* @stdin
%19 = call i32 @getline(i8** %4, i64* %2, i32 %18)
store i32 %19, i32* %3
%20 = icmp ne i32 %19, -1
br i1 %20, label %21, label %170
21: ; preds = %17
%22 = load i8*, i8** %4
%23 = call i32* @strstr(i8* %22, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %26
25: ; preds = %21
br label %17
26: ; preds = %21
%27 = load i8*, i8** %4
%28 = call i32* @strstr(i8* %27, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %31
30: ; preds = %26
br label %17
31: ; preds = %26
%32 = load i8*, i8** %4
%33 = call i32 @strlen(i8* %32)
%34 = icmp slt i32 %33, 1
br i1 %34, label %35, label %36
35: ; preds = %31
br label %17
36: ; preds = %31
%37 = load i8*, i8** %4
%38 = call i32 @strlen(i8* %37)
%39 = zext i32 %38 to i64
%40 = call i8* @llvm.stacksave()
store i8* %40, i8** %5
%41 = alloca i8, i64 %39
store i64 %39, i64* %6
%42 = load i8*, i8** %4
%43 = call i32 @strlen(i8* %42)
%44 = zext i32 %43 to i64
%45 = alloca i8, i64 %44
store i64 %44, i64* %7
%46 = load i8*, i8** %4
%47 = call i32 @strlen(i8* %46)
%48 = zext i32 %47 to i64
%49 = alloca i8, i64 %48
store i64 %48, i64* %8
%50 = load i8*, i8** %4
%51 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %50, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %41, i8* %45, i8* %49)
%52 = icmp eq i32 %51, 3
br i1 %52, label %53, label %165
53: ; preds = %36
%54 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%55 = call i32 @pipe(i32* %54)
%56 = icmp eq i32 %55, -1
br i1 %56, label %61, label %57
57: ; preds = %53
%58 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%59 = call i32 @pipe(i32* %58)
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %63
61: ; preds = %57, %53
%62 = call i32 (i8*, i8*, ...) @say(i8* %45, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
store i32 2, i32* %11
br label %166
63: ; preds = %57
%64 = call i64 (...) @fork()
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %92
66: ; preds = %63
%67 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%68 = load i32, i32* %67
%69 = call i32 @close(i32 %68)
%70 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%71 = load i32, i32* %70
%72 = call i32 @close(i32 %71)
%73 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%74 = load i32, i32* %73
%75 = load i32, i32* @STDOUT_FILENO
%76 = call i32 @dup2(i32 %74, i32 %75)
%77 = icmp eq i32 %76, -1
br i1 %77, label %78, label %81
78: ; preds = %66
%79 = load i32, i32* @stderr
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
store i32 2, i32* %1
store i32 1, i32* %11
br label %166
81: ; preds = %66
%82 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 1
%83 = load i32, i32* %82
%84 = load i32, i32* @STDERR_FILENO
%85 = call i32 @dup2(i32 %83, i32 %84)
%86 = icmp eq i32 %85, -1
br i1 %86, label %87, label %90
87: ; preds = %81
%88 = load i32, i32* @stderr
%89 = call i32 (i32, i8*, ...) @fprintf(i32 %88, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
store i32 2, i32* %1
store i32 1, i32* %11
br label %166
90: ; preds = %81
%91 = call i32 @execl(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %49, i32* null)
store i32 2, i32* %1
store i32 1, i32* %11
br label %166
92: ; preds = %63
%93 = call i32 @wait(i32* %12)
%94 = load i32, i32* %12
%95 = call i32 @WIFEXITED(i32 %94)
%96 = icmp ne i32 %95, 0
br i1 %96, label %101, label %97
97: ; preds = %92
%98 = load i32, i32* %12
%99 = call i32 @WEXITSTATUS(i32 %98)
%100 = call i32 (i8*, i8*, ...) @say(i8* %45, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %99)
br label %151
101: ; preds = %92
%102 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%103 = load i32, i32* %102
%104 = load i32, i32* @F_GETFL
%105 = call i32 @fcntl(i32 %103, i32 %104, i32 0)
store i32 %105, i32* %13
%106 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%107 = load i32, i32* %106
%108 = load i32, i32* @F_SETFL
%109 = load i32, i32* %13
%110 = load i32, i32* @O_NONBLOCK
%111 = or i32 %109, %110
%112 = call i32 @fcntl(i32 %107, i32 %108, i32 %111)
store i32 0, i32* %15
br label %113
113: ; preds = %119, %101
%114 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%115 = load i32, i32* %114
%116 = bitcast [256 x i8]* %14 to i8**
%117 = call i32 @read(i32 %115, i8** %116, i32 255)
store i32 %117, i32* %15
%118 = icmp sgt i32 %117, 0
br i1 %118, label %119, label %126
119: ; preds = %113
%120 = load i32, i32* %15
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 %121
store i8 0, i8* %122
%123 = load i32, i32* @stderr
%124 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
%125 = call i32 (i32, i8*, ...) @fprintf(i32 %123, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %124)
br label %113
126: ; preds = %113
%127 = load i32, i32* @stderr
%128 = call i32 @fflush(i32 %127)
%129 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%130 = load i32, i32* %129
%131 = bitcast [256 x i8]* %14 to i8**
%132 = call i32 @read(i32 %130, i8** %131, i32 255)
store i32 %132, i32* %15
%133 = icmp eq i32 %132, -1
br i1 %133, label %134, label %136
134: ; preds = %126
%135 = call i32 (i8*, i8*, ...) @say(i8* %45, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
br label %151
136: ; preds = %126
%137 = load i32, i32* %15
%138 = sext i32 %137 to i64
%139 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 %138
store i8 0, i8* %139
%140 = bitcast [128 x i8]* %16 to i8*
%141 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
%142 = getelementptr inbounds [128 x i8], [128 x i8]* %16, i64 0, i64 0
%143 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %141, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i8* %142)
%144 = icmp eq i32 %143, 1
br i1 %144, label %145, label %148
145: ; preds = %136
%146 = getelementptr inbounds [128 x i8], [128 x i8]* %16, i64 0, i64 0
%147 = call i32 (i8*, i8*, ...) @say(i8* %45, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.12, i64 0, i64 0), i8* %146)
br label %150
148: ; preds = %136
%149 = call i32 (i8*, i8*, ...) @say(i8* %45, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0))
br label %150
150: ; preds = %148, %145
br label %151
151: ; preds = %150, %134, %97
%152 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%153 = load i32, i32* %152
%154 = call i32 @close(i32 %153)
%155 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 1
%156 = load i32, i32* %155
%157 = call i32 @close(i32 %156)
%158 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%159 = load i32, i32* %158
%160 = call i32 @close(i32 %159)
%161 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%162 = load i32, i32* %161
%163 = call i32 @close(i32 %162)
br label %164
164: ; preds = %151
br label %165
165: ; preds = %164, %36
store i32 0, i32* %11
br label %166
166: ; preds = %165, %90, %87, %78, %61
%167 = load i8*, i8** %5
%168 = load i32, i32* %11
switch i32 %168, label %173 [
i32 0, label %169
i32 2, label %17
i32 1, label %171
]
169: ; preds = %166
br label %17
170: ; preds = %17
store i32 0, i32* %1
br label %171
171: ; preds = %170, %166
%172 = load i32, i32* %1
ret i32 %172
173: ; preds = %166
unreachable
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [8 x i8] c"PRIVMSG\00"
@.str.1 = [8 x i8] c":tweet \00"
@.str.2 = [29 x i8] c"%s PRIVMSG %s ::tweet %[^\0A\0D]\00"
@.str.3 = [12 x i8] c"FAIL pipe()\00"
@STDOUT_FILENO = global i32 0
@stderr = global i32 0
@.str.4 = [13 x i8] c"FAIL dup2()\0A\00"
@STDERR_FILENO = global i32 0
@.str.5 = [22 x i8] c"/home/fridim/bin/twty\00"
@.str.6 = [5 x i8] c"twty\00"
@.str.7 = [22 x i8] c"twty failed, ret = %d\00"
@F_GETFL = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@.str.8 = [3 x i8] c"%s\00"
@.str.9 = [16 x i8] c"FAIL read pipe.\00"
@.str.10 = [15 x i8] c"tweeted: %127s\00"
@.str.11 = [14 x i8] c"tweeted: %s%s\00"
@.str.12 = [37 x i8] c"https://twitter.com/cabotirc/status/\00"
@.str.13 = [29 x i8] c"could not parse twty output.\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i8*
%3 = alloca [2 x i32]
%4 = alloca [2 x i32]
%5 = alloca i32
%6 = alloca [256 x i8]
%7 = alloca [128 x i8]
%8 = bitcast i64* %1 to i8*
store i64 0, i64* %1
%9 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%10 = load i32, i32* @stdin
%11 = call i32 @getline(i8** %2, i64* %1, i32 %10)
%12 = icmp eq i32 %11, -1
br i1 %12, label %150, label %13
13: ; preds = %0
%14 = bitcast [2 x i32]* %3 to i8*
%15 = bitcast [2 x i32]* %4 to i8*
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%17 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%18 = bitcast i32* %5 to i8*
%19 = bitcast [256 x i8]* %6 to i8**
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%22 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%23 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
br label %24
24: ; preds = %32, %13
%25 = load i8*, i8** %2
%26 = call i32* @strstr(i8* dereferenceable(1) %25, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %33
28: ; preds = %24, %33, %36
%29 = load i32, i32* @stdin
%30 = call i32 @getline(i8** %2, i64* %1, i32 %29)
%31 = icmp eq i32 %30, -1
br i1 %31, label %150, label %32
32: ; preds = %28, %146
br label %24
33: ; preds = %24
%34 = call i32* @strstr(i8* dereferenceable(1) %25, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp eq i32* %34, null
br i1 %35, label %28, label %36
36: ; preds = %33
%37 = call i32 @strlen(i8* %25)
%38 = icmp slt i32 %37, 1
br i1 %38, label %28, label %39
39: ; preds = %36
%40 = load i8*, i8** %2
%41 = call i32 @strlen(i8* %40)
%42 = zext i32 %41 to i64
%43 = call i8* @llvm.stacksave()
%44 = alloca i8, i64 %42
%45 = load i8*, i8** %2
%46 = call i32 @strlen(i8* %45)
%47 = zext i32 %46 to i64
%48 = alloca i8, i64 %47
%49 = load i8*, i8** %2
%50 = call i32 @strlen(i8* %49)
%51 = zext i32 %50 to i64
%52 = alloca i8, i64 %51
%53 = load i8*, i8** %2
%54 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %53, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %44, i8* %48, i8* %52)
%55 = icmp eq i32 %54, 3
br i1 %55, label %56, label %146
56: ; preds = %39
%57 = call i32 @pipe(i32* %16)
%58 = icmp eq i32 %57, -1
br i1 %58, label %144, label %59
59: ; preds = %56
%60 = call i32 @pipe(i32* %17)
%61 = icmp eq i32 %60, -1
br i1 %61, label %144, label %62
62: ; preds = %59
%63 = call i64 (...) @fork()
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %87
65: ; preds = %62
%66 = load i32, i32* %16
%67 = call i32 @close(i32 %66)
%68 = load i32, i32* %17
%69 = call i32 @close(i32 %68)
%70 = load i32, i32* %22
%71 = load i32, i32* @STDOUT_FILENO
%72 = call i32 @dup2(i32 %70, i32 %71)
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %77
74: ; preds = %65
%75 = load i32, i32* @stderr
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %143
77: ; preds = %65
%78 = load i32, i32* %23
%79 = load i32, i32* @STDERR_FILENO
%80 = call i32 @dup2(i32 %78, i32 %79)
%81 = icmp eq i32 %80, -1
br i1 %81, label %82, label %85
82: ; preds = %77
%83 = load i32, i32* @stderr
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %143
85: ; preds = %77
%86 = call i32 @execl(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %52, i32* null)
br label %143
87: ; preds = %62
%88 = call i32 @wait(i32* %5)
%89 = load i32, i32* %5
%90 = call i32 @WIFEXITED(i32 %89)
%91 = icmp eq i32 %90, 0
br i1 %91, label %92, label %96
92: ; preds = %87
%93 = load i32, i32* %5
%94 = call i32 @WEXITSTATUS(i32 %93)
%95 = call i32 (i8*, i8*, ...) @say(i8* %48, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %94)
br label %134
96: ; preds = %87
%97 = load i32, i32* %17
%98 = load i32, i32* @F_GETFL
%99 = call i32 @fcntl(i32 %97, i32 %98, i32 0)
%100 = load i32, i32* %17
%101 = load i32, i32* @F_SETFL
%102 = load i32, i32* @O_NONBLOCK
%103 = or i32 %102, %99
%104 = call i32 @fcntl(i32 %100, i32 %101, i32 %103)
%105 = load i32, i32* %17
%106 = call i32 @read(i32 %105, i8** %19, i32 255)
%107 = icmp sgt i32 %106, 0
br i1 %107, label %108, label %117
108: ; preds = %96, %108
%109 = phi i32 [ %115, %108 ], [ %106, %96 ]
%110 = zext i32 %109 to i64
%111 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 %110
store i8 0, i8* %111
%112 = load i32, i32* @stderr
%113 = call i32 (i32, i8*, ...) @fprintf(i32 %112, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %20)
%114 = load i32, i32* %17
%115 = call i32 @read(i32 %114, i8** %19, i32 255)
%116 = icmp sgt i32 %115, 0
br i1 %116, label %108, label %117
117: ; preds = %108, %96
%118 = load i32, i32* @stderr
%119 = call i32 @fflush(i32 %118)
%120 = load i32, i32* %16
%121 = call i32 @read(i32 %120, i8** %19, i32 255)
%122 = icmp eq i32 %121, -1
br i1 %122, label %123, label %125
123: ; preds = %117
%124 = call i32 (i8*, i8*, ...) @say(i8* %48, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
br label %134
125: ; preds = %117
%126 = sext i32 %121 to i64
%127 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 %126
store i8 0, i8* %127
%128 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %20, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i8* %21)
%129 = icmp eq i32 %128, 1
br i1 %129, label %130, label %132
130: ; preds = %125
%131 = call i32 (i8*, i8*, ...) @say(i8* %48, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.12, i64 0, i64 0), i8* %21)
br label %134
132: ; preds = %125
%133 = call i32 (i8*, i8*, ...) @say(i8* %48, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0))
br label %134
134: ; preds = %92, %123, %132, %130
%135 = load i32, i32* %22
%136 = call i32 @close(i32 %135)
%137 = load i32, i32* %23
%138 = call i32 @close(i32 %137)
%139 = load i32, i32* %16
%140 = call i32 @close(i32 %139)
%141 = load i32, i32* %17
%142 = call i32 @close(i32 %141)
br label %146
143: ; preds = %74, %82, %85
br label %150
144: ; preds = %56, %59
%145 = call i32 (i8*, i8*, ...) @say(i8* %48, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %146
146: ; preds = %39, %134, %144
%147 = load i32, i32* @stdin
%148 = call i32 @getline(i8** %2, i64* %1, i32 %147)
%149 = icmp eq i32 %148, -1
br i1 %149, label %150, label %32
150: ; preds = %146, %28, %143, %0
%151 = phi i32 [ 0, %0 ], [ 2, %143 ], [ 0, %28 ], [ 0, %146 ]
ret i32 %151
}