#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*/ fwrite(struct _RANKED *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *);
int main() {
  typedef struct _RANKED {
    char name[4];
    unsigned int score;
  } RANKED;
  RANKED player_vector[5];
  sprintf(player_vector[0].name, "AAA");
  player_vector[0].score = 15000;
  sprintf(player_vector[1].name, "ADR");
  player_vector[1].score = 10000;
  sprintf(player_vector[2].name, "POS");
  player_vector[2].score = 5000;
  sprintf(player_vector[3].name, "DIA");
  player_vector[3].score = 1000;
  sprintf(player_vector[4].name, "AVL");
  player_vector[4].score = 100;
  FILE *pFile;
  pFile = fopen("./ranking", "wb");
  if (!pFile) {
    printf("Unable to open file!");
    return 1;
  }
  fwrite(player_vector, sizeof(RANKED), 5, pFile);
  fclose(pFile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1060 <sprintf@plt>
movl   $0x3a98,-0x2c(%rbp)
lea    -0x30(%rbp),%rdi
add    $0x8,%rdi
lea    0xe7f(%rip),%rsi
call   1060 <sprintf@plt>
movl   $0x2710,-0x24(%rbp)
lea    -0x30(%rbp),%rdi
add    $0x10,%rdi
lea    0xe68(%rip),%rsi
call   1060 <sprintf@plt>
movl   $0x1388,-0x1c(%rbp)
lea    -0x30(%rbp),%rdi
add    $0x18,%rdi
lea    0xe51(%rip),%rsi
call   1060 <sprintf@plt>
movl   $0x3e8,-0x14(%rbp)
lea    -0x30(%rbp),%rdi
add    $0x20,%rdi
lea    0xe3a(%rip),%rsi
call   1060 <sprintf@plt>
movl   $0x64,-0xc(%rbp)
lea    0xe2b(%rip),%rdi
lea    0xe2e(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    121c <main+0xcc>
lea    0xe16(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1243 <main+0xf3>
lea    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rcx
mov    $0x8,%esi
mov    $0x5,%edx
call   1070 <fwrite@plt>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
movaps 0xeb4(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xeb9(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0x64004c5641,%rax
mov    %rax,0x20(%rsp)
lea    0xeae(%rip),%rdi
lea    0xeb1(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11a7 <main+0x67>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x8,%esi
mov    $0x5,%edx
mov    %rax,%rcx
call   1060 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    11b8 <main+0x78>
lea    0xe7f(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct._RANKED = type { [4 x i8], i32 }
%struct._RANKED.0 = type opaque
@.str = [4 x i8] c"AAA\00"
@.str.1 = [4 x i8] c"ADR\00"
@.str.2 = [4 x i8] c"POS\00"
@.str.3 = [4 x i8] c"DIA\00"
@.str.4 = [4 x i8] c"AVL\00"
@.str.5 = [10 x i8] c"./ranking\00"
@.str.6 = [3 x i8] c"wb\00"
@.str.7 = [21 x i8] c"Unable to open file!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x %struct._RANKED]
%3 = alloca i32*
store i32 0, i32* %1
%4 = getelementptr inbounds [5 x %struct._RANKED], [5 x %struct._RANKED]* %2, i64 0, i64 0
%5 = getelementptr inbounds %struct._RANKED, %struct._RANKED* %4, i32 0, i32 0
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%7 = call i32 @sprintf(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [5 x %struct._RANKED], [5 x %struct._RANKED]* %2, i64 0, i64 0
%9 = getelementptr inbounds %struct._RANKED, %struct._RANKED* %8, i32 0, i32 1
store i32 15000, i32* %9
%10 = getelementptr inbounds [5 x %struct._RANKED], [5 x %struct._RANKED]* %2, i64 0, i64 1
%11 = getelementptr inbounds %struct._RANKED, %struct._RANKED* %10, i32 0, i32 0
%12 = getelementptr inbounds [4 x i8], [4 x i8]* %11, i64 0, i64 0
%13 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds [5 x %struct._RANKED], [5 x %struct._RANKED]* %2, i64 0, i64 1
%15 = getelementptr inbounds %struct._RANKED, %struct._RANKED* %14, i32 0, i32 1
store i32 10000, i32* %15
%16 = getelementptr inbounds [5 x %struct._RANKED], [5 x %struct._RANKED]* %2, i64 0, i64 2
%17 = getelementptr inbounds %struct._RANKED, %struct._RANKED* %16, i32 0, i32 0
%18 = getelementptr inbounds [4 x i8], [4 x i8]* %17, i64 0, i64 0
%19 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%20 = getelementptr inbounds [5 x %struct._RANKED], [5 x %struct._RANKED]* %2, i64 0, i64 2
%21 = getelementptr inbounds %struct._RANKED, %struct._RANKED* %20, i32 0, i32 1
store i32 5000, i32* %21
%22 = getelementptr inbounds [5 x %struct._RANKED], [5 x %struct._RANKED]* %2, i64 0, i64 3
%23 = getelementptr inbounds %struct._RANKED, %struct._RANKED* %22, i32 0, i32 0
%24 = getelementptr inbounds [4 x i8], [4 x i8]* %23, i64 0, i64 0
%25 = call i32 @sprintf(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%26 = getelementptr inbounds [5 x %struct._RANKED], [5 x %struct._RANKED]* %2, i64 0, i64 3
%27 = getelementptr inbounds %struct._RANKED, %struct._RANKED* %26, i32 0, i32 1
store i32 1000, i32* %27
%28 = getelementptr inbounds [5 x %struct._RANKED], [5 x %struct._RANKED]* %2, i64 0, i64 4
%29 = getelementptr inbounds %struct._RANKED, %struct._RANKED* %28, i32 0, i32 0
%30 = getelementptr inbounds [4 x i8], [4 x i8]* %29, i64 0, i64 0
%31 = call i32 @sprintf(i8* %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%32 = getelementptr inbounds [5 x %struct._RANKED], [5 x %struct._RANKED]* %2, i64 0, i64 4
%33 = getelementptr inbounds %struct._RANKED, %struct._RANKED* %32, i32 0, i32 1
store i32 100, i32* %33
%34 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i32* %34, i32** %3
%35 = load i32*, i32** %3
%36 = icmp ne i32* %35, null
br i1 %36, label %39, label %37
37: ; preds = %0
%38 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %1
br label %46
39: ; preds = %0
%40 = getelementptr inbounds [5 x %struct._RANKED], [5 x %struct._RANKED]* %2, i64 0, i64 0
%41 = bitcast %struct._RANKED* %40 to %struct._RANKED.0*
%42 = load i32*, i32** %3
%43 = call i32 @fwrite(%struct._RANKED.0* %41, i32 8, i32 5, i32* %42)
%44 = load i32*, i32** %3
%45 = call i32 @fclose(i32* %44)
store i32 0, i32* %1
br label %46
46: ; preds = %39, %37
%47 = load i32, i32* %1
ret i32 %47
}

LLVM IR (-O2):
%struct._RANKED = type { [4 x i8], i32 }
%struct._RANKED.0 = type opaque
@.str.5 = [10 x i8] c"./ranking\00"
@.str.6 = [3 x i8] c"wb\00"
@.str.7 = [21 x i8] c"Unable to open file!\00"
define i32 @main() {
%1 = alloca [5 x %struct._RANKED]
%2 = getelementptr inbounds [5 x %struct._RANKED], [5 x %struct._RANKED]* %1, i64 0, i64 0, i32 0, i64 0
%3 = bitcast [5 x %struct._RANKED]* %1 to <4 x i32>*
store <4 x i32> <i32 4276545, i32 15000, i32 5391425, i32 10000>, <4 x i32>* %3
%4 = getelementptr inbounds [5 x %struct._RANKED], [5 x %struct._RANKED]* %1, i64 0, i64 2
%5 = bitcast %struct._RANKED* %4 to <4 x i32>*
store <4 x i32> <i32 5459792, i32 5000, i32 4278596, i32 1000>, <4 x i32>* %5
%6 = getelementptr inbounds [5 x %struct._RANKED], [5 x %struct._RANKED]* %1, i64 0, i64 4
%7 = bitcast %struct._RANKED* %6 to i32*
store i32 5002817, i32* %7
%8 = getelementptr inbounds [5 x %struct._RANKED], [5 x %struct._RANKED]* %1, i64 0, i64 4, i32 1
store i32 100, i32* %8
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %17
13: ; preds = %0
%14 = bitcast [5 x %struct._RANKED]* %1 to %struct._RANKED.0*
%15 = call i32 @fwrite(%struct._RANKED.0* %14, i32 8, i32 5, i32* %9)
%16 = tail call i32 @fclose(i32* %9)
br label %17
17: ; preds = %13, %11
%18 = phi i32 [ 0, %13 ], [ 1, %11 ]
ret i32 %18
}