#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*/ printf(char *, ...);
int rtl_htblGetFlags(void *);
int WalkPrint(void *h, char *k, void *d, void *u) {
  int f = rtl_htblGetFlags(h);
  if ((f & 1) == 1) {
    printf("k=%s d=%s\n", k, (char *)d);
    return 0;
  }
  if ((f & 2) == 2) {
    printf("k=%d d=%s\n", (size_t)k, (char *)d);
    return 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<WalkPrint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <rtl_htblGetFlags@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
and    $0x1,%eax
cmp    $0x1,%eax
jne    1175 <WalkPrint+0x55>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ad <WalkPrint+0x8d>
mov    -0x2c(%rbp),%eax
and    $0x2,%eax
cmp    $0x2,%eax
jne    11a6 <WalkPrint+0x86>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ad <WalkPrint+0x8d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WalkPrint>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
call   1030 <rtl_htblGetFlags@plt>
test   $0x1,%al
jne    1140 <WalkPrint+0x20>
test   $0x2,%al
je     1154 <WalkPrint+0x34>
lea    0xecd(%rip),%rdi
jmp    1147 <WalkPrint+0x27>
lea    0xeb9(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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