#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 */
scalar_t__ fork();
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ waitpid(int, int /*<<< orphan*/);
int main(int argc, char **argv) {
  if (fork() == 0) {
    for (int i = 0; i < 52; i++)
      putchar('A');
  } else {
    for (int i = 0; i < 50; i++)
      putchar('B');
    waitpid(-1, 0);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <fork@plt>
cmp    $0x0,%rax
jne    1185 <main+0x55>
movl   $0x0,-0x14(%rbp)
cmpl   $0x34,-0x14(%rbp)
jge    1180 <main+0x50>
mov    $0x41,%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115e <main+0x2e>
jmp    11ba <main+0x8a>
movl   $0x0,-0x18(%rbp)
cmpl   $0x32,-0x18(%rbp)
jge    11ae <main+0x7e>
mov    $0x42,%edi
call   1030 <putchar@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118c <main+0x5c>
mov    $0xffffffff,%edi
xor    %esi,%esi
call   1040 <waitpid@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1050 <fork@plt>
test   %rax,%rax
je     116d <main+0x3d>
mov    $0x32,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x42,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1150 <main+0x20>
mov    $0xffffffff,%edi
xor    %esi,%esi
call   1040 <waitpid@plt>
jmp    118f <main+0x5f>
mov    $0x34,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x41,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1180 <main+0x50>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i64 (...) @fork()
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %20
10: ; preds = %2
store i32 0, i32* %6
br label %11
11: ; preds = %16, %10
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 52
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = call i32 @putchar(i8 signext 65)
br label %16
16: ; preds = %14
%17 = load i32, i32* %6
%18 = add nsw i32 %17, 1
store i32 %18, i32* %6
br label %11
19: ; preds = %11
br label %31
20: ; preds = %2
store i32 0, i32* %7
br label %21
21: ; preds = %26, %20
%22 = load i32, i32* %7
%23 = icmp slt i32 %22, 50
br i1 %23, label %24, label %29
24: ; preds = %21
%25 = call i32 @putchar(i8 signext 66)
br label %26
26: ; preds = %24
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %21
29: ; preds = %21
%30 = call i32 @waitpid(i32 -1, i32 0)
br label %31
31: ; preds = %29, %19
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 (...) @fork()
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %12
5: ; preds = %2, %5
%6 = phi i32 [ %8, %5 ], [ 0, %2 ]
%7 = tail call i32 @putchar(i8 signext 65)
%8 = add nuw nsw i32 %6, 1
%9 = icmp eq i32 %8, 52
br i1 %9, label %17, label %5
10: ; preds = %12
%11 = tail call i32 @waitpid(i32 -1, i32 0)
br label %17
12: ; preds = %2, %12
%13 = phi i32 [ %15, %12 ], [ 0, %2 ]
%14 = tail call i32 @putchar(i8 signext 66)
%15 = add nuw nsw i32 %13, 1
%16 = icmp eq i32 %15, 50
br i1 %16, label %10, label %12
17: ; preds = %5, %10
ret i32 0
}