#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 YP_NOMORE;
int /*<<< orphan*/ printf(char *, char *, char *);
int yptest_foreach(int status, char *key, int keylen, char *val, int vallen,
                   char *data) {
  if (status == YP_NOMORE)
    return 0;
  key[keylen] = '\0';
  val[vallen] = '\0';
  printf("%s %s\n", key, val);
  return 0;
}


x86 assembly (clang, -O0):
<yptest_foreach>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2ea8(%rip),%rcx
cmp    (%rcx),%eax
jne    114c <yptest_foreach+0x3c>
movl   $0x0,-0x4(%rbp)
jmp    117f <yptest_foreach+0x6f>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<yptest_foreach>:
push   %rax
mov    0x2ec8(%rip),%rax
cmp    %edi,(%rax)
je     1139 <yptest_foreach+0x29>
movslq %edx,%rax
movb   $0x0,(%rsi,%rax,1)
movslq %r8d,%rax
movb   $0x0,(%rcx,%rax,1)
lea    0xecf(%rip),%rdi
mov    %rcx,%rdx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@YP_NOMORE = global i32 0
@.str = [7 x i8] c"%s %s\0A\00"
define i32 @yptest_foreach(i32 %0, i8* %1, i32 %2, i8* %3, i32 %4, i8* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i8*
store i32 %0, i32* %8
store i8* %1, i8** %9
store i32 %2, i32* %10
store i8* %3, i8** %11
store i32 %4, i32* %12
store i8* %5, i8** %13
%14 = load i32, i32* %8
%15 = load i32, i32* @YP_NOMORE
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %18
17: ; preds = %6
store i32 0, i32* %7
br label %30
18: ; preds = %6
%19 = load i8*, i8** %9
%20 = load i32, i32* %10
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
store i8 0, i8* %22
%23 = load i8*, i8** %11
%24 = load i32, i32* %12
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
store i8 0, i8* %26
%27 = load i8*, i8** %9
%28 = load i8*, i8** %11
%29 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %27, i8* %28)
store i32 0, i32* %7
br label %30
30: ; preds = %18, %17
%31 = load i32, i32* %7
ret i32 %31
}

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