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


x86 assembly (clang, -O0):
<iterate_sum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1176 <iterate_sum+0x36>
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <assert@plt>
cmpq   $0x0,-0x10(%rbp)
jne    1194 <iterate_sum+0x54>
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    %rdx,%rcx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%rsi
lea    0xe67(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iterate_sum>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
test   %rdi,%rdi
je     117e <iterate_sum+0x3e>
test   %r14,%r14
je     1196 <iterate_sum+0x56>
mov    %r14,%rdi
call   1040 <strlen@plt>
add    %eax,(%rbx)
addl   $0x1,0x4(%rbx)
lea    0xec9(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe7b(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <assert@plt>
test   %r14,%r14
jne    1154 <iterate_sum+0x14>
lea    0xe7d(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <assert@plt>
jmp    1154 <iterate_sum+0x14>

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