#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__ EOF;
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char *);
scalar_t__ fputs(char *, int /*<<< orphan*/);
int pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
char *strerror(int);
int main(int argc, char *argv[]) {
  char buf[512];
  FILE *fp;
  if ((fp = popen("./convers", "r")) == NULL) {
    fprintf(stderr, "Err.: %d popen() - %s\n", errno, strerror(errno));
    exit(EXIT_FAILURE);
  }
  while (1) {
    fputs("shell> ", stdout);
    fflush(stdout);
    if (fgets(buf, 512, fp) == NULL)
      break;
    if (fputs(buf, stdout) == EOF) {
      fprintf(stderr, "Err.: %d fputs() - %s\n", errno, strerror(errno));
      exit(EXIT_FAILURE);
    }
  }
  if (pclose(fp) == -1) {
    fprintf(stderr, "Err.: %d pclose() - %s\n", errno, strerror(errno));
    exit(EXIT_FAILURE);
  }
  putchar('\n');
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe50(%rip),%rdi
lea    0xe53(%rip),%rsi
call   1090 <popen@plt>
mov    %rax,-0x218(%rbp)
cmp    $0x0,%rax
jne    1222 <main+0x92>
mov    0x2e04(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x220(%rbp)
mov    0x2ded(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x21c(%rbp)
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x220(%rbp),%edi
mov    -0x21c(%rbp),%edx
mov    %rax,%rcx
lea    0xdfd(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
jmp    1227 <main+0x97>
mov    0x2d92(%rip),%rax
mov    (%rax),%esi
lea    0xdec(%rip),%rdi
call   1050 <fputs@plt>
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
lea    -0x210(%rbp),%rdi
mov    -0x218(%rbp),%rdx
mov    $0x200,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    1271 <main+0xe1>
jmp    12f0 <main+0x160>
lea    -0x210(%rbp),%rdi
mov    0x2d41(%rip),%rax
mov    (%rax),%esi
call   1050 <fputs@plt>
mov    0x2d5b(%rip),%rcx
cmp    (%rcx),%rax
jne    12eb <main+0x15b>
mov    0x2d3b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x228(%rbp)
mov    0x2d24(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x224(%rbp)
mov    0x2d15(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x228(%rbp),%edi
mov    -0x224(%rbp),%edx
mov    %rax,%rcx
lea    0xd53(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2ce4(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
jmp    1227 <main+0x97>
mov    -0x218(%rbp),%rdi
call   1040 <pclose@plt>
cmp    $0xffffffff,%eax
jne    135a <main+0x1ca>
mov    0x2ccc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x230(%rbp)
mov    0x2cb5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x22c(%rbp)
mov    0x2ca6(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x230(%rbp),%edi
mov    -0x22c(%rbp),%edx
mov    %rax,%rcx
lea    0xcfb(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2c75(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2c4d(%rip),%rax
mov    (%rax),%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x200,%rsp
lea    0xe5a(%rip),%rdi
lea    0xe5d(%rip),%rsi
call   1090 <popen@plt>
test   %rax,%rax
je     1283 <main+0xf3>
mov    %rax,%r15
mov    0x2dfb(%rip),%rbp
lea    0xe57(%rip),%r14
mov    %rsp,%rbx
mov    0x2e12(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
mov    0x0(%rbp),%esi
mov    %r14,%rdi
call   1050 <fputs@plt>
mov    0x0(%rbp),%edi
call   1080 <fflush@plt>
mov    %rbx,%rdi
mov    $0x200,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1253 <main+0xc3>
mov    0x0(%rbp),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
cmp    (%r12),%rax
jne    11e0 <main+0x50>
mov    0x2db8(%rip),%rax
mov    (%rax),%ebx
mov    0x2da7(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10b0 <strerror@plt>
lea    0xdf2(%rip),%rsi
mov    %ebx,%edi
mov    %ebp,%edx
mov    %rax,%rcx
call   1070 <fprintf@plt>
mov    0x2d7c(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    %r15,%rdi
call   1040 <pclose@plt>
cmp    $0xffffffff,%eax
je     12a5 <main+0x115>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2d47(%rip),%rax
mov    (%rax),%eax
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d4e(%rip),%rax
mov    (%rax),%ebx
mov    0x2d3d(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10b0 <strerror@plt>
lea    0xd69(%rip),%rsi
jmp    1239 <main+0xa9>
mov    0x2d2c(%rip),%rax
mov    (%rax),%ebx
mov    0x2d1b(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10b0 <strerror@plt>
lea    0xd7d(%rip),%rsi
jmp    1239 <main+0xa9>

LLVM IR (-O0):
@.str = [10 x i8] c"./convers\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [23 x i8] c"Err.: %d popen() - %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.3 = [8 x i8] c"shell> \00"
@stdout = global i32 0
@EOF = global i64 0
@.str.4 = [23 x i8] c"Err.: %d fputs() - %s\0A\00"
@.str.5 = [24 x i8] c"Err.: %d pclose() - %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [512 x i8]
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32* @popen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %7
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %18
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i32, i32* @errno
%13 = load i32, i32* @errno
%14 = call i8* @strerror(i32 %13)
%15 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %12, i8* %14)
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %2
br label %19
19: ; preds = %18, %43
%20 = load i32, i32* @stdout
%21 = call i64 @fputs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = load i32, i32* @stdout
%23 = call i32 @fflush(i32 %22)
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%25 = load i32*, i32** %7
%26 = call i32* @fgets(i8* %24, i32 512, i32* %25)
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %29
28: ; preds = %19
br label %44
29: ; preds = %19
%30 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%31 = load i32, i32* @stdout
%32 = call i64 @fputs(i8* %30, i32 %31)
%33 = load i64, i64* @EOF
%34 = icmp eq i64 %32, %33
br i1 %34, label %35, label %43
35: ; preds = %29
%36 = load i32, i32* @stderr
%37 = load i32, i32* @errno
%38 = load i32, i32* @errno
%39 = call i8* @strerror(i32 %38)
%40 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %37, i8* %39)
%41 = load i32, i32* @EXIT_FAILURE
%42 = call i32 @exit(i32 %41)
unreachable
43: ; preds = %29
br label %19
44: ; preds = %28
%45 = load i32*, i32** %7
%46 = call i32 @pclose(i32* %45)
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %56
48: ; preds = %44
%49 = load i32, i32* @stderr
%50 = load i32, i32* @errno
%51 = load i32, i32* @errno
%52 = call i8* @strerror(i32 %51)
%53 = call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %50, i8* %52)
%54 = load i32, i32* @EXIT_FAILURE
%55 = call i32 @exit(i32 %54)
unreachable
56: ; preds = %44
%57 = call i32 @putchar(i8 signext 10)
%58 = load i32, i32* @EXIT_SUCCESS
ret i32 %58
}

LLVM IR (-O2):
@.str = [10 x i8] c"./convers\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [23 x i8] c"Err.: %d popen() - %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.3 = [8 x i8] c"shell> \00"
@stdout = global i32 0
@EOF = global i64 0
@.str.4 = [23 x i8] c"Err.: %d fputs() - %s\0A\00"
@.str.5 = [24 x i8] c"Err.: %d pclose() - %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = tail call i32* @popen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %14
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = load i32, i32* @errno
%10 = tail call i8* @strerror(i32 %9)
%11 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %9, i8* %10)
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %2, %21
%15 = load i32, i32* @stdout
%16 = call i64 @fputs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %15)
%17 = load i32, i32* @stdout
%18 = call i32 @fflush(i32 %17)
%19 = call i32* @fgets(i8* %4, i32 512, i32* %5)
%20 = icmp eq i32* %19, null
br i1 %20, label %33, label %21
21: ; preds = %14
%22 = load i32, i32* @stdout
%23 = call i64 @fputs(i8* %4, i32 %22)
%24 = load i64, i64* @EOF
%25 = icmp eq i64 %23, %24
br i1 %25, label %26, label %14
26: ; preds = %21
%27 = load i32, i32* @stderr
%28 = load i32, i32* @errno
%29 = call i8* @strerror(i32 %28)
%30 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %28, i8* %29)
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
33: ; preds = %14
%34 = call i32 @pclose(i32* %5)
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %43
36: ; preds = %33
%37 = load i32, i32* @stderr
%38 = load i32, i32* @errno
%39 = call i8* @strerror(i32 %38)
%40 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %38, i8* %39)
%41 = load i32, i32* @EXIT_FAILURE
%42 = call i32 @exit(i32 %41)
unreachable
43: ; preds = %33
%44 = call i32 @putchar(i8 signext 10)
%45 = load i32, i32* @EXIT_SUCCESS
ret i32 %45
}