#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*/ codeln(char *);
int /*<<< orphan*/ commentln(char *);
int /*<<< orphan*/ popIndent();
int /*<<< orphan*/ pushIndent();
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
void xfr_quadratic(char *xs, char *ys) {
  char buf[512];
  commentln("Quadratic function");
  codeln("{");
  pushIndent();
  codeln("float tx;");
  sprintf(buf, "tx = (%s < 0.0) ? -%s : %s;", xs, xs, xs);
  codeln(buf);
  codeln("if (tx < q_Th) {");
  pushIndent();
  sprintf(buf, "%s = tx * q_Tni;", ys);
  codeln(buf);
  popIndent();
  codeln("}");
  codeln("else if (tx < 1.0) {");
  pushIndent();
  codeln("float xa = tx - q_Th;");
  codeln("float xb = xa * q_Tsi;");
  sprintf(buf, "%s = (q_Th + (xa / (1.0 + (xb * xb)))) * q_Tni;", ys);
  codeln(buf);
  popIndent();
  codeln("}");
  codeln("else {");
  pushIndent();
  sprintf(buf, "%s = 1.0;", ys);
  codeln(buf);
  popIndent();
  codeln("}");
  sprintf(buf, "if (%s < 0.0) %s = -%s;", xs, ys, ys);
  codeln(buf);
  popIndent();
  codeln("}");
}


x86 assembly (clang, -O0):
<xfr_quadratic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe96(%rip),%rdi
call   1050 <commentln@plt>
lea    0xefa(%rip),%rdi
call   1040 <codeln@plt>
mov    $0x0,%al
call   1030 <pushIndent@plt>
lea    0xe8a(%rip),%rdi
call   1040 <codeln@plt>
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x8(%rbp),%rcx
mov    -0x8(%rbp),%r8
lea    0xe75(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x210(%rbp),%rdi
call   1040 <codeln@plt>
lea    0xe77(%rip),%rdi
call   1040 <codeln@plt>
mov    $0x0,%al
call   1030 <pushIndent@plt>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe6a(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x210(%rbp),%rdi
call   1040 <codeln@plt>
mov    $0x0,%al
call   1060 <popIndent@plt>
lea    0xe5a(%rip),%rdi
call   1040 <codeln@plt>
lea    0xe50(%rip),%rdi
call   1040 <codeln@plt>
mov    $0x0,%al
call   1030 <pushIndent@plt>
lea    0xe52(%rip),%rdi
call   1040 <codeln@plt>
lea    0xe5c(%rip),%rdi
call   1040 <codeln@plt>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe5c(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x210(%rbp),%rdi
call   1040 <codeln@plt>
mov    $0x0,%al
call   1060 <popIndent@plt>
lea    0xdf7(%rip),%rdi
call   1040 <codeln@plt>
lea    0xe5f(%rip),%rdi
call   1040 <codeln@plt>
mov    $0x0,%al
call   1030 <pushIndent@plt>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe48(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x210(%rbp),%rdi
call   1040 <codeln@plt>
mov    $0x0,%al
call   1060 <popIndent@plt>
lea    0xdac(%rip),%rdi
call   1040 <codeln@plt>
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x10(%rbp),%r8
lea    0xe12(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x210(%rbp),%rdi
call   1040 <codeln@plt>
mov    $0x0,%al
call   1060 <popIndent@plt>
lea    0xd6c(%rip),%rdi
call   1040 <codeln@plt>
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xfr_quadratic>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
lea    0xe95(%rip),%rdi
call   1050 <commentln@plt>
lea    0xef9(%rip),%rdi
call   1040 <codeln@plt>
xor    %eax,%eax
call   1030 <pushIndent@plt>
lea    0xe89(%rip),%rdi
call   1040 <codeln@plt>
lea    0xe87(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %r14,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <codeln@plt>
lea    0xe7e(%rip),%rdi
call   1040 <codeln@plt>
xor    %eax,%eax
call   1030 <pushIndent@plt>
lea    0xe7c(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <codeln@plt>
xor    %eax,%eax
call   1060 <popIndent@plt>
lea    0xe6a(%rip),%r12
mov    %r12,%rdi
call   1040 <codeln@plt>
lea    0xe5d(%rip),%rdi
call   1040 <codeln@plt>
xor    %eax,%eax
call   1030 <pushIndent@plt>
lea    0xe5f(%rip),%rdi
call   1040 <codeln@plt>
lea    0xe69(%rip),%rdi
call   1040 <codeln@plt>
lea    0xe74(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <codeln@plt>
xor    %eax,%eax
call   1060 <popIndent@plt>
mov    %r12,%rdi
call   1040 <codeln@plt>
lea    0xe79(%rip),%rdi
call   1040 <codeln@plt>
xor    %eax,%eax
call   1030 <pushIndent@plt>
lea    0xe6d(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <codeln@plt>
xor    %eax,%eax
call   1060 <popIndent@plt>
mov    %r12,%rdi
call   1040 <codeln@plt>
lea    0xe4c(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %r15,%r8
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <codeln@plt>
xor    %eax,%eax
call   1060 <popIndent@plt>
mov    %r12,%rdi
call   1040 <codeln@plt>
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Quadratic function\00"
@.str.1 = [2 x i8] c"{\00"
@.str.2 = [10 x i8] c"float tx;\00"
@.str.3 = [28 x i8] c"tx = (%s < 0.0) ? -%s : %s;\00"
@.str.4 = [17 x i8] c"if (tx < q_Th) {\00"
@.str.5 = [17 x i8] c"%s = tx * q_Tni;\00"
@.str.6 = [2 x i8] c"}\00"
@.str.7 = [21 x i8] c"else if (tx < 1.0) {\00"
@.str.8 = [22 x i8] c"float xa = tx - q_Th;\00"
@.str.9 = [23 x i8] c"float xb = xa * q_Tsi;\00"
@.str.10 = [48 x i8] c"%s = (q_Th + (xa / (1.0 + (xb * xb)))) * q_Tni;\00"
@.str.11 = [7 x i8] c"else {\00"
@.str.12 = [10 x i8] c"%s = 1.0;\00"
@.str.13 = [24 x i8] c"if (%s < 0.0) %s = -%s;\00"
define void @xfr_quadratic(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [512 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = call i32 @commentln(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @codeln(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (...) @pushIndent()
%9 = call i32 @codeln(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%11 = load i8*, i8** %3
%12 = load i8*, i8** %3
%13 = load i8*, i8** %3
%14 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %10, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %11, i8* %12, i8* %13)
%15 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%16 = call i32 @codeln(i8* %15)
%17 = call i32 @codeln(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%18 = call i32 (...) @pushIndent()
%19 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%20 = load i8*, i8** %4
%21 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %19, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %20)
%22 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%23 = call i32 @codeln(i8* %22)
%24 = call i32 (...) @popIndent()
%25 = call i32 @codeln(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%26 = call i32 @codeln(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
%27 = call i32 (...) @pushIndent()
%28 = call i32 @codeln(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
%29 = call i32 @codeln(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0))
%30 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%31 = load i8*, i8** %4
%32 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %30, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.10, i64 0, i64 0), i8* %31)
%33 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%34 = call i32 @codeln(i8* %33)
%35 = call i32 (...) @popIndent()
%36 = call i32 @codeln(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%37 = call i32 @codeln(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
%38 = call i32 (...) @pushIndent()
%39 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%40 = load i8*, i8** %4
%41 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %39, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i8* %40)
%42 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%43 = call i32 @codeln(i8* %42)
%44 = call i32 (...) @popIndent()
%45 = call i32 @codeln(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%46 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%47 = load i8*, i8** %3
%48 = load i8*, i8** %4
%49 = load i8*, i8** %4
%50 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %46, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0), i8* %47, i8* %48, i8* %49)
%51 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%52 = call i32 @codeln(i8* %51)
%53 = call i32 (...) @popIndent()
%54 = call i32 @codeln(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"Quadratic function\00"
@.str.1 = [2 x i8] c"{\00"
@.str.2 = [10 x i8] c"float tx;\00"
@.str.3 = [28 x i8] c"tx = (%s < 0.0) ? -%s : %s;\00"
@.str.4 = [17 x i8] c"if (tx < q_Th) {\00"
@.str.5 = [17 x i8] c"%s = tx * q_Tni;\00"
@.str.6 = [2 x i8] c"}\00"
@.str.7 = [21 x i8] c"else if (tx < 1.0) {\00"
@.str.8 = [22 x i8] c"float xa = tx - q_Th;\00"
@.str.9 = [23 x i8] c"float xb = xa * q_Tsi;\00"
@.str.10 = [48 x i8] c"%s = (q_Th + (xa / (1.0 + (xb * xb)))) * q_Tni;\00"
@.str.11 = [7 x i8] c"else {\00"
@.str.12 = [10 x i8] c"%s = 1.0;\00"
@.str.13 = [24 x i8] c"if (%s < 0.0) %s = -%s;\00"
define void @xfr_quadratic(i8* %0, i8* %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @commentln(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @codeln(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 (...) @pushIndent()
%8 = tail call i32 @codeln(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %0, i8* %0, i8* %0)
%10 = call i32 @codeln(i8* %4)
%11 = call i32 @codeln(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 (...) @pushIndent()
%13 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %1)
%14 = call i32 @codeln(i8* %4)
%15 = call i32 (...) @popIndent()
%16 = call i32 @codeln(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%17 = call i32 @codeln(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
%18 = call i32 (...) @pushIndent()
%19 = call i32 @codeln(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
%20 = call i32 @codeln(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0))
%21 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.10, i64 0, i64 0), i8* %1)
%22 = call i32 @codeln(i8* %4)
%23 = call i32 (...) @popIndent()
%24 = call i32 @codeln(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%25 = call i32 @codeln(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
%26 = call i32 (...) @pushIndent()
%27 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i8* %1)
%28 = call i32 @codeln(i8* %4)
%29 = call i32 (...) @popIndent()
%30 = call i32 @codeln(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%31 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0), i8* %0, i8* %1, i8* %1)
%32 = call i32 @codeln(i8* %4)
%33 = call i32 (...) @popIndent()
%34 = call i32 @codeln(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
ret void
}