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

/* Variables and functions */
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ dup2(int, int);
int /*<<< orphan*/ error(char *);
int execle(char *, char *, char *, char *, char *, int /*<<< orphan*/ *,
           char **);
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ open_url(char *);
int pipe(int *);
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  char *phrase = argv[1];
  char *vars[] = {"RSS_FEED=http://rss.cnn.com/rss/edition.rss", NULL};
  int fd[2];
  if (pipe(fd) == -1) {
    error("Can't create the pipe");
  }
  pid_t pid = fork();
  if (pid == -1) {
    error("Can't fork process");
  }
  if (!pid) {
    dup2(fd[1], 1);
    close(fd[0]);
    if (execle("/usr/bin/python", "/usr/bin/python", "./rssgossip.py", "-u",
               phrase, NULL, vars) == -1) {
      error("Can't run script");
    }
  }
  dup2(fd[0], 0);
  close(fd[1]);
  char line[255];
  while (fgets(line, 255, stdin)) {
    if (line[0] == '\t')
      open_url(line + 1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    0x2c54(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c51(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    -0x38(%rbp),%rdi
call   1050 <pipe@plt>
cmp    $0xffffffff,%eax
jne    11d9 <main+0x59>
lea    0xe58(%rip),%rdi
call   1070 <error@plt>
mov    $0x0,%al
call   10a0 <fork@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xffffffff,-0x3c(%rbp)
jne    11f9 <main+0x79>
lea    0xe4e(%rip),%rdi
call   1070 <error@plt>
cmpl   $0x0,-0x3c(%rbp)
jne    1260 <main+0xe0>
mov    -0x34(%rbp),%edi
mov    $0x1,%esi
call   1030 <dup2@plt>
mov    -0x38(%rbp),%edi
call   1040 <close@plt>
mov    -0x18(%rbp),%r8
lea    -0x30(%rbp),%rax
lea    0xe2e(%rip),%rsi
lea    0xe37(%rip),%rdx
lea    0xe3f(%rip),%rcx
xor    %edi,%edi
mov    %edi,%r9d
mov    %rsi,%rdi
mov    %rax,(%rsp)
call   1090 <execle@plt>
cmp    $0xffffffff,%eax
jne    125b <main+0xdb>
lea    0xe21(%rip),%rdi
call   1070 <error@plt>
jmp    1260 <main+0xe0>
mov    -0x38(%rbp),%edi
xor    %esi,%esi
call   1030 <dup2@plt>
mov    -0x34(%rbp),%edi
call   1040 <close@plt>
lea    -0x140(%rbp),%rdi
mov    0x2d60(%rip),%rax
mov    (%rax),%edx
mov    $0xff,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     12bb <main+0x13b>
movsbl -0x140(%rbp),%eax
cmp    $0x9,%eax
jne    12b6 <main+0x136>
lea    -0x140(%rbp),%rdi
add    $0x1,%rdi
call   1080 <open_url@plt>
jmp    1272 <main+0xf2>
xor    %eax,%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x120,%rsp
mov    0x8(%rsi),%rbx
movaps 0x2c69(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x8(%rsp),%rdi
call   1050 <pipe@plt>
cmp    $0xffffffff,%eax
jne    11b7 <main+0x37>
lea    0xe7a(%rip),%rdi
call   1070 <error@plt>
xor    %eax,%eax
call   10a0 <fork@plt>
cmp    $0xffffffff,%eax
je     1218 <main+0x98>
test   %eax,%eax
jne    1224 <main+0xa4>
mov    0xc(%rsp),%edi
mov    $0x1,%esi
call   1030 <dup2@plt>
mov    0x8(%rsp),%edi
call   1040 <close@plt>
lea    0x10(%rsp),%rax
mov    %rax,(%rsp)
lea    0xe67(%rip),%rdi
lea    0xe70(%rip),%rdx
lea    0xe78(%rip),%rcx
mov    %rdi,%rsi
mov    %rbx,%r8
xor    %r9d,%r9d
call   1090 <execle@plt>
cmp    $0xffffffff,%eax
jne    1224 <main+0xa4>
lea    0xe61(%rip),%rdi
jmp    121f <main+0x9f>
lea    0xe23(%rip),%rdi
call   1070 <error@plt>
mov    0x8(%rsp),%edi
xor    %esi,%esi
call   1030 <dup2@plt>
mov    0xc(%rsp),%edi
call   1040 <close@plt>
mov    0x2da1(%rip),%r15
mov    (%r15),%edx
lea    0x20(%rsp),%rdi
mov    $0xff,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     1296 <main+0x116>
lea    0x21(%rsp),%r14
lea    0x20(%rsp),%rbx
jmp    1285 <main+0x105>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r15),%edx
mov    %rbx,%rdi
mov    $0xff,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     1296 <main+0x116>
cmpb   $0x9,0x20(%rsp)
jne    1270 <main+0xf0>
mov    %r14,%rdi
call   1080 <open_url@plt>
jmp    1270 <main+0xf0>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [44 x i8] c"RSS_FEED=http://rss.cnn.com/rss/edition.rss\00"
@__const.main.vars = [2 x i8*] [i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i32 0, i32 0), i8* null]
@.str.1 = [22 x i8] c"Can't create the pipe\00"
@.str.2 = [19 x i8] c"Can't fork process\00"
@.str.3 = [16 x i8] c"/usr/bin/python\00"
@.str.4 = [15 x i8] c"./rssgossip.py\00"
@.str.5 = [3 x i8] c"-u\00"
@.str.6 = [17 x i8] c"Can't run script\00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [2 x i8*]
%8 = alloca [2 x i32]
%9 = alloca i32
%10 = alloca [255 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
store i8* %13, i8** %6
%14 = bitcast [2 x i8*]* %7 to i8*
%15 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%16 = call i32 @pipe(i32* %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %18, %2
%21 = call i32 (...) @fork()
store i32 %21, i32* %9
%22 = load i32, i32* %9
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 @error(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %26
26: ; preds = %24, %20
%27 = load i32, i32* %9
%28 = icmp ne i32 %27, 0
br i1 %28, label %43, label %29
29: ; preds = %26
%30 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%31 = load i32, i32* %30
%32 = call i32 @dup2(i32 %31, i32 1)
%33 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%34 = load i32, i32* %33
%35 = call i32 @close(i32 %34)
%36 = load i8*, i8** %6
%37 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 0
%38 = call i32 @execle(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %36, i32* null, i8** %37)
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %42
40: ; preds = %29
%41 = call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
br label %42
42: ; preds = %40, %29
br label %43
43: ; preds = %42, %26
%44 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%45 = load i32, i32* %44
%46 = call i32 @dup2(i32 %45, i32 0)
%47 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%48 = load i32, i32* %47
%49 = call i32 @close(i32 %48)
br label %50
50: ; preds = %64, %43
%51 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%52 = load i32, i32* @stdin
%53 = call i64 @fgets(i8* %51, i32 255, i32 %52)
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %65
55: ; preds = %50
%56 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp eq i32 %58, 9
br i1 %59, label %60, label %64
60: ; preds = %55
%61 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%62 = getelementptr inbounds i8, i8* %61, i64 1
%63 = call i32 @open_url(i8* %62)
br label %64
64: ; preds = %60, %55
br label %50
65: ; preds = %50
ret i32 0
}

LLVM IR (-O2):
@.str = [44 x i8] c"RSS_FEED=http://rss.cnn.com/rss/edition.rss\00"
@__const.main.vars = [2 x i8*] [i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i32 0, i32 0), i8* null]
@.str.1 = [22 x i8] c"Can't create the pipe\00"
@.str.2 = [19 x i8] c"Can't fork process\00"
@.str.3 = [16 x i8] c"/usr/bin/python\00"
@.str.4 = [15 x i8] c"./rssgossip.py\00"
@.str.5 = [3 x i8] c"-u\00"
@.str.6 = [17 x i8] c"Can't run script\00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x i8*]
%4 = alloca [2 x i32]
%5 = alloca [255 x i8]
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = bitcast [2 x i8*]* %3 to i8*
%9 = bitcast [2 x i32]* %4 to i8*
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%11 = call i32 @pipe(i32* %10)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %2
%16 = call i32 (...) @fork()
switch i32 %16, label %29 [
i32 -1, label %26
i32 0, label %17
]
17: ; preds = %15
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%19 = load i32, i32* %18
%20 = call i32 @dup2(i32 %19, i32 1)
%21 = load i32, i32* %10
%22 = call i32 @close(i32 %21)
%23 = getelementptr inbounds [2 x i8*], [2 x i8*]* %3, i64 0, i64 0
%24 = call i32 @execle(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %7, i32* null, i8** %23)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %29
26: ; preds = %17, %15
%27 = phi i8* [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), %15 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), %17 ]
%28 = call i32 @error(i8* %27)
br label %29
29: ; preds = %26, %15, %17
%30 = load i32, i32* %10
%31 = call i32 @dup2(i32 %30, i32 0)
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%33 = load i32, i32* %32
%34 = call i32 @close(i32 %33)
%35 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%36 = load i32, i32* @stdin
%37 = call i64 @fgets(i8* %35, i32 255, i32 %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %50, label %39
39: ; preds = %29
%40 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 1
br label %41
41: ; preds = %39, %46
%42 = load i8, i8* %35
%43 = icmp eq i8 %42, 9
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call i32 @open_url(i8* %40)
br label %46
46: ; preds = %44, %41
%47 = load i32, i32* @stdin
%48 = call i64 @fgets(i8* %35, i32 255, i32 %47)
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %41
50: ; preds = %46, %29
ret i32 0
}