#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
int writeH(int levelnum) {
  char path[10];
  FILE *fp;
  int row;
  int first;
  int i;
  int size;
  path[0] = 'l';
  path[1] = 'e';
  path[2] = 'v';
  path[3] = 'e';
  path[4] = 'l';
  if (levelnum < 10) {
    path[5] = levelnum + '0';
    path[6] = '.';
    path[7] = 'h';
    path[8] = '\0';
  } else {
    path[6] = (levelnum % 10) + '0';
    path[5] = (levelnum / 10) + '0';
    path[7] = '.';
    path[8] = 'h';
    path[9] = '\0';
  }
  fp = fopen(path, "w");
  if (fp == NULL) {
    return -1;
  }
  fprintf(
      fp,
      "/*\n * level %i\n * generated with xythobuz' BobLevelCreator\n */\n\n",
      levelnum);
  fprintf(fp, "extern char **level%i[8];\n", levelnum);
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<writeH>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
movb   $0x6c,-0x12(%rbp)
movb   $0x65,-0x11(%rbp)
movb   $0x76,-0x10(%rbp)
movb   $0x65,-0xf(%rbp)
movb   $0x6c,-0xe(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    1173 <writeH+0x43>
mov    -0x8(%rbp),%eax
add    $0x30,%eax
mov    %al,-0xd(%rbp)
movb   $0x2e,-0xc(%rbp)
movb   $0x68,-0xb(%rbp)
movb   $0x0,-0xa(%rbp)
jmp    11a3 <writeH+0x73>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%al
mov    %al,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%eax
mov    %al,-0xd(%rbp)
movb   $0x2e,-0xb(%rbp)
movb   $0x68,-0xa(%rbp)
movb   $0x0,-0x9(%rbp)
lea    -0x12(%rbp),%rdi
lea    0xe52(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ce <writeH+0x9e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1204 <writeH+0xd4>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xe26(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xe54(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeH>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebp
movl   $0x6576656c,0xe(%rsp)
65
movb   $0x6c,0x12(%rsp)
cmp    $0xa,%edi
jge    1154 <writeH+0x24>
mov    $0x68,%bl
mov    $0x2e,%cl
xor    %edx,%edx
mov    %ebp,%eax
jmp    1179 <writeH+0x49>
mov    %ebp,%ecx
mov    $0xcccccccd,%eax
imul   %rcx,%rax
shr    $0x23,%rax
lea    (%rax,%rax,1),%ecx
lea    (%rcx,%rcx,4),%edx
mov    %ebp,%ecx
sub    %edx,%ecx
or     $0x30,%cl
movb   $0x0,0x17(%rsp)
mov    $0x68,%dl
mov    $0x2e,%bl
add    $0x30,%al
mov    %al,0x13(%rsp)
mov    %cl,0x14(%rsp)
mov    %bl,0x15(%rsp)
mov    %dl,0x16(%rsp)
lea    0xe6e(%rip),%rsi
lea    0xe(%rsp),%rdi
call   1050 <fopen@plt>
test   %rax,%rax
je     11d2 <writeH+0xa2>
mov    %rax,%rbx
lea    0xe57(%rip),%rsi
mov    %rax,%rdi
mov    %ebp,%edx
call   1040 <fprintf@plt>
lea    0xe87(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
call   1040 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    11d7 <writeH+0xa7>
mov    $0xffffffff,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [65 x i8] c"/*\0A * level %i\0A * generated with xythobuz' BobLevelCreator\0A */\0A\0A\00"
@.str.2 = [27 x i8] c"extern char **level%i[8];\0A\00"
define i32 @writeH(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [10 x i8]
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
store i8 108, i8* %10
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 1
store i8 101, i8* %11
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 2
store i8 118, i8* %12
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 3
store i8 101, i8* %13
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 4
store i8 108, i8* %14
%15 = load i32, i32* %3
%16 = icmp slt i32 %15, 10
br i1 %16, label %17, label %25
17: ; preds = %1
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 48
%20 = trunc i32 %19 to i8
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 5
store i8 %20, i8* %21
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 6
store i8 46, i8* %22
%23 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 7
store i8 104, i8* %23
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 8
store i8 0, i8* %24
br label %39
25: ; preds = %1
%26 = load i32, i32* %3
%27 = srem i32 %26, 10
%28 = add nsw i32 %27, 48
%29 = trunc i32 %28 to i8
%30 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 6
store i8 %29, i8* %30
%31 = load i32, i32* %3
%32 = sdiv i32 %31, 10
%33 = add nsw i32 %32, 48
%34 = trunc i32 %33 to i8
%35 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 5
store i8 %34, i8* %35
%36 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 7
store i8 46, i8* %36
%37 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 8
store i8 104, i8* %37
%38 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 9
store i8 0, i8* %38
br label %39
39: ; preds = %25, %17
%40 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%41 = call i32* @fopen(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %41, i32** %5
%42 = load i32*, i32** %5
%43 = icmp eq i32* %42, null
br i1 %43, label %44, label %45
44: ; preds = %39
store i32 -1, i32* %2
br label %54
45: ; preds = %39
%46 = load i32*, i32** %5
%47 = load i32, i32* %3
%48 = call i32 @fprintf(i32* %46, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), i32 %47)
%49 = load i32*, i32** %5
%50 = load i32, i32* %3
%51 = call i32 @fprintf(i32* %49, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %50)
%52 = load i32*, i32** %5
%53 = call i32 @fclose(i32* %52)
store i32 0, i32* %2
br label %54
54: ; preds = %45, %44
%55 = load i32, i32* %2
ret i32 %55
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [65 x i8] c"/*\0A * level %i\0A * generated with xythobuz' BobLevelCreator\0A */\0A\0A\00"
@.str.2 = [27 x i8] c"extern char **level%i[8];\0A\00"
define i32 @writeH(i32 %0) {
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
store i8 108, i8* %3
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 1
store i8 101, i8* %4
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 2
store i8 118, i8* %5
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 3
store i8 101, i8* %6
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 4
store i8 108, i8* %7
%8 = icmp slt i32 %0, 10
br i1 %8, label %15, label %9
9: ; preds = %1
%10 = urem i32 %0, 10
%11 = trunc i32 %10 to i8
%12 = or i8 %11, 48
%13 = udiv i32 %0, 10
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 9
store i8 0, i8* %14
br label %15
15: ; preds = %1, %9
%16 = phi i32 [ %13, %9 ], [ %0, %1 ]
%17 = phi i8 [ %12, %9 ], [ 46, %1 ]
%18 = phi i8 [ 46, %9 ], [ 104, %1 ]
%19 = phi i8 [ 104, %9 ], [ 0, %1 ]
%20 = trunc i32 %16 to i8
%21 = add i8 %20, 48
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 5
store i8 %21, i8* %22
%23 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 6
store i8 %17, i8* %23
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 7
store i8 %18, i8* %24
%25 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 8
store i8 %19, i8* %25
%26 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%27 = icmp eq i32* %26, null
br i1 %27, label %32, label %28
28: ; preds = %15
%29 = tail call i32 @fprintf(i32* %26, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), i32 %0)
%30 = tail call i32 @fprintf(i32* %26, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %0)
%31 = tail call i32 @fclose(i32* %26)
br label %32
32: ; preds = %15, %28
%33 = phi i32 [ 0, %28 ], [ -1, %15 ]
ret i32 %33
}