#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 */
typedef int /*<<< orphan*/ prev_section;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char const *, char const *);
scalar_t__ strcmp(char const *, char *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
int dumper(void *user, const char *section, const char *name,
           const char *value) {
  static char prev_section[50] = "";
  if (strcmp(section, prev_section)) {
    printf("%s[%s]\n", (prev_section[0] ? "\n" : ""), section);
    strncpy(prev_section, section, sizeof(prev_section));
    prev_section[sizeof(prev_section) - 1] = '\0';
  }
  printf("%s = %s\n", name, value);
  return 1;
}


x86 assembly (clang, -O0):
<dumper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0x2efd(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11aa <dumper+0x7a>
movsbl 0x2ee7(%rip),%ecx
lea    0xe97(%rip),%rsi
lea    0xe8f(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
mov    -0x10(%rbp),%rdx
lea    0xe77(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0x2eb7(%rip),%rdi
mov    $0x32,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x2ed7(%rip)
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe4f(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dumper>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
lea    0x2f08(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     119b <dumper+0x6b>
lea    0x2ef4(%rip),%r12
cmpb   $0x0,0x2eed(%rip)
lea    0xe9d(%rip),%rax
lea    0xe95(%rip),%rsi
cmove  %rax,%rsi
lea    0xe84(%rip),%rdi
mov    %rbx,%rdx
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x32,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x2ee6(%rip)
lea    0xe66(%rip),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@dumper.prev_section = internal global [50 x i8] zeroinitializer
@.str = [8 x i8] c"%s[%s]\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [9 x i8] c"%s = %s\0A\00"
define i32 @dumper(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%9 = load i8*, i8** %6
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @dumper.prev_section, i64 0, i64 0))
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %4
%13 = load i8, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @dumper.prev_section, i64 0, i64 0)
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
%16 = zext i1 %15 to i64
%17 = select i1 %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%18 = load i8*, i8** %6
%19 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %17, i8* %18)
%20 = load i8*, i8** %6
%21 = call i32 @strncpy(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @dumper.prev_section, i64 0, i64 0), i8* %20, i32 50)
store i8 0, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @dumper.prev_section, i64 0, i64 49)
br label %22
22: ; preds = %12, %4
%23 = load i8*, i8** %7
%24 = load i8*, i8** %8
%25 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %23, i8* %24)
ret i32 1
}

LLVM IR (-O2):
@dumper.prev_section = internal global [50 x i8] zeroinitializer
@.str = [8 x i8] c"%s[%s]\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [9 x i8] c"%s = %s\0A\00"
define i32 @dumper(i8* nocapture readnone %0, i8* %1, i8* %2, i8* %3) {
%5 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @dumper.prev_section, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %13, label %7
7: ; preds = %4
%8 = load i8, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @dumper.prev_section, i64 0, i64 0)
%9 = icmp eq i8 %8, 0
%10 = select i1 %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %1)
%12 = tail call i32 @strncpy(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @dumper.prev_section, i64 0, i64 0), i8* %1, i32 50)
store i8 0, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @dumper.prev_section, i64 0, i64 49)
br label %13
13: ; preds = %7, %4
%14 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %2, i8* %3)
ret i32 1
}