#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ get_place_str(int, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void output_move(const char *move_file, int move_type, int src, int dest,
                 int score) {
  char src_str[3], dest_str[3];
  FILE *fp;
  fp = fopen(move_file, "wt");
  if (fp == NULL) {
    fprintf(fp, "cannot open output file \"%s\"\n", move_file);
    exit(1);
  }
  get_place_str(src, src_str);
  if (move_type == 0)
    get_place_str(dest, dest_str);
  else
    strcpy(dest_str, "0");
  fprintf(fp, "%d\n%s\n%s\n%d\n", move_type, src_str, dest_str, score);
  fclose(fp);
}


x86 assembly (clang, -O0):
<output_move>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe7c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11b8 <output_move+0x58>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe5c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%edi
lea    -0x1b(%rbp),%rsi
call   1060 <get_place_str@plt>
cmpl   $0x0,-0xc(%rbp)
jne    11df <output_move+0x7f>
mov    -0x14(%rbp),%edi
lea    -0x1e(%rbp),%rsi
call   1060 <get_place_str@plt>
jmp    11ef <output_move+0x8f>
lea    -0x1e(%rbp),%rdi
lea    0xe37(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    -0x1b(%rbp),%rcx
lea    -0x1e(%rbp),%r8
mov    -0x18(%rbp),%r9d
lea    0xe1a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_move>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %ecx,%r15d
mov    %edx,%ebp
mov    %esi,%r12d
mov    %rdi,%r13
lea    0xe80(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11f6 <output_move+0x96>
mov    %rax,%rbx
lea    0x5(%rsp),%rsi
mov    %ebp,%edi
call   1060 <get_place_str@plt>
test   %r12d,%r12d
je     11b1 <output_move+0x51>
lea    0xe7c(%rip),%rsi
lea    0x2(%rsp),%rdi
call   1030 <strcpy@plt>
jmp    11be <output_move+0x5e>
lea    0x2(%rsp),%rsi
mov    %r15d,%edi
call   1060 <get_place_str@plt>
lea    0xe5e(%rip),%rsi
lea    0x5(%rsp),%rcx
lea    0x2(%rsp),%r8
mov    %rbx,%rdi
mov    %r12d,%edx
mov    %r14d,%r9d
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe06(%rip),%rsi
xor    %edi,%edi
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"wt\00"
@.str.1 = [30 x i8] c"cannot open output file \22%s\22\0A\00"
@.str.2 = [2 x i8] c"0\00"
@.str.3 = [13 x i8] c"%d\0A%s\0A%s\0A%d\0A\00"
define void @output_move(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [3 x i8]
%12 = alloca [3 x i8]
%13 = alloca i32*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%14 = load i8*, i8** %6
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %13
%16 = load i32*, i32** %13
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %23
18: ; preds = %5
%19 = load i32*, i32** %13
%20 = load i8*, i8** %6
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %5
%24 = load i32, i32* %8
%25 = getelementptr inbounds [3 x i8], [3 x i8]* %11, i64 0, i64 0
%26 = call i32 @get_place_str(i32 %24, i8* %25)
%27 = load i32, i32* %7
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %23
%30 = load i32, i32* %9
%31 = getelementptr inbounds [3 x i8], [3 x i8]* %12, i64 0, i64 0
%32 = call i32 @get_place_str(i32 %30, i8* %31)
br label %36
33: ; preds = %23
%34 = getelementptr inbounds [3 x i8], [3 x i8]* %12, i64 0, i64 0
%35 = call i32 @strcpy(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %36
36: ; preds = %33, %29
%37 = load i32*, i32** %13
%38 = load i32, i32* %7
%39 = getelementptr inbounds [3 x i8], [3 x i8]* %11, i64 0, i64 0
%40 = getelementptr inbounds [3 x i8], [3 x i8]* %12, i64 0, i64 0
%41 = load i32, i32* %10
%42 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %38, i8* %39, i8* %40, i32 %41)
%43 = load i32*, i32** %13
%44 = call i32 @fclose(i32* %43)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"wt\00"
@.str.1 = [30 x i8] c"cannot open output file \22%s\22\0A\00"
@.str.2 = [2 x i8] c"0\00"
@.str.3 = [13 x i8] c"%d\0A%s\0A%s\0A%d\0A\00"
define void @output_move(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca [3 x i8]
%7 = alloca [3 x i8]
%8 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%9 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%10 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %5
%13 = tail call i32 (i32*, i8*, ...) @fprintf(i32* null, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %5
%16 = call i32 @get_place_str(i32 %2, i8* %8)
%17 = icmp eq i32 %1, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @get_place_str(i32 %3, i8* %9)
br label %22
20: ; preds = %15
%21 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %20, %18
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %10, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %1, i8* %8, i8* %9, i32 %4)
%24 = call i32 @fclose(i32* %10)
ret void
}