#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*/ printf(char *, ...);
int callback(void *junk __attribute__((unused)), int cnt, char **vals,
             char **col_name) {
  int i = 0;
  printf("\n");
  for (i = 0; i < cnt; ++i) {
    if (vals[i]) {
      printf("%s: %s\n", col_name[i], vals[i]);
    } else {
      printf("%s: %s\n", col_name[i], "NULL");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<callback>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c1 <callback+0xb1>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     118d <callback+0x7d>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ae <callback+0x9e>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe60(%rip),%rdi
lea    0xe61(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b3 <callback+0xa3>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1143 <callback+0x33>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<callback>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r13
mov    %esi,%ebp
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %ebp,%ebp
jle    1186 <callback+0x66>
mov    %ebp,%ebp
lea    0xeb6(%rip),%r15
lea    0xeb7(%rip),%r12
xor    %ebx,%ebx
jmp    1170 <callback+0x50>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
je     1186 <callback+0x66>
mov    0x0(%r13,%rbx,8),%rdx
mov    (%r14,%rbx,8),%rsi
mov    %r15,%rdi
test   %rdx,%rdx
jne    1160 <callback+0x40>
mov    %r12,%rdx
jmp    1160 <callback+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [8 x i8] c"%s: %s\0A\00"
@.str.2 = [5 x i8] c"NULL\00"
define i32 @callback(i8* nocapture readnone %0, i32 %1, i8** nocapture %2, i8** nocapture %3) {
%5 = tail call i32 @putchar(i32 10)
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %23
7: ; preds = %4
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %7, %20
%10 = phi i64 [ 0, %7 ], [ %21, %20 ]
%11 = getelementptr inbounds i8*, i8** %2, i64 %10
%12 = load i8*, i8** %11
%13 = icmp eq i8* %12, null
%14 = getelementptr inbounds i8*, i8** %3, i64 %10
%15 = load i8*, i8** %14
br i1 %13, label %18, label %16
16: ; preds = %9
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %15, i8* %12)
br label %20
18: ; preds = %9
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %16, %18
%21 = add nuw nsw i64 %10, 1
%22 = icmp eq i64 %21, %8
br i1 %22, label %23, label %9
23: ; preds = %20, %4
ret i32 0
}