#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*/ FILE;

/* Variables and functions */
scalar_t__ EAGAIN;
int /*<<< orphan*/ _exit(int);
int /*<<< orphan*/ dup2(int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ errno;
int /*<<< orphan*/ execl(char *, char *, char *, char *, char *);
int /*<<< orphan*/ execlp(char *, char *, char *, char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fileno(int /*<<< orphan*/ *);
int fork();
int /*<<< orphan*/ perror(char *);
int wait(int *);
void inews(FILE *infile) {
  int status;
  int pid;
  do {
    pid = fork();
  } while (pid == -1 && errno == EAGAIN);
  if (pid == -1) {
    perror("fork");
    return;
  }
  if (pid != 0) {
    while (pid != wait(&status))
      ;
    return;
  }
  dup2(fileno(infile), 0);
  fclose(infile);
  execlp("inews", "inews", "-h", "-S", (char *)0);
  execl("/usr/local/news/inews", "inews", "-h", "-S", (char *)0);
  execl("/usr/local/lib/news/inews", "inews", "-h", "-S", (char *)0);
  execl("/etc/inews", "inews", "-h", "-S", (char *)0);
  execl("/usr/etc/inews", "inews", "-h", "-S", (char *)0);
  execl("/usr/news/inews", "inews", "-h", "-S", (char *)0);
  execl("/usr/news/bin/inews", "inews", "-h", "-S", (char *)0);
  perror("execl");
  _exit(1);
}


x86 assembly (clang, -O0):
<inews>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   10b0 <fork@plt>
mov    %eax,-0x10(%rbp)
xor    %eax,%eax
cmpl   $0xffffffff,-0x10(%rbp)
mov    %al,-0x11(%rbp)
jne    11cf <inews+0x3f>
mov    0x2e24(%rip),%rax
mov    (%rax),%rax
mov    0x2e0a(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    119c <inews+0xc>
cmpl   $0xffffffff,-0x10(%rbp)
jne    11f5 <inews+0x65>
lea    0xe15(%rip),%rdi
call   1070 <perror@plt>
jmp    1361 <inews+0x1d1>
cmpl   $0x0,-0x10(%rbp)
je     122a <inews+0x9a>
jmp    1204 <inews+0x74>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    -0xc(%rbp),%rdi
call   10a0 <wait@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
je     1225 <inews+0x95>
jmp    1204 <inews+0x74>
jmp    1361 <inews+0x1d1>
mov    -0x8(%rbp),%rdi
call   1060 <fileno@plt>
mov    %eax,%edi
xor    %esi,%esi
call   1050 <dup2@plt>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xdf8(%rip),%rsi
lea    0xdb2(%rip),%rdx
lea    0xdae(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
mov    %rsi,%rdi
call   1080 <execlp@plt>
lea    0xd9d(%rip),%rdi
lea    0xdcf(%rip),%rsi
lea    0xd89(%rip),%rdx
lea    0xd85(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1090 <execl@plt>
lea    0xd8d(%rip),%rdi
lea    0xda9(%rip),%rsi
lea    0xd63(%rip),%rdx
lea    0xd5f(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1090 <execl@plt>
lea    0xd85(%rip),%rdi
lea    0xd83(%rip),%rsi
lea    0xd3d(%rip),%rdx
lea    0xd39(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1090 <execl@plt>
lea    0xd5b(%rip),%rdi
lea    0xd5d(%rip),%rsi
lea    0xd17(%rip),%rdx
lea    0xd13(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1090 <execl@plt>
lea    0xd44(%rip),%rdi
lea    0xd37(%rip),%rsi
lea    0xcf1(%rip),%rdx
lea    0xced(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1090 <execl@plt>
lea    0xd2e(%rip),%rdi
lea    0xd11(%rip),%rsi
lea    0xccb(%rip),%rdx
lea    0xcc7(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1090 <execl@plt>
lea    0xd1c(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1030 <_exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inews>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2e3f(%rip),%r15
mov    0x2e28(%rip),%rbx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10b0 <fork@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    11c6 <inews+0x36>
mov    (%rbx),%rax
cmp    %rax,(%r15)
je     11b0 <inews+0x20>
cmp    $0xffffffff,%ebp
je     11f7 <inews+0x67>
test   %ebp,%ebp
je     120d <inews+0x7d>
lea    0x4(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   10a0 <wait@plt>
cmp    %eax,%ebp
jne    11e0 <inews+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe02(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <perror@plt>
mov    %r14,%rdi
call   1060 <fileno@plt>
mov    %eax,%edi
xor    %esi,%esi
call   1050 <dup2@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
lea    0xe17(%rip),%rbx
lea    0xdd1(%rip),%r14
lea    0xdcd(%rip),%r15
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %r8d,%r8d
call   1080 <execlp@plt>
lea    0xdb5(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %r8d,%r8d
call   1090 <execl@plt>
lea    0xdb3(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %r8d,%r8d
call   1090 <execl@plt>
lea    0xdb9(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %r8d,%r8d
call   1090 <execl@plt>
lea    0xd9d(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %r8d,%r8d
call   1090 <execl@plt>
lea    0xd94(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %r8d,%r8d
call   1090 <execl@plt>
lea    0xd8c(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %r8d,%r8d
call   1090 <execl@plt>
lea    0xd88(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
@errno = global i64 0
@EAGAIN = global i64 0
@.str = [5 x i8] c"fork\00"
@.str.1 = [6 x i8] c"inews\00"
@.str.2 = [3 x i8] c"-h\00"
@.str.3 = [3 x i8] c"-S\00"
@.str.4 = [22 x i8] c"/usr/local/news/inews\00"
@.str.5 = [26 x i8] c"/usr/local/lib/news/inews\00"
@.str.6 = [11 x i8] c"/etc/inews\00"
@.str.7 = [15 x i8] c"/usr/etc/inews\00"
@.str.8 = [16 x i8] c"/usr/news/inews\00"
@.str.9 = [20 x i8] c"/usr/news/bin/inews\00"
@.str.10 = [6 x i8] c"execl\00"
define void @inews(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
br label %5
5: ; preds = %14, %1
%6 = call i32 (...) @fork()
store i32 %6, i32* %4
br label %7
7: ; preds = %5
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = load i64, i64* @errno
%12 = load i64, i64* @EAGAIN
%13 = icmp eq i64 %11, %12
br label %14
14: ; preds = %10, %7
%15 = phi i1 [ false, %7 ], [ %13, %10 ]
br i1 %15, label %5, label %16
16: ; preds = %14
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %46
21: ; preds = %16
%22 = load i32, i32* %4
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %31
24: ; preds = %21
br label %25
25: ; preds = %29, %24
%26 = load i32, i32* %4
%27 = call i32 @wait(i32* %3)
%28 = icmp ne i32 %26, %27
br i1 %28, label %29, label %30
29: ; preds = %25
br label %25
30: ; preds = %25
br label %46
31: ; preds = %21
%32 = load i32*, i32** %2
%33 = call i32 @fileno(i32* %32)
%34 = call i32 @dup2(i32 %33, i32 0)
%35 = load i32*, i32** %2
%36 = call i32 @fclose(i32* %35)
%37 = call i32 @execlp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* null)
%38 = call i32 @execl(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* null)
%39 = call i32 @execl(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* null)
%40 = call i32 @execl(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* null)
%41 = call i32 @execl(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* null)
%42 = call i32 @execl(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* null)
%43 = call i32 @execl(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* null)
%44 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%45 = call i32 @_exit(i32 1)
unreachable
46: ; preds = %30, %19
ret void
}

LLVM IR (-O2):
@errno = global i64 0
@EAGAIN = global i64 0
@.str = [5 x i8] c"fork\00"
@.str.1 = [6 x i8] c"inews\00"
@.str.2 = [3 x i8] c"-h\00"
@.str.3 = [3 x i8] c"-S\00"
@.str.4 = [22 x i8] c"/usr/local/news/inews\00"
@.str.5 = [26 x i8] c"/usr/local/lib/news/inews\00"
@.str.6 = [11 x i8] c"/etc/inews\00"
@.str.7 = [15 x i8] c"/usr/etc/inews\00"
@.str.8 = [16 x i8] c"/usr/news/inews\00"
@.str.9 = [20 x i8] c"/usr/news/bin/inews\00"
@.str.10 = [6 x i8] c"execl\00"
define void @inews(i32* nocapture %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
br label %4
4: ; preds = %4, %1
%5 = tail call i32 (...) @fork()
%6 = icmp eq i32 %5, -1
%7 = load i64, i64* @errno
%8 = load i64, i64* @EAGAIN
%9 = icmp eq i64 %7, %8
%10 = select i1 %6, i1 %9, i1 false
br i1 %10, label %4, label %11
11: ; preds = %4
br i1 %6, label %12, label %14
12: ; preds = %11
%13 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %32
14: ; preds = %11
%15 = icmp eq i32 %5, 0
br i1 %15, label %19, label %16
16: ; preds = %14, %16
%17 = call i32 @wait(i32* %2)
%18 = icmp eq i32 %5, %17
br i1 %18, label %32, label %16
19: ; preds = %14
%20 = tail call i32 @fileno(i32* %0)
%21 = tail call i32 @dup2(i32 %20, i32 0)
%22 = tail call i32 @fclose(i32* %0)
%23 = tail call i32 @execlp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* null)
%24 = tail call i32 @execl(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* null)
%25 = tail call i32 @execl(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* null)
%26 = tail call i32 @execl(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* null)
%27 = tail call i32 @execl(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* null)
%28 = tail call i32 @execl(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* null)
%29 = tail call i32 @execl(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* null)
%30 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%31 = tail call i32 @_exit(i32 1)
unreachable
32: ; preds = %16, %12
ret void
}