#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*/ fflush(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int /*<<< orphan*/ usleep(int);
int main(int argc, char *argv[]) {
  char *buff;
  int i, c, l, p;
  if (argc < 2)
    return (0);
  p = fork();
  switch (p) {
  case -1:
    perror("fork(): ");
    return (1);
  case 0:
    break;
  default:
    fprintf(stderr, "running as %i\n", p);
    return (0);
  };
  c = 0;
  while (c < 1000) {
    l = strlen(argv[1]);
    buff = (char *)malloc(l + 10);
    strncpy(buff, argv[1], l);
    for (i = l; i < (l + 10); i++)
      buff[i] = ' ';
    l += 10;
    for (c = 0; c < l + 1; c++) {
      for (i = 0; i < l; i++) {
        if (i == c) {
          fprintf(stdout, "\a");
          fflush(stdout);
          fprintf(stdout, "]2;");
        };
        fprintf(stdout, "%c", buff[i]);
      };
      usleep(80000);
    };
  };
  printf("\a");
  fflush(stdout);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11bc <main+0x2c>
movl   $0x0,-0x4(%rbp)
jmp    1390 <main+0x200>
xor    %eax,%eax
call   10a0 <fork@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0xffffffff,%eax
je     11ea <main+0x5a>
jmp    11da <main+0x4a>
mov    -0x2c(%rbp),%eax
test   %eax,%eax
je     1202 <main+0x72>
jmp    1207 <main+0x77>
lea    0xe0f(%rip),%rdi
call   1090 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1390 <main+0x200>
jmp    122d <main+0x9d>
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%edx
lea    0xdef(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1390 <main+0x200>
movl   $0x0,-0x20(%rbp)
cmpl   $0x3e8,-0x20(%rbp)
jge    136f <main+0x1df>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
add    $0xa,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x24(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x24(%rbp),%ecx
add    $0xa,%ecx
cmp    %ecx,%eax
jge    12a5 <main+0x115>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    127a <main+0xea>
mov    -0x24(%rbp),%eax
add    $0xa,%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    136a <main+0x1da>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1352 <main+0x1c2>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    1321 <main+0x191>
mov    0x2cec(%rip),%rax
mov    (%rax),%edi
lea    0xd23(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2cd5(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
mov    0x2cc7(%rip),%rax
mov    (%rax),%edi
lea    0xd00(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2cb0(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
lea    0xce2(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12cd <main+0x13d>
mov    $0x13880,%edi
call   10b0 <usleep@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12b5 <main+0x125>
jmp    1234 <main+0xa4>
lea    0xca2(%rip),%rdi
call   1050 <printf@plt>
mov    0x2c56(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %ebx,%ebx
cmp    $0x2,%edi
jl     1335 <main+0x195>
mov    %rsi,%r15
xor    %eax,%eax
call   10b0 <fork@plt>
test   %eax,%eax
je     11f0 <main+0x50>
cmp    $0xffffffff,%eax
je     1346 <main+0x1a6>
mov    0x2e09(%rip),%rcx
mov    (%rcx),%edi
lea    0xe29(%rip),%rsi
xor    %ebx,%ebx
mov    %eax,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1335 <main+0x195>
mov    0x2de1(%rip),%r13
lea    0xe21(%rip),%rbx
mov    %r15,(%rsp)
jmp    121f <main+0x7f>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rsp),%r15
cmp    $0x3e7,%eax
ja     1320 <main+0x180>
mov    0x8(%r15),%rdi
call   1050 <strlen@plt>
mov    %eax,%r12d
lea    0xa(%r12),%ebp
mov    %ebp,%edi
call   1080 <malloc@plt>
mov    %rax,%r14
mov    0x8(%r15),%rsi
mov    %rax,%rdi
mov    %r12d,%edx
call   1040 <strncpy@plt>
movslq %r12d,%r15
lea    0x1(%r15),%eax
cmp    %eax,%ebp
cmovg  %ebp,%eax
lea    (%r14,%r15,1),%rdi
mov    %r15d,%edx
not    %edx
add    %eax,%edx
add    $0x1,%rdx
mov    $0x20,%esi
call   1060 <memset@plt>
mov    $0x0,%eax
cmp    $0xfffffff6,%r15d
mov    (%rsp),%r15
jl     1214 <main+0x74>
cmp    $0x2,%ebp
mov    $0x1,%eax
cmovl  %eax,%ebp
lea    0xb(%r12),%eax
xor    %r15d,%r15d
mov    %r12,0x10(%rsp)
mov    %rax,0x8(%rsp)
jmp    12c1 <main+0x121>
nopl   0x0(%rax)
mov    $0x13880,%edi
call   10c0 <usleep@plt>
add    $0x1,%r15
mov    0x8(%rsp),%rax
cmp    %rax,%r15
mov    0x10(%rsp),%r12
je     1210 <main+0x70>
cmp    $0xfffffff6,%r12d
je     12a0 <main+0x100>
xor    %r12d,%r12d
jmp    12ec <main+0x14c>
nopl   0x0(%rax)
mov    0x0(%r13),%edi
movsbl (%r14,%r12,1),%edx
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
add    $0x1,%r12
cmp    %r12,%rbp
je     12a0 <main+0x100>
cmp    %r12,%r15
jne    12d0 <main+0x130>
mov    0x0(%r13),%edi
lea    0xd1c(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x0(%r13),%edi
call   1090 <fflush@plt>
mov    0x0(%r13),%edi
lea    0xd03(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    12d0 <main+0x130>
mov    $0x7,%edi
call   1030 <putchar@plt>
mov    0x0(%r13),%edi
call   1090 <fflush@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcb3(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%ebx
jmp    1335 <main+0x195>

LLVM IR (-O0):
@.str = [9 x i8] c"fork(): \00"
@stderr = global i32 0
@.str.1 = [15 x i8] c"running as %i\0A\00"
@stdout = global i32 0
@.str.2 = [2 x i8] c"\07\00"
@.str.3 = [5 x i8] c"\1B]2;\00"
@.str.4 = [3 x i8] c"%c\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 0, i32* %3
br label %103
14: ; preds = %2
%15 = call i32 (...) @fork()
store i32 %15, i32* %10
%16 = load i32, i32* %10
switch i32 %16, label %20 [
i32 -1, label %17
i32 0, label %19
]
17: ; preds = %14
%18 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %103
19: ; preds = %14
br label %24
20: ; preds = %14
%21 = load i32, i32* @stderr
%22 = load i32, i32* %10
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %22)
store i32 0, i32* %3
br label %103
24: ; preds = %19
store i32 0, i32* %8
br label %25
25: ; preds = %98, %24
%26 = load i32, i32* %8
%27 = icmp slt i32 %26, 1000
br i1 %27, label %28, label %99
28: ; preds = %25
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 @strlen(i8* %31)
store i32 %32, i32* %9
%33 = load i32, i32* %9
%34 = add nsw i32 %33, 10
%35 = call i64 @malloc(i32 %34)
%36 = inttoptr i64 %35 to i8*
store i8* %36, i8** %6
%37 = load i8*, i8** %6
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = load i32, i32* %9
%42 = call i32 @strncpy(i8* %37, i8* %40, i32 %41)
%43 = load i32, i32* %9
store i32 %43, i32* %7
br label %44
44: ; preds = %54, %28
%45 = load i32, i32* %7
%46 = load i32, i32* %9
%47 = add nsw i32 %46, 10
%48 = icmp slt i32 %45, %47
br i1 %48, label %49, label %57
49: ; preds = %44
%50 = load i8*, i8** %6
%51 = load i32, i32* %7
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
store i8 32, i8* %53
br label %54
54: ; preds = %49
%55 = load i32, i32* %7
%56 = add nsw i32 %55, 1
store i32 %56, i32* %7
br label %44
57: ; preds = %44
%58 = load i32, i32* %9
%59 = add nsw i32 %58, 10
store i32 %59, i32* %9
store i32 0, i32* %8
br label %60
60: ; preds = %95, %57
%61 = load i32, i32* %8
%62 = load i32, i32* %9
%63 = add nsw i32 %62, 1
%64 = icmp slt i32 %61, %63
br i1 %64, label %65, label %98
65: ; preds = %60
store i32 0, i32* %7
br label %66
66: ; preds = %90, %65
%67 = load i32, i32* %7
%68 = load i32, i32* %9
%69 = icmp slt i32 %67, %68
br i1 %69, label %70, label %93
70: ; preds = %66
%71 = load i32, i32* %7
%72 = load i32, i32* %8
%73 = icmp eq i32 %71, %72
br i1 %73, label %74, label %81
74: ; preds = %70
%75 = load i32, i32* @stdout
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%77 = load i32, i32* @stdout
%78 = call i32 @fflush(i32 %77)
%79 = load i32, i32* @stdout
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %81
81: ; preds = %74, %70
%82 = load i32, i32* @stdout
%83 = load i8*, i8** %6
%84 = load i32, i32* %7
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8, i8* %83, i64 %85
%87 = load i8, i8* %86
%88 = sext i8 %87 to i32
%89 = call i32 (i32, i8*, ...) @fprintf(i32 %82, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %88)
br label %90
90: ; preds = %81
%91 = load i32, i32* %7
%92 = add nsw i32 %91, 1
store i32 %92, i32* %7
br label %66
93: ; preds = %66
%94 = call i32 @usleep(i32 80000)
br label %95
95: ; preds = %93
%96 = load i32, i32* %8
%97 = add nsw i32 %96, 1
store i32 %97, i32* %8
br label %60
98: ; preds = %60
br label %25
99: ; preds = %25
%100 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%101 = load i32, i32* @stdout
%102 = call i32 @fflush(i32 %101)
store i32 0, i32* %3
br label %103
103: ; preds = %99, %20, %17, %13
%104 = load i32, i32* %3
ret i32 %104
}

LLVM IR (-O2):
@.str = [9 x i8] c"fork(): \00"
@stderr = global i32 0
@.str.1 = [15 x i8] c"running as %i\0A\00"
@stdout = global i32 0
@.str.2 = [2 x i8] c"\07\00"
@.str.3 = [5 x i8] c"\1B]2;\00"
@.str.4 = [3 x i8] c"%c\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %69, label %4
4: ; preds = %2
%5 = tail call i32 (...) @fork()
switch i32 %5, label %10 [
i32 -1, label %8
i32 0, label %6
]
6: ; preds = %4
%7 = getelementptr inbounds i8*, i8** %1, i64 1
br label %18
8: ; preds = %4
%9 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %69
10: ; preds = %4
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %5)
br label %69
13: ; preds = %61
%14 = add i32 %20, 11
br label %15
15: ; preds = %13, %18
%16 = phi i32 [ 0, %18 ], [ %14, %13 ]
%17 = icmp ult i32 %16, 1000
br i1 %17, label %18, label %65
18: ; preds = %6, %15
%19 = load i8*, i8** %7
%20 = tail call i32 @strlen(i8* %19)
%21 = add nsw i32 %20, 10
%22 = tail call i64 @malloc(i32 %21)
%23 = inttoptr i64 %22 to i8*
%24 = load i8*, i8** %7
%25 = tail call i32 @strncpy(i8* %23, i8* %24, i32 %20)
%26 = sext i32 %20 to i64
%27 = getelementptr i8, i8* %23, i64 %26
%28 = add i32 %20, 1
%29 = call i32 @llvm.smax.i32(i32 %21, i32 %28)
%30 = xor i32 %20, -1
%31 = add i32 %29, %30
%32 = zext i32 %31 to i64
%33 = add nuw nsw i64 %32, 1
%34 = icmp sgt i32 %20, -11
br i1 %34, label %35, label %15
35: ; preds = %18
%36 = icmp eq i32 %20, -10
%37 = call i32 @llvm.smax.i32(i32 %21, i32 1)
%38 = add i32 %20, 11
%39 = zext i32 %38 to i64
%40 = zext i32 %37 to i64
br label %41
41: ; preds = %35, %61
%42 = phi i64 [ 0, %35 ], [ %63, %61 ]
br i1 %36, label %61, label %43
43: ; preds = %41, %53
%44 = phi i64 [ %59, %53 ], [ 0, %41 ]
%45 = icmp eq i64 %44, %42
br i1 %45, label %46, label %53
46: ; preds = %43
%47 = load i32, i32* @stdout
%48 = tail call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%49 = load i32, i32* @stdout
%50 = tail call i32 @fflush(i32 %49)
%51 = load i32, i32* @stdout
%52 = tail call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %53
53: ; preds = %46, %43
%54 = load i32, i32* @stdout
%55 = getelementptr inbounds i8, i8* %23, i64 %44
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = tail call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %57)
%59 = add nuw nsw i64 %44, 1
%60 = icmp eq i64 %59, %40
br i1 %60, label %61, label %43
61: ; preds = %53, %41
%62 = tail call i32 @usleep(i32 80000)
%63 = add nuw nsw i64 %42, 1
%64 = icmp eq i64 %63, %39
br i1 %64, label %13, label %41
65: ; preds = %15
%66 = tail call i32 @putchar(i32 7)
%67 = load i32, i32* @stdout
%68 = tail call i32 @fflush(i32 %67)
br label %69
69: ; preds = %2, %65, %10, %8
%70 = phi i32 [ 0, %10 ], [ 0, %65 ], [ 1, %8 ], [ 0, %2 ]
ret i32 %70
}