void task_first() {
  int j = 0;
  while (1) {
    kprint(" ");
    kprint("T:");
    char arr[10];
    int length = int_to_str(&arr, 10, j);
    for (int i = 0; i < length; ++i) {
      kprint_char(arr[i]);
    }
    kprint(" ");
    for (int i = 0; i < 1000000; ++i) {
      __asm__("NOP");
    }
    ++j;
  }
}


x86 assembly (clang, -O0):
<task_first>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1050 <kprint@plt>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1050 <kprint@plt>
mov    -0x4(%rbp),%edx
lea    -0xe(%rbp),%rdi
mov    $0xa,%esi
mov    $0x0,%al
call   1040 <int_to_str@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11a2 <task_first+0x72>
movslq -0x18(%rbp),%rax
movsbl -0xe(%rbp,%rax,1),%edi
mov    $0x0,%al
call   1030 <kprint_char@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1178 <task_first+0x48>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1050 <kprint@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0xf4240,-0x1c(%rbp)
jge    11d3 <task_first+0xa3>
nop
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b7 <task_first+0x87>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    113f <task_first+0xf>

x86 assembly (clang, -O2):
<task_first>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebb(%rip),%r12
lea    0xeb6(%rip),%r14
lea    0xe(%rsp),%r15
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <kprint@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <kprint@plt>
mov    %r15,%rdi
mov    $0xa,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1040 <int_to_str@plt>
test   %eax,%eax
jle    11a5 <task_first+0x75>
mov    %eax,%ebx
xor    %ebp,%ebp
xchg   %ax,%ax
movsbl 0xe(%rsp,%rbp,1),%edi
xor    %eax,%eax
call   1030 <kprint_char@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1190 <task_first+0x60>
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <kprint@plt>
mov    $0xf4240,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
nop
add    $0xffffffff,%eax
jne    11c0 <task_first+0x90>
add    $0x1,%r13d
jmp    1160 <task_first+0x30>

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [3 x i8] c"T:\00"
define void @task_first() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
br label %6
6: ; preds = %0, %34
%7 = call i32 (i8*, ...) bitcast (i32 (...)* @kprint to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) bitcast (i32 (...)* @kprint to i32 (i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%9 = load i32, i32* %1
%10 = call i32 ([10 x i8]*, i32, i32, ...) bitcast (i32 (...)* @int_to_str to i32 ([10 x i8]*, i32, i32, ...)*)([10 x i8]* %2, i32 10, i32 %9)
store i32 %10, i32* %3
store i32 0, i32* %4
br label %11
11: ; preds = %22, %6
%12 = load i32, i32* %4
%13 = load i32, i32* %3
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %25
15: ; preds = %11
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = call i32 (i32, ...) bitcast (i32 (...)* @kprint_char to i32 (i32, ...)*)(i32 %20)
br label %22
22: ; preds = %15
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %11
25: ; preds = %11
%26 = call i32 (i8*, ...) bitcast (i32 (...)* @kprint to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %27
27: ; preds = %31, %25
%28 = load i32, i32* %5
%29 = icmp slt i32 %28, 1000000
br i1 %29, label %30, label %34
30: ; preds = %27
br label %31
31: ; preds = %30
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
br label %27
34: ; preds = %27
%35 = load i32, i32* %1
%36 = add nsw i32 %35, 1
store i32 %36, i32* %1
br label %6
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [3 x i8] c"T:\00"
define void @task_first() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %21, %0
%4 = phi i32 [ 0, %0 ], [ %22, %21 ]
%5 = call i32 (i8*, ...) bitcast (i32 (...)* @kprint to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) bitcast (i32 (...)* @kprint to i32 (i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 ([10 x i8]*, i32, i32, ...) bitcast (i32 (...)* @int_to_str to i32 ([10 x i8]*, i32, i32, ...)*)([10 x i8]* %1, i32 10, i32 %4)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = zext i32 %7 to i64
br label %13
11: ; preds = %13, %3
%12 = call i32 (i8*, ...) bitcast (i32 (...)* @kprint to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %23
13: ; preds = %9, %13
%14 = phi i64 [ 0, %9 ], [ %19, %13 ]
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = call i32 (i32, ...) bitcast (i32 (...)* @kprint_char to i32 (i32, ...)*)(i32 %17)
%19 = add nuw nsw i64 %14, 1
%20 = icmp eq i64 %19, %10
br i1 %20, label %11, label %13
21: ; preds = %23
%22 = add nuw nsw i32 %4, 1
br label %3
23: ; preds = %11, %23
%24 = phi i32 [ 0, %11 ], [ %25, %23 ]
%25 = add nuw nsw i32 %24, 1
%26 = icmp eq i32 %25, 1000000
br i1 %26, label %21, label %23
}