#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 *, char *, ...);
int stub1(int);
int stub2(int);
void test_d_(char *d_name, int (*d_func)(int)) {
  printf("testing %s():\n", d_name);
  for (int m = 1; m <= 12; m++) {
    printf("\t%s(%2d) = %d\n", d_name, m, (*d_func)(m));
  }
  return;
}


x86 assembly (clang, -O0):
<test_d_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
cmpl   $0xc,-0x14(%rbp)
jg     117f <test_d_+0x6f>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%edi
call   *%rax
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    %eax,%ecx
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1139 <test_d_+0x29>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_d_>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xede(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%edi
call   *%r14
lea    0xed4(%rip),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x2,%edi
call   *%r14
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x3,%edi
call   *%r14
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x4,%edi
call   *%r14
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x5,%edi
call   *%r14
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x5,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x6,%edi
call   *%r14
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x7,%edi
call   *%r14
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x7,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x8,%edi
call   *%r14
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x9,%edi
call   *%r14
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x9,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xa,%edi
call   *%r14
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0xa,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xb,%edi
call   *%r14
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0xb,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xc,%edi
call   *%r14
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0xc,%edx
mov    %eax,%ecx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"testing %s():\0A\00"
@.str.1 = [15 x i8] c"\09%s(%2d) = %d\0A\00"
define void @test_d_(i8* %0, i32 (i32)* %1) {
%3 = alloca i8*
%4 = alloca i32 (i32)*
%5 = alloca i32
store i8* %0, i8** %3
store i32 (i32)* %1, i32 (i32)** %4
%6 = load i8*, i8** %3
%7 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %6)
store i32 1, i32* %5
br label %8
8: ; preds = %18, %2
%9 = load i32, i32* %5
%10 = icmp sle i32 %9, 12
br i1 %10, label %11, label %21
11: ; preds = %8
%12 = load i8*, i8** %3
%13 = load i32, i32* %5
%14 = load i32 (i32)*, i32 (i32)** %4
%15 = load i32, i32* %5
%16 = call i32 %14(i32 %15)
%17 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %12, i32 %13, i32 %16)
br label %18
18: ; preds = %11
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %8
21: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"testing %s():\0A\00"
@.str.1 = [15 x i8] c"\09%s(%2d) = %d\0A\00"
define void @test_d_(i8* %0, i32 (i32)* nocapture %1) {
%3 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = tail call i32 %1(i32 1)
%5 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 1, i32 %4)
%6 = tail call i32 %1(i32 2)
%7 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 2, i32 %6)
%8 = tail call i32 %1(i32 3)
%9 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 3, i32 %8)
%10 = tail call i32 %1(i32 4)
%11 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 4, i32 %10)
%12 = tail call i32 %1(i32 5)
%13 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 5, i32 %12)
%14 = tail call i32 %1(i32 6)
%15 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 6, i32 %14)
%16 = tail call i32 %1(i32 7)
%17 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 7, i32 %16)
%18 = tail call i32 %1(i32 8)
%19 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 8, i32 %18)
%20 = tail call i32 %1(i32 9)
%21 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 9, i32 %20)
%22 = tail call i32 %1(i32 10)
%23 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 10, i32 %22)
%24 = tail call i32 %1(i32 11)
%25 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 11, i32 %24)
%26 = tail call i32 %1(i32 12)
%27 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 12, i32 %26)
ret void
}