#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 scalar_t__ pid_t;

/* Variables and functions */
scalar_t__ fork();
int /*<<< orphan*/ printf(char *, char);
int main() {
  pid_t pid;
  int i;
  pid = fork();
  if (pid == 0) {
    for (i = 1; i < 5; i++) {
      printf("%d", i);
    }
    return 0;
  }
  for (i = 1; i < 5; i++) {
    printf("%c\n", 'a');
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <fork@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1182 <main+0x62>
movl   $0x1,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    1176 <main+0x56>
mov    -0x14(%rbp),%eax
lea    0xea0(%rip),%rdi
movsbl %al,%esi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114c <main+0x2c>
movl   $0x0,-0x4(%rbp)
jmp    11b9 <main+0x99>
movl   $0x1,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    11b2 <main+0x92>
lea    0xe69(%rip),%rdi
mov    $0x61,%esi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1189 <main+0x69>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1040 <fork@plt>
test   %rax,%rax
je     1165 <main+0x45>
lea    0xecf(%rip),%rbx
mov    %rbx,%rdi
mov    $0x61,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x61,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x61,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x61,%esi
jmp    119b <main+0x7b>
lea    0xe94(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32
store i32 0, i32* %1
%4 = call i64 (...) @fork()
store i64 %4, i64* %2
%5 = load i64, i64* %2
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %19
7: ; preds = %0
store i32 1, i32* %3
br label %8
8: ; preds = %15, %7
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 5
br i1 %10, label %11, label %18
11: ; preds = %8
%12 = load i32, i32* %3
%13 = trunc i32 %12 to i8
%14 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %13)
br label %15
15: ; preds = %11
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %8
18: ; preds = %8
store i32 0, i32* %1
br label %29
19: ; preds = %0
store i32 1, i32* %3
br label %20
20: ; preds = %25, %19
%21 = load i32, i32* %3
%22 = icmp slt i32 %21, 5
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8 signext 97)
br label %25
25: ; preds = %23
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %20
28: ; preds = %20
store i32 0, i32* %1
br label %29
29: ; preds = %28, %18
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%c\0A\00"
define i32 @main() {
%1 = tail call i64 (...) @fork()
%2 = icmp eq i64 %1, 0
br i1 %2, label %8, label %3
3: ; preds = %0
%4 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8 signext 97)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8 signext 97)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8 signext 97)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8 signext 97)
br label %13
8: ; preds = %0
%9 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 1)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 2)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 3)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext 4)
br label %13
13: ; preds = %3, %8
ret i32 0
}