#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*/ assert(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char const);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
void convert(const signed char MPH_to[90], const char *filename) {
  FILE *fp = fopen(filename, "w");
  assert(NULL != fp);
  fputs("// This file is automagically generated by mphtogen, do not edit\n",
        fp);
  unsigned i;
  unsigned len = 0;
  for (i = 0; i < 90; ++i) {
    if (len > 0) {
      fputc(',', fp);
      ++len;
    }
    if (len > 78) {
      fputc('\n', fp);
      len = 0;
    }
    fprintf(fp, "%3d", MPH_to[i]);
    len += 3;
  }
  if (len > 0) {
    fputc('\n', fp);
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<convert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x18(%rbp),%rsi
lea    0xe60(%rip),%rdi
call   1040 <fputs@plt>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x5a,-0x1c(%rbp)
jae    1231 <convert+0xd1>
cmpl   $0x0,-0x20(%rbp)
jbe    11e0 <convert+0x80>
mov    -0x18(%rbp),%rsi
mov    $0x2c,%edi
call   1050 <fputc@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x4e,-0x20(%rbp)
jbe    11ff <convert+0x9f>
mov    -0x18(%rbp),%rsi
mov    $0xa,%edi
call   1050 <fputc@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
lea    0xe33(%rip),%rsi
movsbl (%rax,%rcx,1),%edx
call   1070 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b5 <convert+0x55>
cmpl   $0x0,-0x20(%rbp)
jbe    1249 <convert+0xe9>
mov    -0x18(%rbp),%rsi
mov    $0xa,%edi
call   1050 <fputc@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rax
mov    %rdi,%r14
lea    0xe88(%rip),%rsi
mov    %rax,%rdi
call   1070 <fopen@plt>
mov    %rax,%r12
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
lea    0xe6a(%rip),%rdi
mov    $0x41,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1080 <fwrite@plt>
xor    %r13d,%r13d
lea    0xe90(%rip),%r15
xor    %ebp,%ebp
jmp    11df <convert+0x7f>
nopl   0x0(%rax,%rax,1)
movsbl (%r14,%r13,1),%edx
mov    %r12,%rdi
mov    %r15,%rsi
call   1060 <fprintf@plt>
add    $0x3,%ebx
add    $0x1,%r13
mov    %ebx,%ebp
cmp    $0x5a,%r13
je     1210 <convert+0xb0>
mov    $0x0,%ebx
test   %ebp,%ebp
je     11c0 <convert+0x60>
mov    $0x2c,%edi
mov    %r12,%rsi
call   1040 <fputc@plt>
add    $0x1,%ebp
mov    %ebp,%ebx
cmp    $0x4f,%ebp
jb     11c0 <convert+0x60>
mov    $0xa,%edi
mov    %r12,%rsi
call   1040 <fputc@plt>
xor    %ebx,%ebx
jmp    11c0 <convert+0x60>
mov    $0xa,%edi
mov    %r12,%rsi
call   1040 <fputc@plt>
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [66 x i8] c"// This file is automagically generated by mphtogen, do not edit\0A\00"
@.str.2 = [4 x i8] c"%3d\00"
define void @convert(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %4
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %5
%10 = load i32*, i32** %5
%11 = icmp ne i32* null, %10
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i32*, i32** %5
%15 = call i32 @fputs(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0), i32* %14)
store i32 0, i32* %7
store i32 0, i32* %6
br label %16
16: ; preds = %43, %2
%17 = load i32, i32* %6
%18 = icmp ult i32 %17, 90
br i1 %18, label %19, label %46
19: ; preds = %16
%20 = load i32, i32* %7
%21 = icmp ugt i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i32*, i32** %5
%24 = call i32 @fputc(i8 signext 44, i32* %23)
%25 = load i32, i32* %7
%26 = add i32 %25, 1
store i32 %26, i32* %7
br label %27
27: ; preds = %22, %19
%28 = load i32, i32* %7
%29 = icmp ugt i32 %28, 78
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i32*, i32** %5
%32 = call i32 @fputc(i8 signext 10, i32* %31)
store i32 0, i32* %7
br label %33
33: ; preds = %30, %27
%34 = load i32*, i32** %5
%35 = load i8*, i8** %3
%36 = load i32, i32* %6
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = call i32 @fprintf(i32* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8 signext %39)
%41 = load i32, i32* %7
%42 = add i32 %41, 3
store i32 %42, i32* %7
br label %43
43: ; preds = %33
%44 = load i32, i32* %6
%45 = add i32 %44, 1
store i32 %45, i32* %6
br label %16
46: ; preds = %16
%47 = load i32, i32* %7
%48 = icmp ugt i32 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %46
%50 = load i32*, i32** %5
%51 = call i32 @fputc(i8 signext 10, i32* %50)
br label %52
52: ; preds = %49, %46
%53 = load i32*, i32** %5
%54 = call i32 @fclose(i32* %53)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [66 x i8] c"// This file is automagically generated by mphtogen, do not edit\0A\00"
@.str.2 = [4 x i8] c"%3d\00"
define void @convert(i8* nocapture %0, i8* nocapture %1) {
%3 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp ne i32* %3, null
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = tail call i64 @fwrite(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0), i64 65, i64 1, i32* %3)
br label %8
8: ; preds = %2, %18
%9 = phi i64 [ 0, %2 ], [ %24, %18 ]
%10 = phi i32 [ 0, %2 ], [ %23, %18 ]
%11 = icmp eq i32 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %8
%13 = tail call i32 @fputc(i8 signext 44, i32* %3)
%14 = add i32 %10, 1
%15 = icmp ugt i32 %14, 78
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = tail call i32 @fputc(i8 signext 10, i32* %3)
br label %18
18: ; preds = %8, %16, %12
%19 = phi i32 [ 0, %16 ], [ %14, %12 ], [ 0, %8 ]
%20 = getelementptr inbounds i8, i8* %0, i64 %9
%21 = load i8, i8* %20
%22 = tail call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8 signext %21)
%23 = add nuw nsw i32 %19, 3
%24 = add nuw nsw i64 %9, 1
%25 = icmp eq i64 %24, 90
br i1 %25, label %26, label %8
26: ; preds = %18
%27 = tail call i32 @fputc(i8 signext 10, i32* %3)
%28 = tail call i32 @fclose(i32* %3)
ret void
}