#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*/ fprintf(int /*<<< orphan*/, char *, char const *, ...);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdout;
int callback(void *data, int argc, char **argv, char **azColName) {
  int i;
  data = "Callback function called";
  fprintf(stdout, "%s: ", (const char *)data);
  for (i = 0; i < argc; i++) {
    fprintf(stdout, "%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<callback>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    0xec2(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    0x2e97(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xec3(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11eb <callback+0xcb>
mov    0x2e69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11b4 <callback+0x94>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x40(%rbp)
jmp    11c4 <callback+0xa4>
lea    0xe6c(%rip),%rax
mov    %rax,-0x40(%rbp)
jmp    11c4 <callback+0xa4>
mov    -0x30(%rbp),%rdx
mov    -0x34(%rbp),%edi
mov    -0x40(%rbp),%rcx
lea    0xe48(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1164 <callback+0x44>
lea    0xe33(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%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,%rbx
mov    %esi,%r15d
mov    0x2ea5(%rip),%rax
mov    (%rax),%edi
lea    0xed5(%rip),%rsi
lea    0xeb5(%rip),%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
test   %r15d,%r15d
jle    119b <callback+0x7b>
mov    %r15d,%ebp
lea    0xec6(%rip),%r13
lea    0xeb6(%rip),%r15
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    (%r14,%r12,8),%rdx
mov    (%rbx,%r12,8),%rcx
test   %rcx,%rcx
cmove  %r13,%rcx
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x1,%r12
cmp    %r12,%rbp
jne    1170 <callback+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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