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

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ waitpid(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main() {
  if (fork() == 0) {
    printf("a");
    fflush(stdout);
  } else {
    printf("b");
    fflush(stdout);
    waitpid(-1, NULL, 0);
  }
  printf("c");
  fflush(stdout);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1070 <fork@plt>
cmp    $0x0,%rax
jne    118f <main+0x3f>
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
jmp    11b9 <main+0x69>
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    $0xffffffff,%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <waitpid@plt>
lea    0xe44(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
jne    1177 <main+0x27>
mov    $0x61,%edi
call   1030 <putchar@plt>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
jmp    119d <main+0x4d>
mov    $0x62,%edi
call   1030 <putchar@plt>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    $0xffffffff,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <waitpid@plt>
mov    $0x63,%edi
call   1030 <putchar@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"a\00"
@stdout = global i32 0
@.str.1 = [2 x i8] c"b\00"
@.str.2 = [2 x i8] c"c\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i64 (...) @fork()
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %8
4: ; preds = %0
%5 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @stdout
%7 = call i32 @fflush(i32 %6)
br label %13
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @stdout
%11 = call i32 @fflush(i32 %10)
%12 = call i32 @waitpid(i32 -1, i32* null, i32 0)
br label %13
13: ; preds = %8, %4
%14 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* @stdout
%16 = call i32 @fflush(i32 %15)
%17 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stdout = global i32 0
define i32 @main() {
%1 = tail call i64 (...) @fork()
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %7
3: ; preds = %0
%4 = tail call i32 @putchar(i32 97)
%5 = load i32, i32* @stdout
%6 = tail call i32 @fflush(i32 %5)
br label %12
7: ; preds = %0
%8 = tail call i32 @putchar(i32 98)
%9 = load i32, i32* @stdout
%10 = tail call i32 @fflush(i32 %9)
%11 = tail call i32 @waitpid(i32 -1, i32* null, i32 0)
br label %12
12: ; preds = %7, %3
%13 = tail call i32 @putchar(i32 99)
%14 = load i32, i32* @stdout
%15 = tail call i32 @fflush(i32 %14)
%16 = tail call i32 @exit(i32 0)
unreachable
}