#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*/ fileno(int /*<<< orphan*/);
char *get_val(char **, char **, int, char *);
scalar_t__ isatty(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, char *, char *, ...);
int /*<<< orphan*/ stdout;
int project_list_tasks_callback(void *data, int n, char **vals, char **keys) {
  char *done = get_val(keys, vals, n, "timedone");
  if (isatty(fileno(stdout)))
    printf("%s%1.2s. %-50.50s %-16.16s\n"
           "\x1B"
           "[0m",
           done ? "\x1B"
                  "[2m"
                : "\x1B"
                  "[1m",
           get_val(keys, vals, n, "id"), get_val(keys, vals, n, "name"),
           done ? done : "");
  else
    printf("%s\t%s\t%s\n", get_val(keys, vals, n, "id"),
           get_val(keys, vals, n, "name"), done ? done : "");
  return 0;
}


x86 assembly (clang, -O0):
<project_list_tasks_callback>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0xe97(%rip),%rcx
call   1050 <get_val@plt>
mov    %rax,-0x28(%rbp)
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
call   1060 <fileno@plt>
mov    %eax,%edi
call   1030 <isatty@plt>
cmp    $0x0,%rax
je     1230 <project_list_tasks_callback+0xf0>
mov    -0x28(%rbp),%rdx
lea    0xe92(%rip),%rax
lea    0xe86(%rip),%rcx
cmp    $0x0,%rdx
cmovne %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0xe72(%rip),%rcx
call   1050 <get_val@plt>
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0xe5a(%rip),%rcx
call   1050 <get_val@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11fd <project_list_tasks_callback+0xbd>
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    120d <project_list_tasks_callback+0xcd>
lea    0xe40(%rip),%rax
mov    %rax,-0x48(%rbp)
jmp    120d <project_list_tasks_callback+0xcd>
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%rdx
mov    -0x40(%rbp),%rsi
mov    -0x48(%rbp),%r8
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12a8 <project_list_tasks_callback+0x168>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0xdf1(%rip),%rcx
call   1050 <get_val@plt>
mov    %rax,-0x58(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0xdd9(%rip),%rcx
call   1050 <get_val@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     127e <project_list_tasks_callback+0x13e>
mov    -0x28(%rbp),%rax
mov    %rax,-0x60(%rbp)
jmp    128e <project_list_tasks_callback+0x14e>
lea    0xdbf(%rip),%rax
mov    %rax,-0x60(%rbp)
jmp    128e <project_list_tasks_callback+0x14e>
mov    -0x50(%rbp),%rdx
mov    -0x58(%rbp),%rsi
mov    -0x60(%rbp),%rcx
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<project_list_tasks_callback>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%rbp
mov    %rdx,%rbx
mov    %esi,%r15d
lea    0xea8(%rip),%rcx
mov    %rbp,%rdi
mov    %rdx,%rsi
mov    %r15d,%edx
call   1050 <get_val@plt>
mov    %rax,%r14
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
call   1060 <fileno@plt>
mov    %eax,%edi
call   1030 <isatty@plt>
lea    0xeae(%rip),%rcx
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
test   %rax,%rax
je     11e6 <project_list_tasks_callback+0xa6>
call   1050 <get_val@plt>
mov    %rax,%r12
lea    0xe94(%rip),%rcx
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1050 <get_val@plt>
test   %r14,%r14
lea    0xe74(%rip),%rcx
lea    0xe68(%rip),%rsi
cmove  %rcx,%rsi
lea    0xe78(%rip),%r8
cmovne %r14,%r8
lea    0xe32(%rip),%rdi
mov    %r12,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1225 <project_list_tasks_callback+0xe5>
call   1050 <get_val@plt>
mov    %rax,%r12
lea    0xe41(%rip),%rcx
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1050 <get_val@plt>
test   %r14,%r14
lea    0xe37(%rip),%rcx
cmovne %r14,%rcx
lea    0xe23(%rip),%rdi
mov    %r12,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"timedone\00"
@stdout = global i32 0
@.str.1 = [32 x i8] c"%s%1.2s. %-50.50s %-16.16s\0A\1B[0m\00"
@.str.2 = [5 x i8] c"\1B[2m\00"
@.str.3 = [5 x i8] c"\1B[1m\00"
@.str.4 = [3 x i8] c"id\00"
@.str.5 = [5 x i8] c"name\00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [10 x i8] c"%s\09%s\09%s\0A\00"
define i32 @project_list_tasks_callback(i8* %0, i32 %1, i8** %2, i8** %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i8*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
store i8** %3, i8*** %8
%10 = load i8**, i8*** %8
%11 = load i8**, i8*** %7
%12 = load i32, i32* %6
%13 = call i8* @get_val(i8** %10, i8** %11, i32 %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i8* %13, i8** %9
%14 = load i32, i32* @stdout
%15 = call i32 @fileno(i32 %14)
%16 = call i64 @isatty(i32 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %39
18: ; preds = %4
%19 = load i8*, i8** %9
%20 = icmp ne i8* %19, null
%21 = zext i1 %20 to i64
%22 = select i1 %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%23 = load i8**, i8*** %8
%24 = load i8**, i8*** %7
%25 = load i32, i32* %6
%26 = call i8* @get_val(i8** %23, i8** %24, i32 %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%27 = load i8**, i8*** %8
%28 = load i8**, i8*** %7
%29 = load i32, i32* %6
%30 = call i8* @get_val(i8** %27, i8** %28, i32 %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%31 = load i8*, i8** %9
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %35
33: ; preds = %18
%34 = load i8*, i8** %9
br label %36
35: ; preds = %18
br label %36
36: ; preds = %35, %33
%37 = phi i8* [ %34, %33 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), %35 ]
%38 = call i32 (i8*, i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %22, i8* %26, i8* %30, i8* %37)
br label %56
39: ; preds = %4
%40 = load i8**, i8*** %8
%41 = load i8**, i8*** %7
%42 = load i32, i32* %6
%43 = call i8* @get_val(i8** %40, i8** %41, i32 %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%44 = load i8**, i8*** %8
%45 = load i8**, i8*** %7
%46 = load i32, i32* %6
%47 = call i8* @get_val(i8** %44, i8** %45, i32 %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%48 = load i8*, i8** %9
%49 = icmp ne i8* %48, null
br i1 %49, label %50, label %52
50: ; preds = %39
%51 = load i8*, i8** %9
br label %53
52: ; preds = %39
br label %53
53: ; preds = %52, %50
%54 = phi i8* [ %51, %50 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), %52 ]
%55 = call i32 (i8*, i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %43, i8* %47, i8* %54)
br label %56
56: ; preds = %53, %36
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"timedone\00"
@stdout = global i32 0
@.str.1 = [32 x i8] c"%s%1.2s. %-50.50s %-16.16s\0A\1B[0m\00"
@.str.2 = [5 x i8] c"\1B[2m\00"
@.str.3 = [5 x i8] c"\1B[1m\00"
@.str.4 = [3 x i8] c"id\00"
@.str.5 = [5 x i8] c"name\00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [10 x i8] c"%s\09%s\09%s\0A\00"
define i32 @project_list_tasks_callback(i8* nocapture readnone %0, i32 %1, i8** %2, i8** %3) {
%5 = tail call i8* @get_val(i8** %3, i8** %2, i32 %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @stdout
%7 = tail call i32 @fileno(i32 %6)
%8 = tail call i64 @isatty(i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %4
%11 = icmp eq i8* %5, null
%12 = select i1 %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%13 = tail call i8* @get_val(i8** %3, i8** %2, i32 %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%14 = tail call i8* @get_val(i8** %3, i8** %2, i32 %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%15 = select i1 %11, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i8* %5
%16 = tail call i32 (i8*, i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %12, i8* %13, i8* %14, i8* %15)
br label %23
17: ; preds = %4
%18 = tail call i8* @get_val(i8** %3, i8** %2, i32 %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%19 = tail call i8* @get_val(i8** %3, i8** %2, i32 %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%20 = icmp eq i8* %5, null
%21 = select i1 %20, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i8* %5
%22 = tail call i32 (i8*, i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %18, i8* %19, i8* %21)
br label %23
23: ; preds = %17, %10
ret i32 0
}