#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*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char const *, unsigned int);
int /*<<< orphan*/ puts(char *);
scalar_t__ strlen(char const *);
unsigned int iterate_sum(void *state, const char *key, void **data) {
  unsigned int *state_sums = 0;
  unsigned int **data_int = 0;
  if (!state) {
    puts("iterate_each: state undef");
    assert(0);
  }
  if (!key) {
    puts("iterate_each: key undef");
    assert(0);
  }
  if (!data) {
    puts("iterate_each: data undef");
    assert(0);
  }
  data_int = (unsigned int **)data;
  state_sums = state;
  state_sums[0] += strlen(key);
  state_sums[1] += **data_int;
  state_sums[2] += 1;
  printf("iterate_sum: saw pair ('%s': '%u')\n", key, **data_int);
  return 1;
}


x86 assembly (clang, -O0):
<iterate_sum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1182 <iterate_sum+0x42>
lea    0xe8a(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <assert@plt>
cmpq   $0x0,-0x10(%rbp)
jne    11a0 <iterate_sum+0x60>
lea    0xe86(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <assert@plt>
cmpq   $0x0,-0x18(%rbp)
jne    11be <iterate_sum+0x7e>
lea    0xe80(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <assert@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    %rdx,%rcx
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
add    0x4(%rax),%ecx
mov    %ecx,0x4(%rax)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%ecx
add    $0x1,%ecx
mov    %ecx,0x8(%rax)
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%edx
lea    0xe32(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iterate_sum>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
test   %rdi,%rdi
je     118f <iterate_sum+0x4f>
test   %r14,%r14
je     11a7 <iterate_sum+0x67>
test   %r15,%r15
je     11bf <iterate_sum+0x7f>
mov    %r14,%rdi
call   1040 <strlen@plt>
add    %eax,(%rbx)
mov    (%r15),%rax
mov    (%rax),%ecx
add    %ecx,0x4(%rbx)
addl   $0x1,0x8(%rbx)
mov    (%rax),%edx
lea    0xecf(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe6a(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <assert@plt>
test   %r14,%r14
jne    1158 <iterate_sum+0x18>
lea    0xe6c(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <assert@plt>
test   %r15,%r15
jne    115d <iterate_sum+0x1d>
lea    0xe6c(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <assert@plt>
jmp    115d <iterate_sum+0x1d>

LLVM IR (-O0):
@.str = [26 x i8] c"iterate_each: state undef\00"
@.str.1 = [24 x i8] c"iterate_each: key undef\00"
@.str.2 = [25 x i8] c"iterate_each: data undef\00"
@.str.3 = [36 x i8] c"iterate_sum: saw pair ('%s': '%u')\0A\00"
define i32 @iterate_sum(i8* %0, i8* %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32*
%8 = alloca i32**
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8** %2, i8*** %6
store i32* null, i32** %7
store i32** null, i32*** %8
%9 = load i8*, i8** %4
%10 = icmp ne i8* %9, null
br i1 %10, label %14, label %11
11: ; preds = %3
%12 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @assert(i32 0)
br label %14
14: ; preds = %11, %3
%15 = load i8*, i8** %5
%16 = icmp ne i8* %15, null
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @assert(i32 0)
br label %20
20: ; preds = %17, %14
%21 = load i8**, i8*** %6
%22 = icmp ne i8** %21, null
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = call i32 @puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 @assert(i32 0)
br label %26
26: ; preds = %23, %20
%27 = load i8**, i8*** %6
%28 = bitcast i8** %27 to i32**
store i32** %28, i32*** %8
%29 = load i8*, i8** %4
%30 = bitcast i8* %29 to i32*
store i32* %30, i32** %7
%31 = load i8*, i8** %5
%32 = call i64 @strlen(i8* %31)
%33 = load i32*, i32** %7
%34 = getelementptr inbounds i32, i32* %33, i64 0
%35 = load i32, i32* %34
%36 = zext i32 %35 to i64
%37 = add nsw i64 %36, %32
%38 = trunc i64 %37 to i32
store i32 %38, i32* %34
%39 = load i32**, i32*** %8
%40 = load i32*, i32** %39
%41 = load i32, i32* %40
%42 = load i32*, i32** %7
%43 = getelementptr inbounds i32, i32* %42, i64 1
%44 = load i32, i32* %43
%45 = add i32 %44, %41
store i32 %45, i32* %43
%46 = load i32*, i32** %7
%47 = getelementptr inbounds i32, i32* %46, i64 2
%48 = load i32, i32* %47
%49 = add i32 %48, 1
store i32 %49, i32* %47
%50 = load i8*, i8** %5
%51 = load i32**, i32*** %8
%52 = load i32*, i32** %51
%53 = load i32, i32* %52
%54 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* %50, i32 %53)
ret i32 1
}

LLVM IR (-O2):
@.str = [26 x i8] c"iterate_each: state undef\00"
@.str.1 = [24 x i8] c"iterate_each: key undef\00"
@.str.2 = [25 x i8] c"iterate_each: data undef\00"
@.str.3 = [36 x i8] c"iterate_sum: saw pair ('%s': '%u')\0A\00"
define i32 @iterate_sum(i8* %0, i8* %1, i8** %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @assert(i32 0)
br label %8
8: ; preds = %5, %3
%9 = icmp eq i8* %1, null
br i1 %9, label %10, label %13
10: ; preds = %8
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 @assert(i32 0)
br label %13
13: ; preds = %10, %8
%14 = icmp eq i8** %2, null
br i1 %14, label %15, label %18
15: ; preds = %13
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%17 = tail call i32 @assert(i32 0)
br label %18
18: ; preds = %15, %13
%19 = bitcast i8** %2 to i32**
%20 = bitcast i8* %0 to i32*
%21 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%22 = load i32, i32* %20
%23 = trunc i64 %21 to i32
%24 = add i32 %22, %23
store i32 %24, i32* %20
%25 = load i32*, i32** %19
%26 = load i32, i32* %25
%27 = getelementptr inbounds i8, i8* %0, i64 4
%28 = bitcast i8* %27 to i32*
%29 = load i32, i32* %28
%30 = add i32 %29, %26
store i32 %30, i32* %28
%31 = getelementptr inbounds i8, i8* %0, i64 8
%32 = bitcast i8* %31 to i32*
%33 = load i32, i32* %32
%34 = add i32 %33, 1
store i32 %34, i32* %32
%35 = load i32, i32* %25
%36 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* %1, i32 %35)
ret i32 1
}