#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*/ clear();
int /*<<< orphan*/ mvaddstr(int, int, char *);
int pdetect_period(int, int /*<<< orphan*/ *);
int pid_get(int /*<<< orphan*/);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ sprintf(char *, char *, int, char *, int);
char *task_name(int);
void visual_update(void) {
  int p, todo;
  unsigned int j = 0, line = 0;
  clear();
  todo = 1;
  while (todo >= 0) {
    todo = pid_get(j++);
    if (todo > 0) {
      p = pdetect_period(todo, NULL);
      if (p) {
        char string[128];
        sprintf(string, "[%d] %s\t%d", todo, task_name(todo), p);
        mvaddstr(line++ + 4, 4, string);
      }
    }
  }
  refresh();
}


x86 assembly (clang, -O0):
<visual_update>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1090 <clear@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     123f <visual_update+0xcf>
mov    -0xc(%rbp),%edi
mov    %edi,%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
call   1080 <pid_get@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    123a <visual_update+0xca>
mov    -0x8(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <pdetect_period@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1235 <visual_update+0xc5>
lea    -0x90(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x94(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <task_name@plt>
mov    -0xa0(%rbp),%rdi
mov    -0x94(%rbp),%edx
mov    %rax,%rcx
mov    -0x4(%rbp),%r8d
lea    0xdef(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x10(%rbp),%edi
mov    %edi,%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
add    $0x4,%edi
lea    -0x90(%rbp),%rdx
mov    $0x4,%esi
call   1060 <mvaddstr@plt>
jmp    123a <visual_update+0xca>
jmp    1197 <visual_update+0x27>
mov    $0x0,%al
call   1040 <refresh@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<visual_update>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
xor    %r12d,%r12d
xor    %eax,%eax
call   1090 <clear@plt>
lea    0xe6e(%rip),%r14
mov    %rsp,%r15
xor    %ebp,%ebp
jmp    11a7 <visual_update+0x37>
nopl   0x0(%rax)
add    $0x1,%ebp
test   %ebx,%ebx
js     11fc <visual_update+0x8c>
mov    %ebp,%edi
call   1080 <pid_get@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    11a0 <visual_update+0x30>
mov    %ebx,%edi
xor    %esi,%esi
call   1050 <pdetect_period@plt>
test   %eax,%eax
je     11a0 <visual_update+0x30>
mov    %eax,%r13d
mov    %ebx,%edi
call   1030 <task_name@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
mov    %rax,%rcx
mov    %r13d,%r8d
call   1070 <sprintf@plt>
lea    0x1(%r12),%r13d
add    $0x4,%r12d
mov    %r12d,%edi
mov    $0x4,%esi
mov    %r15,%rdx
call   1060 <mvaddstr@plt>
mov    %r13d,%r12d
jmp    11a0 <visual_update+0x30>
xor    %eax,%eax
call   1040 <refresh@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"[%d] %s\09%d\00"
define void @visual_update() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [128 x i8]
store i32 0, i32* %3
store i32 0, i32* %4
%6 = call i32 (...) @clear()
store i32 1, i32* %2
br label %7
7: ; preds = %34, %0
%8 = load i32, i32* %2
%9 = icmp sge i32 %8, 0
br i1 %9, label %10, label %35
10: ; preds = %7
%11 = load i32, i32* %3
%12 = add i32 %11, 1
store i32 %12, i32* %3
%13 = call i32 @pid_get(i32 %11)
store i32 %13, i32* %2
%14 = load i32, i32* %2
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %34
16: ; preds = %10
%17 = load i32, i32* %2
%18 = call i32 @pdetect_period(i32 %17, i32* null)
store i32 %18, i32* %1
%19 = load i32, i32* %1
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %33
21: ; preds = %16
%22 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%23 = load i32, i32* %2
%24 = load i32, i32* %2
%25 = call i8* @task_name(i32 %24)
%26 = load i32, i32* %1
%27 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %23, i8* %25, i32 %26)
%28 = load i32, i32* %4
%29 = add i32 %28, 1
store i32 %29, i32* %4
%30 = add i32 %28, 4
%31 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%32 = call i32 @mvaddstr(i32 %30, i32 4, i8* %31)
br label %33
33: ; preds = %21, %16
br label %34
34: ; preds = %33, %10
br label %7
35: ; preds = %7
%36 = call i32 (...) @refresh()
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"[%d] %s\09%d\00"
define void @visual_update() {
%1 = alloca [128 x i8]
%2 = tail call i32 (...) @clear()
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
br label %4
4: ; preds = %0, %19
%5 = phi i32 [ 0, %0 ], [ %20, %19 ]
%6 = phi i32 [ 0, %0 ], [ %7, %19 ]
%7 = add i32 %6, 1
%8 = call i32 @pid_get(i32 %6)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %19
10: ; preds = %4
%11 = call i32 @pdetect_period(i32 %8, i32* null)
%12 = icmp eq i32 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %10
%14 = call i8* @task_name(i32 %8)
%15 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %8, i8* %14, i32 %11)
%16 = add i32 %5, 1
%17 = add i32 %5, 4
%18 = call i32 @mvaddstr(i32 %17, i32 4, i8* %3)
br label %19
19: ; preds = %10, %13, %4
%20 = phi i32 [ %16, %13 ], [ %5, %10 ], [ %5, %4 ]
%21 = icmp sgt i32 %8, -1
br i1 %21, label %4, label %22
22: ; preds = %19
%23 = call i32 (...) @refresh()
ret void
}