#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*/ 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:
    printf("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    1389 <main+0x1f9>
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    1389 <main+0x1f9>
jmp    1224 <main+0x94>
mov    -0x28(%rbp),%esi
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1389 <main+0x1f9>
movl   $0x0,-0x20(%rbp)
cmpl   $0x3e8,-0x20(%rbp)
jge    1366 <main+0x1d6>
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    129c <main+0x10c>
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    1271 <main+0xe1>
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    1361 <main+0x1d1>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1349 <main+0x1b9>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    1318 <main+0x188>
mov    0x2cfd(%rip),%rax
mov    (%rax),%edi
lea    0xd2c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2ce6(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
mov    0x2cd8(%rip),%rax
mov    (%rax),%edi
lea    0xd09(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2cc1(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
lea    0xceb(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12c4 <main+0x134>
mov    $0x13880,%edi
call   10b0 <usleep@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12ac <main+0x11c>
jmp    122b <main+0x9b>
lea    0xcab(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2c65(%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+0x185>
mov    %rsi,%r15
xor    %eax,%eax
call   10c0 <fork@plt>
test   %eax,%eax
je     11f7 <main+0x47>
cmp    $0xffffffff,%eax
je     1346 <main+0x196>
lea    0xe22(%rip),%rdi
xor    %ebx,%ebx
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1335 <main+0x185>
mov    0x2de2(%rip),%r13
lea    0xe1a(%rip),%rbx
mov    %r15,(%rsp)
jmp    121f <main+0x6f>
nopl   0x0(%rax,%rax,1)
mov    (%rsp),%r15
cmp    $0x3e7,%eax
ja     1320 <main+0x170>
mov    0x8(%r15),%rdi
call   1050 <strlen@plt>
mov    %eax,%r12d
lea    0xa(%r12),%ebp
mov    %ebp,%edi
call   1090 <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   1070 <memset@plt>
mov    $0x0,%eax
cmp    $0xfffffff6,%r15d
mov    (%rsp),%r15
jl     1214 <main+0x64>
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+0x111>
nopl   0x0(%rax)
mov    $0x13880,%edi
call   10d0 <usleep@plt>
add    $0x1,%r15
mov    0x8(%rsp),%rax
cmp    %rax,%r15
mov    0x10(%rsp),%r12
je     1210 <main+0x60>
cmp    $0xfffffff6,%r12d
je     12a0 <main+0xf0>
xor    %r12d,%r12d
jmp    12ec <main+0x13c>
nopl   0x0(%rax)
mov    0x0(%r13),%edi
movsbl (%r14,%r12,1),%edx
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
add    $0x1,%r12
cmp    %r12,%rbp
je     12a0 <main+0xf0>
cmp    %r12,%r15
jne    12d0 <main+0x120>
mov    0x0(%r13),%edi
lea    0xd1c(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x0(%r13),%edi
call   10a0 <fflush@plt>
mov    0x0(%r13),%edi
lea    0xd03(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    12d0 <main+0x120>
mov    $0x7,%edi
call   1030 <putchar@plt>
mov    0x0(%r13),%edi
call   10a0 <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   10b0 <perror@plt>
mov    $0x1,%ebx
jmp    1335 <main+0x185>

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

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