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


x86 assembly (clang, -O0):
<iterate_first>:
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_first+0x36>
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <assert@plt>
cmpq   $0x0,-0x10(%rbp)
jne    1194 <iterate_first+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    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%rsi
lea    0xe6d(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iterate_first>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
test   %rdi,%rdi
je     117b <iterate_first+0x3b>
test   %r14,%r14
je     1193 <iterate_first+0x53>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,(%rbx)
addl   $0x1,0x4(%rbx)
lea    0xec9(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe7e(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <assert@plt>
test   %r14,%r14
jne    1154 <iterate_first+0x14>
lea    0xe80(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <assert@plt>
jmp    1154 <iterate_first+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 = [29 x i8] c"iterate_first: saw key '%s'\0A\00"
define i32 @iterate_first(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 i32 @strlen(i8* %20)
%22 = load i32*, i32** %5
%23 = getelementptr inbounds i32, i32* %22, i64 0
store i32 %21, i32* %23
%24 = load i32*, i32** %5
%25 = getelementptr inbounds i32, i32* %24, i64 1
%26 = load i32, i32* %25
%27 = add i32 %26, 1
store i32 %27, i32* %25
%28 = load i8*, i8** %4
%29 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %28)
ret i32 0
}

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 = [29 x i8] c"iterate_first: saw key '%s'\0A\00"
define i32 @iterate_first(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 i32 @strlen(i8* %1)
store i32 %14, i32* %13
%15 = getelementptr inbounds i8, i8* %0, i64 4
%16 = bitcast i8* %15 to i32*
%17 = load i32, i32* %16
%18 = add i32 %17, 1
store i32 %18, i32* %16
%19 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %1)
ret i32 0
}