#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 fork();
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ write(int, char *, int);
int main(void) {
  char first, last, ch;
  int pid, i;
  if ((pid = fork()) > 0) {
    first = 'A';
    last = 'Z';
  } else if (pid == 0) {
    first = 'a';
    last = 'z';
    sleep(1);
  }
  for (ch = first; ch <= last; ch++)
    write(1, &ch, 1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <fork@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jle    115f <main+0x2f>
movb   $0x41,-0x5(%rbp)
movb   $0x5a,-0x6(%rbp)
jmp    1180 <main+0x50>
cmpl   $0x0,-0xc(%rbp)
jne    117b <main+0x4b>
movb   $0x61,-0x5(%rbp)
movb   $0x7a,-0x6(%rbp)
mov    $0x1,%edi
call   1040 <sleep@plt>
jmp    1180 <main+0x50>
mov    -0x5(%rbp),%al
mov    %al,-0x7(%rbp)
movsbl -0x7(%rbp),%eax
movsbl -0x6(%rbp),%ecx
cmp    %ecx,%eax
jg     11b3 <main+0x83>
mov    $0x1,%edx
lea    -0x7(%rbp),%rsi
mov    %edx,%edi
call   1030 <write@plt>
mov    -0x7(%rbp),%al
add    $0x1,%al
mov    %al,-0x7(%rbp)
jmp    1186 <main+0x56>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <fork@plt>
test   %eax,%eax
jle    1153 <main+0x23>
movb   $0x41,0xf(%rsp)
mov    $0x5a,%ebp
mov    $0x41,%bl
jmp    116b <main+0x3b>
jne    116b <main+0x3b>
mov    $0x1,%edi
call   1040 <sleep@plt>
movb   $0x61,0xf(%rsp)
mov    $0x7a,%ebp
mov    $0x61,%bl
add    $0x1,%bl
lea    0xf(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x1,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %bl,0xf(%rsp)
movsbl %bl,%eax
lea    0x1(%rax),%ebx
cmp    %eax,%ebp
jge    1180 <main+0x50>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (...) @fork()
store i32 %7, i32* %5
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %0
store i8 65, i8* %2
store i8 90, i8* %3
br label %16
10: ; preds = %0
%11 = load i32, i32* %5
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
store i8 97, i8* %2
store i8 122, i8* %3
%14 = call i32 @sleep(i32 1)
br label %15
15: ; preds = %13, %10
br label %16
16: ; preds = %15, %9
%17 = load i8, i8* %2
store i8 %17, i8* %4
br label %18
18: ; preds = %26, %16
%19 = load i8, i8* %4
%20 = sext i8 %19 to i32
%21 = load i8, i8* %3
%22 = sext i8 %21 to i32
%23 = icmp sle i32 %20, %22
br i1 %23, label %24, label %29
24: ; preds = %18
%25 = call i32 @write(i32 1, i8* %4, i32 1)
br label %26
26: ; preds = %24
%27 = load i8, i8* %4
%28 = add i8 %27, 1
store i8 %28, i8* %4
br label %18
29: ; preds = %18
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca i8
%2 = tail call i32 (...) @fork()
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %5
4: ; preds = %0
store i8 65, i8* %1
br label %9
5: ; preds = %0
%6 = icmp eq i32 %2, 0
br i1 %6, label %7, label %9
7: ; preds = %5
%8 = tail call i32 @sleep(i32 1)
store i8 97, i8* %1
br label %9
9: ; preds = %5, %4, %7
%10 = phi i8 [ 97, %7 ], [ 65, %4 ], [ undef, %5 ]
%11 = phi i32 [ 122, %7 ], [ 90, %4 ], [ 0, %5 ]
br label %12
12: ; preds = %9, %12
%13 = phi i8 [ %15, %12 ], [ %10, %9 ]
%14 = call i32 @write(i32 1, i8* %1, i32 1)
%15 = add i8 %13, 1
store i8 %15, i8* %1
%16 = sext i8 %15 to i32
%17 = icmp slt i32 %11, %16
br i1 %17, label %18, label %12
18: ; preds = %12
ret i32 0
}