#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 *, ...);
void do_one(char *name, double (*f)(double), double *args, int nargs,
            char *argfmt, char *resfmt) {
  int i;
  double a, r;
  printf("\n");
  for (i = 0; i < nargs; i++) {
    a = args[i];
    r = f(a);
    printf("%s ", name);
    printf(argfmt, a);
    printf(" -> ");
    printf(resfmt, r);
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<do_one>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11ce <do_one+0xbe>
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movsd  -0x40(%rbp),%xmm0
call   *%rax
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
movsd  -0x40(%rbp),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rdi
movsd  -0x48(%rbp),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1144 <do_one+0x34>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_one>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,(%rsp)
mov    %r8,%r15
mov    %ecx,%ebp
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%rbx
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %ebp,%ebp
jle    11c8 <do_one+0xa8>
mov    %ebp,%ebp
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  (%r12,%r14,8),%xmm0
movsd  %xmm0,0x8(%rsp)
call   *%r13
movsd  %xmm0,0x10(%rsp)
lea    0xe84(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe67(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r14
cmp    %r14,%rbp
jne    1160 <do_one+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [4 x i8] c"%s \00"
@.str.2 = [5 x i8] c" -> \00"
define void @do_one(i8* %0, double (double)* %1, double* %2, i32 %3, i8* %4, i8* %5) {
%7 = alloca i8*
%8 = alloca double (double)*
%9 = alloca double*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca double
%15 = alloca double
store i8* %0, i8** %7
store double (double)* %1, double (double)** %8
store double* %2, double** %9
store i32 %3, i32* %10
store i8* %4, i8** %11
store i8* %5, i8** %12
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %13
br label %17
17: ; preds = %40, %6
%18 = load i32, i32* %13
%19 = load i32, i32* %10
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %43
21: ; preds = %17
%22 = load double*, double** %9
%23 = load i32, i32* %13
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %22, i64 %24
%26 = load double, double* %25
store double %26, double* %14
%27 = load double (double)*, double (double)** %8
%28 = load double, double* %14
%29 = call double %27(double %28)
store double %29, double* %15
%30 = load i8*, i8** %7
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = load i8*, i8** %11
%33 = load double, double* %14
%34 = call i32 (i8*, ...) @printf(i8* %32, double %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%36 = load i8*, i8** %12
%37 = load double, double* %15
%38 = call i32 (i8*, ...) @printf(i8* %36, double %37)
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %40
40: ; preds = %21
%41 = load i32, i32* %13
%42 = add nsw i32 %41, 1
store i32 %42, i32* %13
br label %17
43: ; preds = %17
ret void
}

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