#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*/ error(char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
FILE *init_svg(char *filename, unsigned int xsize, unsigned int ysize) {
  FILE *fsvg;
  fsvg = fopen(filename, "w");
  if (fsvg == NULL)
    error("init_svg: unable to open SVG output file.");
  fprintf(fsvg, "<?xml version=\"1.0\" standalone=\"no\"?>\n");
  fprintf(fsvg, "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n");
  fprintf(fsvg, " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
  fprintf(fsvg, "<svg width=\"%upx\" height=\"%upx\" ", xsize, ysize);
  fprintf(fsvg, "version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\" ");
  fprintf(fsvg, "xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n");
  return fsvg;
}


x86 assembly (clang, -O0):
<init_svg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb3(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    116d <init_svg+0x3d>
lea    0xe9a(%rip),%rdi
call   1040 <error@plt>
mov    -0x18(%rbp),%rdi
lea    0xeb4(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xec9(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xee7(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xf05(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xf14(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xf35(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_svg>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
lea    0xeb0(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1169 <init_svg+0x29>
lea    0xe9e(%rip),%rdi
call   1040 <error@plt>
lea    0xebc(%rip),%rdi
mov    $0x26,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
lea    0xeca(%rip),%rdi
mov    $0x2f,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
lea    0xee1(%rip),%rdi
mov    $0x35,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
lea    0xefe(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xf09(%rip),%rdi
mov    $0x32,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
lea    0xf23(%rip),%rdi
mov    $0x2c,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [42 x i8] c"init_svg: unable to open SVG output file.\00"
@.str.2 = [39 x i8] c"<?xml version=\221.0\22 standalone=\22no\22?>\0A\00"
@.str.3 = [48 x i8] c"<!DOCTYPE svg PUBLIC \22-//W3C//DTD SVG 1.1//EN\22\0A\00"
@.str.4 = [54 x i8] c" \22http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\22>\0A\00"
@.str.5 = [33 x i8] c"<svg width=\22%upx\22 height=\22%upx\22 \00"
@.str.6 = [51 x i8] c"version=\221.1\22\0A xmlns=\22http://www.w3.org/2000/svg\22 \00"
@.str.7 = [45 x i8] c"xmlns:xlink=\22http://www.w3.org/1999/xlink\22>\0A\00"
define i32* @init_svg(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%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** %7
%10 = load i32*, i32** %7
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = call i32 @error(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %12, %3
%15 = load i32*, i32** %7
%16 = call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%17 = load i32*, i32** %7
%18 = call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0))
%19 = load i32*, i32** %7
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0))
%21 = load i32*, i32** %7
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i32 %22, i32 %23)
%25 = load i32*, i32** %7
%26 = call i32 (i32*, i8*, ...) @fprintf(i32* %25, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0))
%27 = load i32*, i32** %7
%28 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0))
%29 = load i32*, i32** %7
ret i32* %29
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [42 x i8] c"init_svg: unable to open SVG output file.\00"
@.str.2 = [39 x i8] c"<?xml version=\221.0\22 standalone=\22no\22?>\0A\00"
@.str.3 = [48 x i8] c"<!DOCTYPE svg PUBLIC \22-//W3C//DTD SVG 1.1//EN\22\0A\00"
@.str.4 = [54 x i8] c" \22http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\22>\0A\00"
@.str.5 = [33 x i8] c"<svg width=\22%upx\22 height=\22%upx\22 \00"
@.str.6 = [51 x i8] c"version=\221.1\22\0A xmlns=\22http://www.w3.org/2000/svg\22 \00"
@.str.7 = [45 x i8] c"xmlns:xlink=\22http://www.w3.org/1999/xlink\22>\0A\00"
define noalias i32* @init_svg(i8* nocapture %0, i32 %1, i32 %2) {
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @error(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %6, %3
%9 = tail call i64 @fwrite(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i64 38, i64 1, i32* %4)
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i64 47, i64 1, i32* %4)
%11 = tail call i64 @fwrite(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0), i64 53, i64 1, i32* %4)
%12 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i32 %1, i32 %2)
%13 = tail call i64 @fwrite(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0), i64 50, i64 1, i32* %4)
%14 = tail call i64 @fwrite(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0), i64 44, i64 1, i32* %4)
ret i32* %4
}