#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 stub1(int);
int stub2(int);
int stub3(int);
int stub4(int);
int stub5(int);
int stub6(int);
void test_to(const char *name, int (*fcn)(int)) {
  int k;
  (void)printf("\n");
  (void)printf("Test of %s: ", name);
  for (k = 0; k <= 255; ++k) {
    if ((*fcn)(k) != k)
      (void)printf(" %d->%d", k, (*fcn)(k));
  }
  (void)printf("\n");
  (void)printf("Test of %s: ", name);
  for (k = 0; k <= 255; ++k) {
    if ((*fcn)(k) != k)
      (void)printf(" %c->%c", k, (*fcn)(k));
  }
  (void)printf("\n");
}


x86 assembly (clang, -O0):
<test_to>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xff,-0x14(%rbp)
jg     119b <test_to+0x8b>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%edi
call   *%rax
cmp    -0x14(%rbp),%eax
je     1188 <test_to+0x78>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%edi
call   *%rax
mov    -0x18(%rbp),%esi
mov    %eax,%edx
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118d <test_to+0x7d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1147 <test_to+0x37>
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xff,-0x14(%rbp)
jg     1216 <test_to+0x106>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%edi
call   *%rax
cmp    -0x14(%rbp),%eax
je     1203 <test_to+0xf3>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%edi
call   *%rax
mov    -0x1c(%rbp),%esi
mov    %eax,%edx
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1208 <test_to+0xf8>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c2 <test_to+0xb2>
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_to>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xec2(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebe(%rip),%r15
xor    %ebp,%ebp
jmp    116b <test_to+0x4b>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%ebp
cmp    $0x100,%ebp
je     1187 <test_to+0x67>
mov    %ebp,%edi
call   *%rbx
cmp    %eax,%ebp
je     1160 <test_to+0x40>
mov    %ebp,%edi
call   *%rbx
mov    %r15,%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1160 <test_to+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe68(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe6c(%rip),%r14
xor    %ebp,%ebp
jmp    11bb <test_to+0x9b>
nopl   (%rax)
add    $0x1,%ebp
cmp    $0x100,%ebp
je     11d7 <test_to+0xb7>
mov    %ebp,%edi
call   *%rbx
cmp    %eax,%ebp
je     11b0 <test_to+0x90>
mov    %ebp,%edi
call   *%rbx
mov    %r14,%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11b0 <test_to+0x90>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [13 x i8] c"Test of %s: \00"
@.str.2 = [8 x i8] c" %d->%d\00"
@.str.3 = [8 x i8] c" %c->%c\00"
define void @test_to(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 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = load i8*, i8** %3
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %7)
store i32 0, i32* %5
br label %9
9: ; preds = %25, %2
%10 = load i32, i32* %5
%11 = icmp sle i32 %10, 255
br i1 %11, label %12, label %28
12: ; preds = %9
%13 = load i32 (i32)*, i32 (i32)** %4
%14 = load i32, i32* %5
%15 = call i32 %13(i32 %14)
%16 = load i32, i32* %5
%17 = icmp ne i32 %15, %16
br i1 %17, label %18, label %24
18: ; preds = %12
%19 = load i32, i32* %5
%20 = load i32 (i32)*, i32 (i32)** %4
%21 = load i32, i32* %5
%22 = call i32 %20(i32 %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %22)
br label %24
24: ; preds = %18, %12
br label %25
25: ; preds = %24
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %9
28: ; preds = %9
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%30 = load i8*, i8** %3
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %30)
store i32 0, i32* %5
br label %32
32: ; preds = %48, %28
%33 = load i32, i32* %5
%34 = icmp sle i32 %33, 255
br i1 %34, label %35, label %51
35: ; preds = %32
%36 = load i32 (i32)*, i32 (i32)** %4
%37 = load i32, i32* %5
%38 = call i32 %36(i32 %37)
%39 = load i32, i32* %5
%40 = icmp ne i32 %38, %39
br i1 %40, label %41, label %47
41: ; preds = %35
%42 = load i32, i32* %5
%43 = load i32 (i32)*, i32 (i32)** %4
%44 = load i32, i32* %5
%45 = call i32 %43(i32 %44)
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %42, i32 %45)
br label %47
47: ; preds = %41, %35
br label %48
48: ; preds = %47
%49 = load i32, i32* %5
%50 = add nsw i32 %49, 1
store i32 %50, i32* %5
br label %32
51: ; preds = %32
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [13 x i8] c"Test of %s: \00"
@.str.2 = [8 x i8] c" %d->%d\00"
@.str.3 = [8 x i8] c" %c->%c\00"
define void @test_to(i8* %0, i32 (i32)* nocapture %1) {
%3 = tail call i32 @putchar(i32 10)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %5
5: ; preds = %2, %12
%6 = phi i32 [ 0, %2 ], [ %13, %12 ]
%7 = tail call i32 %1(i32 %6)
%8 = icmp eq i32 %7, %6
br i1 %8, label %12, label %9
9: ; preds = %5
%10 = tail call i32 %1(i32 %6)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %6, i32 %10)
br label %12
12: ; preds = %5, %9
%13 = add nuw nsw i32 %6, 1
%14 = icmp eq i32 %13, 256
br i1 %14, label %15, label %5
15: ; preds = %12
%16 = tail call i32 @putchar(i32 10)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %18
18: ; preds = %15, %25
%19 = phi i32 [ 0, %15 ], [ %26, %25 ]
%20 = tail call i32 %1(i32 %19)
%21 = icmp eq i32 %20, %19
br i1 %21, label %25, label %22
22: ; preds = %18
%23 = tail call i32 %1(i32 %19)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %19, i32 %23)
br label %25
25: ; preds = %18, %22
%26 = add nuw nsw i32 %19, 1
%27 = icmp eq i32 %26, 256
br i1 %27, label %28, label %18
28: ; preds = %25
%29 = tail call i32 @putchar(i32 10)
ret void
}