#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 */

/* Variables and functions */
scalar_t__ buffer_from_file(char const *, unsigned char *, int);
int /*<<< orphan*/ cart_crc32(unsigned char *, int *, int);
int f2au_GameID_gen(const char *filename, int *game_id) {
  unsigned char buffer[189];
  if (buffer_from_file(filename, buffer, 189) < 0)
    return -1;
  buffer[180] = buffer[188];
  cart_crc32(buffer, game_id, 181);
  return 0;
}


x86 assembly (clang, -O0):
<f2au_GameID_gen>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
mov    $0xbd,%edx
call   1040 <buffer_from_file@plt>
cmp    $0x0,%rax
jge    115e <f2au_GameID_gen+0x3e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1180 <f2au_GameID_gen+0x60>
mov    -0x24(%rbp),%al
mov    %al,-0x2c(%rbp)
lea    -0xe0(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0xb5,%edx
call   1030 <cart_crc32@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f2au_GameID_gen>:
push   %rbx
sub    $0xc0,%rsp
mov    %rsi,%rbx
mov    %rsp,%rsi
mov    $0xbd,%edx
call   1040 <buffer_from_file@plt>
test   %rax,%rax
js     115f <f2au_GameID_gen+0x3f>
mov    0xbc(%rsp),%al
mov    %al,0xb4(%rsp)
mov    %rsp,%rdi
mov    %rbx,%rsi
mov    $0xb5,%edx
call   1030 <cart_crc32@plt>
xor    %eax,%eax
jmp    1164 <f2au_GameID_gen+0x44>
mov    $0xffffffff,%eax
add    $0xc0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @f2au_GameID_gen(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca [189 x i8]
store i8* %0, i8** %4
store i32* %1, i32** %5
%7 = load i8*, i8** %4
%8 = getelementptr inbounds [189 x i8], [189 x i8]* %6, i64 0, i64 0
%9 = call i64 @buffer_from_file(i8* %7, i8* %8, i32 189)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 -1, i32* %3
br label %19
12: ; preds = %2
%13 = getelementptr inbounds [189 x i8], [189 x i8]* %6, i64 0, i64 188
%14 = load i8, i8* %13
%15 = getelementptr inbounds [189 x i8], [189 x i8]* %6, i64 0, i64 180
store i8 %14, i8* %15
%16 = getelementptr inbounds [189 x i8], [189 x i8]* %6, i64 0, i64 0
%17 = load i32*, i32** %5
%18 = call i32 @cart_crc32(i8* %16, i32* %17, i32 181)
store i32 0, i32* %3
br label %19
19: ; preds = %12, %11
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
define i32 @f2au_GameID_gen(i8* %0, i32* %1) {
%3 = alloca [189 x i8]
%4 = getelementptr inbounds [189 x i8], [189 x i8]* %3, i64 0, i64 0
%5 = call i64 @buffer_from_file(i8* %0, i8* %4, i32 189)
%6 = icmp slt i64 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = getelementptr inbounds [189 x i8], [189 x i8]* %3, i64 0, i64 188
%9 = load i8, i8* %8
%10 = getelementptr inbounds [189 x i8], [189 x i8]* %3, i64 0, i64 180
store i8 %9, i8* %10
%11 = call i32 @cart_crc32(i8* %4, i32* %1, i32 181)
br label %12
12: ; preds = %2, %7
%13 = phi i32 [ 0, %7 ], [ -1, %2 ]
ret i32 %13
}