#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 /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int /*<<< orphan*/ stdout;
void *count_to_ten(void *x) {
  int ii, jj;
  char buffer[100];
  char tabs[20] = {'\0'};
  int skip = *((int *)x);
  for (jj = 0; jj < skip; jj++) {
    sprintf(tabs, "%s\t", tabs);
  }
  for (ii = 0; ii < 10; ii++) {
    sprintf(buffer, "%s%d\n", tabs, ii);
    printf("%s", buffer);
    fflush(stdout);
    sleep(1);
  }
  return NULL;
}


x86 assembly (clang, -O0):
<count_to_ten>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xa4(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xa4(%rbp),%eax
jge    11be <count_to_ten+0x6e>
lea    -0xa0(%rbp),%rdi
lea    -0xa0(%rbp),%rdx
lea    0xe57(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1185 <count_to_ten+0x35>
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    1221 <count_to_ten+0xd1>
lea    -0x80(%rbp),%rdi
lea    -0xa0(%rbp),%rdx
mov    -0xc(%rbp),%ecx
lea    0xe20(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x80(%rbp),%rsi
lea    0xe14(%rip),%rdi
call   1030 <printf@plt>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c5 <count_to_ten+0x75>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_to_ten>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
mov    (%rdi),%ebp
test   %ebp,%ebp
jle    1185 <count_to_ten+0x45>
lea    0xe93(%rip),%r14
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <sprintf@plt>
add    $0xffffffff,%ebp
jne    1170 <count_to_ten+0x30>
lea    0xe78(%rip),%r14
lea    0x20(%rsp),%rbx
mov    %rsp,%r15
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %ecx,%ecx
xor    %eax,%eax
call   1050 <sprintf@plt>
lea    0xe5d(%rip),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    0x2e21(%rip),%r13
mov    0x0(%r13),%edi
call   1040 <fflush@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    $0x1,%ecx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    0x0(%r13),%edi
call   1040 <fflush@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    $0x2,%ecx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    0x0(%r13),%edi
call   1040 <fflush@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    $0x3,%ecx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    0x0(%r13),%edi
call   1040 <fflush@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    $0x4,%ecx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    0x0(%r13),%edi
call   1040 <fflush@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    $0x5,%ecx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    0x0(%r13),%edi
call   1040 <fflush@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    $0x6,%ecx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    0x0(%r13),%edi
call   1040 <fflush@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    $0x7,%ecx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    0x0(%r13),%edi
call   1040 <fflush@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    $0x8,%ecx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    0x0(%r13),%edi
call   1040 <fflush@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    $0x9,%ecx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    0x0(%r13),%edi
call   1040 <fflush@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\09\00"
@.str.1 = [6 x i8] c"%s%d\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@stdout = global i32 0
define i8* @count_to_ten(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [100 x i8]
%6 = alloca [20 x i8]
%7 = alloca i32
store i8* %0, i8** %2
%8 = bitcast [20 x i8]* %6 to i8*
%9 = load i8*, i8** %2
%10 = bitcast i8* %9 to i32*
%11 = load i32, i32* %10
store i32 %11, i32* %7
store i32 0, i32* %4
br label %12
12: ; preds = %20, %1
%13 = load i32, i32* %4
%14 = load i32, i32* %7
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %23
16: ; preds = %12
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%19 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %16
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %12
23: ; preds = %12
store i32 0, i32* %3
br label %24
24: ; preds = %37, %23
%25 = load i32, i32* %3
%26 = icmp slt i32 %25, 10
br i1 %26, label %27, label %40
27: ; preds = %24
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%30 = load i32, i32* %3
%31 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %29, i32 %30)
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%33 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %32)
%34 = load i32, i32* @stdout
%35 = call i32 @fflush(i32 %34)
%36 = call i32 @sleep(i32 1)
br label %37
37: ; preds = %27
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
br label %24
40: ; preds = %24
ret i8* null
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\09\00"
@.str.1 = [6 x i8] c"%s%d\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@stdout = global i32 0
define noalias i8* @count_to_ten(i8* nocapture %0) {
%2 = alloca [100 x i8]
%3 = alloca [20 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%6 = bitcast i8* %0 to i32*
%7 = load i32, i32* %6
%8 = icmp sgt i32 %7, 0
br i1 %8, label %60, label %9
9: ; preds = %60, %1
%10 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32 0)
%11 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%12 = load i32, i32* @stdout
%13 = call i32 @fflush(i32 %12)
%14 = call i32 @sleep(i32 1)
%15 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32 1)
%16 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%17 = load i32, i32* @stdout
%18 = call i32 @fflush(i32 %17)
%19 = call i32 @sleep(i32 1)
%20 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32 2)
%21 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%22 = load i32, i32* @stdout
%23 = call i32 @fflush(i32 %22)
%24 = call i32 @sleep(i32 1)
%25 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32 3)
%26 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%27 = load i32, i32* @stdout
%28 = call i32 @fflush(i32 %27)
%29 = call i32 @sleep(i32 1)
%30 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32 4)
%31 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%32 = load i32, i32* @stdout
%33 = call i32 @fflush(i32 %32)
%34 = call i32 @sleep(i32 1)
%35 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32 5)
%36 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%37 = load i32, i32* @stdout
%38 = call i32 @fflush(i32 %37)
%39 = call i32 @sleep(i32 1)
%40 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32 6)
%41 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%42 = load i32, i32* @stdout
%43 = call i32 @fflush(i32 %42)
%44 = call i32 @sleep(i32 1)
%45 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32 7)
%46 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%47 = load i32, i32* @stdout
%48 = call i32 @fflush(i32 %47)
%49 = call i32 @sleep(i32 1)
%50 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32 8)
%51 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%52 = load i32, i32* @stdout
%53 = call i32 @fflush(i32 %52)
%54 = call i32 @sleep(i32 1)
%55 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32 9)
%56 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%57 = load i32, i32* @stdout
%58 = call i32 @fflush(i32 %57)
%59 = call i32 @sleep(i32 1)
ret i8* null
60: ; preds = %1, %60
%61 = phi i32 [ %63, %60 ], [ 0, %1 ]
%62 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %5)
%63 = add nuw nsw i32 %61, 1
%64 = icmp eq i32 %63, %7
br i1 %64, label %9, label %60
}