#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ BsiGenerateTables(int /*<<< orphan*/ *, char *, double, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdout;
int main(int argc, char *argv[]) {
  FILE *output;
  ;
  if (argc > 2) {
    fprintf(stderr, "Usage: %s [output file]\n", argv[0]);
    return 1;
  }
  if (argc == 2) {
    output = fopen(argv[1], "wb");
    if (!output) {
      fprintf(stderr, "Failed to open %s for writing\n", argv[1]);
      return 1;
    }
  } else
    output = stdout;
  fprintf(output,
          "/* Generated by bsincgen, do not edit! */\n"
          "#pragma once\n\n"
          "static_assert(BSINC_SCALE_COUNT == %d, \"Unexpected "
          "BSINC_SCALE_COUNT value!\");\n"
          "static_assert(BSINC_PHASE_COUNT == %d, \"Unexpected "
          "BSINC_PHASE_COUNT value!\");\n\n"
          "namespace {\n\n"
          "struct BSincTable {\n"
          "    const float scaleBase, scaleRange;\n"
          "    const unsigned int m[BSINC_SCALE_COUNT];\n"
          "    const unsigned int filterOffset[BSINC_SCALE_COUNT];\n"
          "    const float *Tab;\n"
          "};\n\n",
          16, 32);
  BsiGenerateTables(output, "bsinc24", 60.0, 23);
  BsiGenerateTables(output, "bsinc12", 60.0, 11);
  fprintf(output, "} // namespace\n");
  if (output != stdout)
    fclose(output);
  output = NULL;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    118b <main+0x4b>
mov    0x2e79(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe90(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    128b <main+0x14b>
cmpl   $0x2,-0x8(%rbp)
jne    11e9 <main+0xa9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7d(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11e4 <main+0xa4>
mov    0x2e21(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe53(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    128b <main+0x14b>
jmp    11f7 <main+0xb7>
mov    0x2de8(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe41(%rip),%rsi
mov    $0x10,%edx
mov    $0x20,%ecx
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xfc4(%rip),%rsi
movsd  0xdda(%rip),%xmm0
mov    $0x17,%edx
call   1030 <BsiGenerateTables@plt>
mov    -0x18(%rbp),%rdi
lea    0xfaf(%rip),%rsi
movsd  0xdbd(%rip),%xmm0
mov    $0xb,%edx
call   1030 <BsiGenerateTables@plt>
mov    -0x18(%rbp),%rdi
lea    0xf9a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    0x2d6e(%rip),%rcx
cmp    (%rcx),%rax
je     127c <main+0x13c>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbp
cmp    $0x3,%edi
jl     1181 <main+0x31>
mov    0x2e7e(%rip),%rax
movslq (%rax),%rdi
mov    0x0(%rbp),%rdx
lea    0xe98(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%ebp
jmp    1241 <main+0xf1>
cmp    $0x2,%edi
jne    11b5 <main+0x65>
mov    0x8(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11bf <main+0x6f>
mov    0x2e3b(%rip),%rax
movslq (%rax),%rdi
mov    0x8(%rbp),%rdx
lea    0xe71(%rip),%rsi
jmp    1170 <main+0x20>
mov    0x2e1c(%rip),%rax
mov    (%rax),%rbx
lea    0xe7d(%rip),%rsi
xor    %ebp,%ebp
mov    %rbx,%rdi
mov    $0x10,%edx
mov    $0x20,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xfff(%rip),%rsi
movsd  0xe15(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x17,%edx
call   1030 <BsiGenerateTables@plt>
lea    0xfeb(%rip),%rsi
mov    %rbx,%rdi
movsd  0xdf6(%rip),%xmm0
mov    $0xb,%edx
call   1030 <BsiGenerateTables@plt>
lea    0xfd7(%rip),%rdi
mov    $0xf,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
mov    0x2da4(%rip),%rax
cmp    (%rax),%rbx
je     1241 <main+0xf1>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"Usage: %s [output file]\0A\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [31 x i8] c"Failed to open %s for writing\0A\00"
@stdout = global i32* null
@.str.3 = [415 x i8] c"/* Generated by bsincgen, do not edit! */\0A#pragma once\0A\0Astatic_assert(BSINC_SCALE_COUNT == %d, \22Unexpected BSINC_SCALE_COUNT value!\22);\0Astatic_assert(BSINC_PHASE_COUNT == %d, \22Unexpected BSINC_PHASE_COUNT value!\22);\0A\0Anamespace {\0A\0Astruct BSincTable {\0A const float scaleBase, scaleRange;\0A const unsigned int m[BSINC_SCALE_COUNT];\0A const unsigned int filterOffset[BSINC_SCALE_COUNT];\0A const float *Tab;\0A};\0A\0A\00"
@.str.4 = [8 x i8] c"bsinc24\00"
@.str.5 = [8 x i8] c"bsinc12\00"
@.str.6 = [16 x i8] c"} // namespace\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 2
br i1 %8, label %9, label %17
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = sext i32 %10 to i64
%12 = inttoptr i64 %11 to i32*
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 1, i32* %3
br label %54
17: ; preds = %2
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 2
br i1 %19, label %20, label %36
20: ; preds = %17
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %24, i32** %6
%25 = load i32*, i32** %6
%26 = icmp ne i32* %25, null
br i1 %26, label %35, label %27
27: ; preds = %20
%28 = load i32, i32* @stderr
%29 = sext i32 %28 to i64
%30 = inttoptr i64 %29 to i32*
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %33)
store i32 1, i32* %3
br label %54
35: ; preds = %20
br label %38
36: ; preds = %17
%37 = load i32*, i32** @stdout
store i32* %37, i32** %6
br label %38
38: ; preds = %36, %35
%39 = load i32*, i32** %6
%40 = call i32 (i32*, i8*, ...) @fprintf(i32* %39, i8* getelementptr inbounds ([415 x i8], [415 x i8]* @.str.3, i64 0, i64 0), i32 16, i32 32)
%41 = load i32*, i32** %6
%42 = call i32 @BsiGenerateTables(i32* %41, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), double 6.000000e+01, i32 23)
%43 = load i32*, i32** %6
%44 = call i32 @BsiGenerateTables(i32* %43, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), double 6.000000e+01, i32 11)
%45 = load i32*, i32** %6
%46 = call i32 (i32*, i8*, ...) @fprintf(i32* %45, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%47 = load i32*, i32** %6
%48 = load i32*, i32** @stdout
%49 = icmp ne i32* %47, %48
br i1 %49, label %50, label %53
50: ; preds = %38
%51 = load i32*, i32** %6
%52 = call i32 @fclose(i32* %51)
br label %53
53: ; preds = %50, %38
store i32* null, i32** %6
store i32 0, i32* %3
br label %54
54: ; preds = %53, %27, %9
%55 = load i32, i32* %3
ret i32 %55
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"Usage: %s [output file]\0A\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [31 x i8] c"Failed to open %s for writing\0A\00"
@stdout = global i32* null
@.str.3 = [415 x i8] c"/* Generated by bsincgen, do not edit! */\0A#pragma once\0A\0Astatic_assert(BSINC_SCALE_COUNT == %d, \22Unexpected BSINC_SCALE_COUNT value!\22);\0Astatic_assert(BSINC_PHASE_COUNT == %d, \22Unexpected BSINC_PHASE_COUNT value!\22);\0A\0Anamespace {\0A\0Astruct BSincTable {\0A const float scaleBase, scaleRange;\0A const unsigned int m[BSINC_SCALE_COUNT];\0A const unsigned int filterOffset[BSINC_SCALE_COUNT];\0A const float *Tab;\0A};\0A\0A\00"
@.str.4 = [8 x i8] c"bsinc24\00"
@.str.5 = [8 x i8] c"bsinc12\00"
@.str.6 = [16 x i8] c"} // namespace\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 2
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to i32*
%8 = load i8*, i8** %1
%9 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %35
10: ; preds = %2
%11 = icmp eq i32 %0, 2
br i1 %11, label %12, label %23
12: ; preds = %10
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %25
17: ; preds = %12
%18 = load i32, i32* @stderr
%19 = sext i32 %18 to i64
%20 = inttoptr i64 %19 to i32*
%21 = load i8*, i8** %13
%22 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %21)
br label %35
23: ; preds = %10
%24 = load i32*, i32** @stdout
br label %25
25: ; preds = %12, %23
%26 = phi i32* [ %15, %12 ], [ %24, %23 ]
%27 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([415 x i8], [415 x i8]* @.str.3, i64 0, i64 0), i32 16, i32 32)
%28 = tail call i32 @BsiGenerateTables(i32* %26, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), double 6.000000e+01, i32 23)
%29 = tail call i32 @BsiGenerateTables(i32* %26, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), double 6.000000e+01, i32 11)
%30 = tail call i64 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i64 15, i64 1, i32* %26)
%31 = load i32*, i32** @stdout
%32 = icmp eq i32* %26, %31
br i1 %32, label %35, label %33
33: ; preds = %25
%34 = tail call i32 @fclose(i32* %26)
br label %35
35: ; preds = %25, %33, %17, %4
%36 = phi i32 [ 1, %4 ], [ 1, %17 ], [ 0, %33 ], [ 0, %25 ]
ret i32 %36
}