#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 EOF;
int fputc(unsigned char, int /*<<< orphan*/ *);
int unicoder_writeCodePoint(unsigned char *, unsigned int, unsigned int);
int unicoder_writeCodePointToFile(FILE *file, unsigned int x,
                                  unsigned int encoding) {
  unsigned char p[4];
  int i, numBytes, fputcRet;
  if (file == NULL)
    return -64;
  numBytes = 0;
  for (i = 0; i < 4; i++)
    p[i] = 0;
  numBytes = unicoder_writeCodePoint(p, x, encoding);
  if (numBytes < 1)
    return numBytes;
  for (i = 0; i < numBytes; i++) {
    fputcRet = fputc(p[i], file);
    if (fputcRet == EOF)
      return -64;
  }
  return numBytes;
}


x86 assembly (clang, -O0):
<unicoder_writeCodePointToFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1149 <unicoder_writeCodePointToFile+0x29>
movl   $0xffffffc0,-0x4(%rbp)
jmp    1200 <unicoder_writeCodePointToFile+0xe0>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x4,-0x20(%rbp)
jge    1178 <unicoder_writeCodePointToFile+0x58>
movslq -0x20(%rbp),%rax
movb   $0x0,-0x1c(%rbp,%rax,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1157 <unicoder_writeCodePointToFile+0x37>
lea    -0x1c(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <unicoder_writeCodePoint@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jge    119f <unicoder_writeCodePointToFile+0x7f>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1200 <unicoder_writeCodePointToFile+0xe0>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11fa <unicoder_writeCodePointToFile+0xda>
movslq -0x20(%rbp),%rax
mov    -0x1c(%rbp,%rax,1),%al
mov    -0x10(%rbp),%rsi
movzbl %al,%edi
call   1030 <fputc@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    0x2e15(%rip),%rcx
cmp    (%rcx),%eax
jne    11e7 <unicoder_writeCodePointToFile+0xc7>
movl   $0xffffffc0,-0x4(%rbp)
jmp    1200 <unicoder_writeCodePointToFile+0xe0>
jmp    11ec <unicoder_writeCodePointToFile+0xcc>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11a6 <unicoder_writeCodePointToFile+0x86>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unicoder_writeCodePointToFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xffffffc0,%r14d
test   %rdi,%rdi
je     117f <unicoder_writeCodePointToFile+0x5f>
mov    %rdi,%r12
movl   $0x0,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1040 <unicoder_writeCodePoint@plt>
mov    %eax,%r15d
test   %eax,%eax
jle    117c <unicoder_writeCodePointToFile+0x5c>
mov    %r15d,%ebp
xor    %ebx,%ebx
mov    0x2e8a(%rip),%r13
xchg   %ax,%ax
movzbl 0x4(%rsp,%rbx,1),%edi
mov    %r12,%rsi
call   1030 <fputc@plt>
cmp    0x0(%r13),%eax
je     117f <unicoder_writeCodePointToFile+0x5f>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <unicoder_writeCodePointToFile+0x40>
mov    %r15d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @unicoder_writeCodePointToFile(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca [4 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%12 = load i32*, i32** %5
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %15
14: ; preds = %3
store i32 -64, i32* %4
br label %57
15: ; preds = %3
store i32 0, i32* %10
store i32 0, i32* %9
br label %16
16: ; preds = %23, %15
%17 = load i32, i32* %9
%18 = icmp slt i32 %17, 4
br i1 %18, label %19, label %26
19: ; preds = %16
%20 = load i32, i32* %9
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 %21
store i8 0, i8* %22
br label %23
23: ; preds = %19
%24 = load i32, i32* %9
%25 = add nsw i32 %24, 1
store i32 %25, i32* %9
br label %16
26: ; preds = %16
%27 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%28 = load i32, i32* %6
%29 = load i32, i32* %7
%30 = call i32 @unicoder_writeCodePoint(i8* %27, i32 %28, i32 %29)
store i32 %30, i32* %10
%31 = load i32, i32* %10
%32 = icmp slt i32 %31, 1
br i1 %32, label %33, label %35
33: ; preds = %26
%34 = load i32, i32* %10
store i32 %34, i32* %4
br label %57
35: ; preds = %26
store i32 0, i32* %9
br label %36
36: ; preds = %52, %35
%37 = load i32, i32* %9
%38 = load i32, i32* %10
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %55
40: ; preds = %36
%41 = load i32, i32* %9
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = load i32*, i32** %5
%46 = call i32 @fputc(i8 zeroext %44, i32* %45)
store i32 %46, i32* %11
%47 = load i32, i32* %11
%48 = load i32, i32* @EOF
%49 = icmp eq i32 %47, %48
br i1 %49, label %50, label %51
50: ; preds = %40
store i32 -64, i32* %4
br label %57
51: ; preds = %40
br label %52
52: ; preds = %51
%53 = load i32, i32* %9
%54 = add nsw i32 %53, 1
store i32 %54, i32* %9
br label %36
55: ; preds = %36
%56 = load i32, i32* %10
store i32 %56, i32* %4
br label %57
57: ; preds = %55, %50, %33, %14
%58 = load i32, i32* %4
ret i32 %58
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @unicoder_writeCodePointToFile(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to [4 x i8]*
%6 = bitcast i32* %4 to i8*
%7 = icmp eq i32* %0, null
br i1 %7, label %23, label %8
8: ; preds = %3
store i32 0, i32* %4
%9 = call i32 @unicoder_writeCodePoint(i8* %6, i32 %1, i32 %2)
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %8
%12 = zext i32 %9 to i64
br label %15
13: ; preds = %15
%14 = icmp eq i64 %22, %12
br i1 %14, label %23, label %15
15: ; preds = %11, %13
%16 = phi i64 [ 0, %11 ], [ %22, %13 ]
%17 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = call i32 @fputc(i8 zeroext %18, i32* %0)
%20 = load i32, i32* @EOF
%21 = icmp eq i32 %19, %20
%22 = add nuw nsw i64 %16, 1
br i1 %21, label %23, label %13
23: ; preds = %15, %13, %8, %3
%24 = phi i32 [ -64, %3 ], [ %9, %8 ], [ -64, %15 ], [ %9, %13 ]
ret i32 %24
}