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

/* Variables and functions */
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ dup2(int, int);
int /*<<< orphan*/ execlp(char *, char *, char *, int /*<<< orphan*/ *);
int fork();
int /*<<< orphan*/ pipe(int *);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
int /*<<< orphan*/ scanf(char *, int *, int *);
int /*<<< orphan*/ snprintf(char *, int, char *, int, int);
int strlen(char *);
int /*<<< orphan*/ write(int, char *, int);
int main(void) {
  int a, b, blen, pid;
  char buf[1024];
  int fd1[2], fd2[2];
  scanf("%d%d", &a, &b);
  snprintf(buf, sizeof(buf), "%d + %d\n", a, b);
  blen = strlen(buf);
  pipe(fd1);
  pipe(fd2);
  if (!(pid = fork())) {
    dup2(fd1[0], 0);
    close(fd1[0]);
    close(fd1[1]);
    dup2(fd2[1], 1);
    close(fd2[0]);
    close(fd2[1]);
    execlp("/usr/bin/bc", "/usr/bin/bc", "--quiet", NULL);
  }
  write(fd1[1], buf, blen);
  close(fd1[0]);
  close(fd1[1]);
  close(fd2[1]);
  blen = read(fd2[0], buf, sizeof(buf));
  buf[blen] = 0;
  printf("%s", buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe37(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   10b0 <scanf@plt>
lea    -0x420(%rbp),%rdi
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%r8d
mov    $0x400,%esi
lea    0xe15(%rip),%rdx
call   1070 <snprintf@plt>
lea    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x10(%rbp)
lea    -0x428(%rbp),%rdi
call   1090 <pipe@plt>
lea    -0x430(%rbp),%rdi
call   1090 <pipe@plt>
mov    $0x0,%al
call   10d0 <fork@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jne    1292 <main+0xe2>
mov    -0x428(%rbp),%edi
xor    %esi,%esi
call   1050 <dup2@plt>
mov    -0x428(%rbp),%edi
call   1080 <close@plt>
mov    -0x424(%rbp),%edi
call   1080 <close@plt>
mov    -0x42c(%rbp),%edi
mov    $0x1,%esi
call   1050 <dup2@plt>
mov    -0x430(%rbp),%edi
call   1080 <close@plt>
mov    -0x42c(%rbp),%edi
call   1080 <close@plt>
lea    0xd8f(%rip),%rsi
lea    0xd94(%rip),%rdx
xor    %eax,%eax
mov    %eax,%ecx
mov    %rsi,%rdi
call   10c0 <execlp@plt>
mov    -0x424(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    -0x10(%rbp),%edx
call   1030 <write@plt>
mov    -0x428(%rbp),%edi
call   1080 <close@plt>
mov    -0x424(%rbp),%edi
call   1080 <close@plt>
mov    -0x42c(%rbp),%edi
call   1080 <close@plt>
mov    -0x430(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   10a0 <read@plt>
mov    %eax,-0x10(%rbp)
movslq -0x10(%rbp),%rax
movb   $0x0,-0x420(%rbp,%rax,1)
lea    -0x420(%rbp),%rsi
lea    0xd26(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x428,%rsp
lea    0xe40(%rip),%rdi
lea    0x1c(%rsp),%rsi
lea    0x18(%rsp),%rdx
call   10b0 <scanf@plt>
mov    0x1c(%rsp),%ecx
mov    0x18(%rsp),%r8d
lea    0xe26(%rip),%rdx
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1070 <snprintf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
lea    0x8(%rsp),%rdi
call   1090 <pipe@plt>
lea    0x10(%rsp),%rdi
call   1090 <pipe@plt>
xor    %eax,%eax
call   10d0 <fork@plt>
test   %eax,%eax
jne    126f <main+0xbf>
mov    0x8(%rsp),%edi
xor    %esi,%esi
call   1050 <dup2@plt>
mov    0x8(%rsp),%edi
call   1080 <close@plt>
mov    0xc(%rsp),%edi
call   1080 <close@plt>
mov    0x14(%rsp),%edi
mov    $0x1,%esi
call   1050 <dup2@plt>
mov    0x10(%rsp),%edi
call   1080 <close@plt>
mov    0x14(%rsp),%edi
call   1080 <close@plt>
lea    0xdb0(%rip),%rdi
lea    0xdb5(%rip),%rdx
mov    %rdi,%rsi
xor    %ecx,%ecx
call   10c0 <execlp@plt>
mov    0xc(%rsp),%edi
lea    0x20(%rsp),%rbx
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <write@plt>
mov    0x8(%rsp),%edi
call   1080 <close@plt>
mov    0xc(%rsp),%edi
call   1080 <close@plt>
mov    0x14(%rsp),%edi
call   1080 <close@plt>
mov    0x10(%rsp),%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   10a0 <read@plt>
cltq
movb   $0x0,0x20(%rsp,%rax,1)
lea    0xd66(%rip),%rdi
mov    %rbx,%rsi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x428,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%d%d\00"
@.str.1 = [9 x i8] c"%d + %d\0A\00"
@.str.2 = [12 x i8] c"/usr/bin/bc\00"
@.str.3 = [8 x i8] c"--quiet\00"
@.str.4 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [1024 x i8]
%7 = alloca [2 x i32]
%8 = alloca [2 x i32]
store i32 0, i32* %1
%9 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = call i32 @snprintf(i8* %10, i32 1024, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %12)
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
store i32 %15, i32* %4
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%17 = call i32 @pipe(i32* %16)
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%19 = call i32 @pipe(i32* %18)
%20 = call i32 (...) @fork()
store i32 %20, i32* %5
%21 = icmp ne i32 %20, 0
br i1 %21, label %42, label %22
22: ; preds = %0
%23 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%24 = load i32, i32* %23
%25 = call i32 @dup2(i32 %24, i32 0)
%26 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%27 = load i32, i32* %26
%28 = call i32 @close(i32 %27)
%29 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%30 = load i32, i32* %29
%31 = call i32 @close(i32 %30)
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%33 = load i32, i32* %32
%34 = call i32 @dup2(i32 %33, i32 1)
%35 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%36 = load i32, i32* %35
%37 = call i32 @close(i32 %36)
%38 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%39 = load i32, i32* %38
%40 = call i32 @close(i32 %39)
%41 = call i32 @execlp(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32* null)
br label %42
42: ; preds = %22, %0
%43 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%44 = load i32, i32* %43
%45 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%46 = load i32, i32* %4
%47 = call i32 @write(i32 %44, i8* %45, i32 %46)
%48 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%49 = load i32, i32* %48
%50 = call i32 @close(i32 %49)
%51 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%52 = load i32, i32* %51
%53 = call i32 @close(i32 %52)
%54 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%55 = load i32, i32* %54
%56 = call i32 @close(i32 %55)
%57 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%58 = load i32, i32* %57
%59 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%60 = call i32 @read(i32 %58, i8* %59, i32 1024)
store i32 %60, i32* %4
%61 = load i32, i32* %4
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 %62
store i8 0, i8* %63
%64 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%65 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %64)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%d%d\00"
@.str.1 = [9 x i8] c"%d + %d\0A\00"
@.str.2 = [12 x i8] c"/usr/bin/bc\00"
@.str.3 = [8 x i8] c"--quiet\00"
@.str.4 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [1024 x i8]
%4 = alloca [2 x i32]
%5 = alloca [2 x i32]
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%9 = bitcast [2 x i32]* %4 to i8*
%10 = bitcast [2 x i32]* %5 to i8*
%11 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%12 = load i32, i32* %1
%13 = load i32, i32* %2
%14 = call i32 @snprintf(i8* %8, i32 1024, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %13)
%15 = call i32 @strlen(i8* %8)
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%17 = call i32 @pipe(i32* %16)
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%19 = call i32 @pipe(i32* %18)
%20 = call i32 (...) @fork()
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %38
22: ; preds = %0
%23 = load i32, i32* %16
%24 = call i32 @dup2(i32 %23, i32 0)
%25 = load i32, i32* %16
%26 = call i32 @close(i32 %25)
%27 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%28 = load i32, i32* %27
%29 = call i32 @close(i32 %28)
%30 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%31 = load i32, i32* %30
%32 = call i32 @dup2(i32 %31, i32 1)
%33 = load i32, i32* %18
%34 = call i32 @close(i32 %33)
%35 = load i32, i32* %30
%36 = call i32 @close(i32 %35)
%37 = call i32 @execlp(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32* null)
br label %38
38: ; preds = %22, %0
%39 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%40 = load i32, i32* %39
%41 = call i32 @write(i32 %40, i8* %8, i32 %15)
%42 = load i32, i32* %16
%43 = call i32 @close(i32 %42)
%44 = load i32, i32* %39
%45 = call i32 @close(i32 %44)
%46 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%47 = load i32, i32* %46
%48 = call i32 @close(i32 %47)
%49 = load i32, i32* %18
%50 = call i32 @read(i32 %49, i8* %8, i32 1024)
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %51
store i8 0, i8* %52
%53 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %8)
ret i32 0
}