#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*/ setp(int (*)(), int);
int main(void) {
  int (*p)(void);
  int i;
  for (i = 0; i < 10; i++) {
    setp(&p, i);
    p();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    114d <main+0x3d>
lea    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <setp@plt>
call   *-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1126 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <setp@plt>
call   *0x8(%rsp)
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <setp@plt>
call   *0x8(%rsp)
mov    %rbx,%rdi
mov    $0x2,%esi
call   1030 <setp@plt>
call   *0x8(%rsp)
mov    %rbx,%rdi
mov    $0x3,%esi
call   1030 <setp@plt>
call   *0x8(%rsp)
mov    %rbx,%rdi
mov    $0x4,%esi
call   1030 <setp@plt>
call   *0x8(%rsp)
mov    %rbx,%rdi
mov    $0x5,%esi
call   1030 <setp@plt>
call   *0x8(%rsp)
mov    %rbx,%rdi
mov    $0x6,%esi
call   1030 <setp@plt>
call   *0x8(%rsp)
mov    %rbx,%rdi
mov    $0x7,%esi
call   1030 <setp@plt>
call   *0x8(%rsp)
mov    %rbx,%rdi
mov    $0x8,%esi
call   1030 <setp@plt>
call   *0x8(%rsp)
mov    %rbx,%rdi
mov    $0x9,%esi
call   1030 <setp@plt>
call   *0x8(%rsp)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32 ()*
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %4
4: ; preds = %13, %0
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 10
br i1 %6, label %7, label %16
7: ; preds = %4
%8 = bitcast i32 ()** %2 to i32 (...)*
%9 = load i32, i32* %3
%10 = call i32 @setp(i32 (...)* %8, i32 %9)
%11 = load i32 ()*, i32 ()** %2
%12 = call i32 %11()
br label %13
13: ; preds = %7
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %4
16: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca i32 ()*
%2 = bitcast i32 ()** %1 to i8*
%3 = bitcast i32 ()** %1 to i32 (...)*
%4 = call i32 @setp(i32 (...)* %3, i32 0)
%5 = load i32 ()*, i32 ()** %1
%6 = call i32 %5()
%7 = call i32 @setp(i32 (...)* %3, i32 1)
%8 = load i32 ()*, i32 ()** %1
%9 = call i32 %8()
%10 = call i32 @setp(i32 (...)* %3, i32 2)
%11 = load i32 ()*, i32 ()** %1
%12 = call i32 %11()
%13 = call i32 @setp(i32 (...)* %3, i32 3)
%14 = load i32 ()*, i32 ()** %1
%15 = call i32 %14()
%16 = call i32 @setp(i32 (...)* %3, i32 4)
%17 = load i32 ()*, i32 ()** %1
%18 = call i32 %17()
%19 = call i32 @setp(i32 (...)* %3, i32 5)
%20 = load i32 ()*, i32 ()** %1
%21 = call i32 %20()
%22 = call i32 @setp(i32 (...)* %3, i32 6)
%23 = load i32 ()*, i32 ()** %1
%24 = call i32 %23()
%25 = call i32 @setp(i32 (...)* %3, i32 7)
%26 = load i32 ()*, i32 ()** %1
%27 = call i32 %26()
%28 = call i32 @setp(i32 (...)* %3, i32 8)
%29 = load i32 ()*, i32 ()** %1
%30 = call i32 %29()
%31 = call i32 @setp(i32 (...)* %3, i32 9)
%32 = load i32 ()*, i32 ()** %1
%33 = call i32 %32()
ret i32 0
}