#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 *, unsigned char);
void cfile_vec_F12_int(char *file, int n, int *L) {
  FILE *fichier;
  fichier = fopen(file, "wb");
  unsigned char c = 0;
  unsigned char c1 = 0;
  int i;
  for (i = 0; i < n; i++) {
    c = L[i] & 255;
    c1 = (L[i] >> 8) & 255;
    fprintf(fichier, "%c", c1);
    fprintf(fichier, "%c", c);
  }
  fclose(fichier);
}


x86 assembly (clang, -O0):
<cfile_vec_F12_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb2(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
movb   $0x0,-0x21(%rbp)
movb   $0x0,-0x22(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d1 <cfile_vec_F12_int+0xa1>
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
and    $0xff,%eax
mov    %al,-0x21(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %al,-0x22(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe5d(%rip),%rsi
movzbl -0x22(%rbp),%edx
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xe49(%rip),%rsi
movzbl -0x21(%rbp),%edx
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1166 <cfile_vec_F12_int+0x36>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cfile_vec_F12_int>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %esi,%ebp
lea    0xebc(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r12
test   %ebp,%ebp
jle    1188 <cfile_vec_F12_int+0x58>
mov    %ebp,%r15d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r14,%rbp,4),%ebx
mov    %ebx,%eax
shr    $0x8,%eax
movsbl %al,%edi
mov    %r12,%rsi
call   1040 <fputc@plt>
movsbl %bl,%edi
mov    %r12,%rsi
call   1040 <fputc@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1160 <cfile_vec_F12_int+0x30>
mov    %r12,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"wb\00"
@.str.1 = [3 x i8] c"%c\00"
define void @cfile_vec_F12_int(i8* %0, i32 %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8
%9 = alloca i8
%10 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%11 = load i8*, i8** %4
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %7
store i8 0, i8* %8
store i8 0, i8* %9
store i32 0, i32* %10
br label %13
13: ; preds = %39, %3
%14 = load i32, i32* %10
%15 = load i32, i32* %5
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %42
17: ; preds = %13
%18 = load i32*, i32** %6
%19 = load i32, i32* %10
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
%22 = load i32, i32* %21
%23 = and i32 %22, 255
%24 = trunc i32 %23 to i8
store i8 %24, i8* %8
%25 = load i32*, i32** %6
%26 = load i32, i32* %10
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = load i32, i32* %28
%30 = ashr i32 %29, 8
%31 = and i32 %30, 255
%32 = trunc i32 %31 to i8
store i8 %32, i8* %9
%33 = load i32*, i32** %7
%34 = load i8, i8* %9
%35 = call i32 @fprintf(i32* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %34)
%36 = load i32*, i32** %7
%37 = load i8, i8* %8
%38 = call i32 @fprintf(i32* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %37)
br label %39
39: ; preds = %17
%40 = load i32, i32* %10
%41 = add nsw i32 %40, 1
store i32 %41, i32* %10
br label %13
42: ; preds = %13
%43 = load i32*, i32** %7
%44 = call i32 @fclose(i32* %43)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"wb\00"
define void @cfile_vec_F12_int(i8* nocapture %0, i32 %1, i32* nocapture %2) {
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %20
6: ; preds = %3
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %18, %8 ]
%10 = getelementptr inbounds i32, i32* %2, i64 %9
%11 = load i32, i32* %10
%12 = shl i32 %11, 16
%13 = ashr i32 %12, 24
%14 = tail call i32 @fputc(i32 %13, i32* %4)
%15 = shl i32 %11, 24
%16 = ashr exact i32 %15, 24
%17 = tail call i32 @fputc(i32 %16, i32* %4)
%18 = add nuw nsw i64 %9, 1
%19 = icmp eq i64 %18, %7
br i1 %19, label %20, label %8
20: ; preds = %8, %3
%21 = tail call i32 @fclose(i32* %4)
ret void
}